Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Isomorphic
    replied
    Your serverCustom validator can embed Groovy or other code right in the .DS.xml file. See the QuickStart about Server Script support.

    Leave a comment:


  • Blama
    replied
    Hi xdebugger,

    haha, did you see my question? I had the same idea because of this thread.
    Otherwise the serverCustom validator is a very easy way to solve your problem with the only downside that is does not run in the browser. But perhaps this is not a problem?
    The serverCustom validator would also work with server.properties instead of DB.

    Best regards
    Blama

    Leave a comment:


  • xdebugger
    replied
    Hi Blama ,

    Thank you for the solution, but this will require lot of changes on my end.
    Is there any easy way to do? maybe using VelocitySupport?

    Leave a comment:


  • Blama
    replied
    Hi xdebugger,

    a lot of work for a single thing like this. Can't you store the regexp in the DB and do a normal serverCustom Java validator that does the validation with asking the DB first?
    If not, DynamicDSGenerator is what you need. See also here.

    To start it add in web.xml:
    Code:
    <servlet>
            <servlet-name>RegisterDS</servlet-name>
            <servlet-class>com.mycompany.server.RegisterDS</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
    init() is then filled with your DynamicDSGenerator that parses the .ds.xml, and with XPath that manipulates it.
    This would be the right way and is a great feature in general (you can basically build DataSources based solely on configuration data, without a .ds.xml file), but it might be a bit overkill if it is really only about the one validator.

    Best regards
    Blama

    Leave a comment:


  • xdebugger
    replied
    Hi Blama ,

    Thank you for the response.

    I have the validator element and expression attribute I need to get from the properties file.
    <validator type="regexp" expression="^[a-zA-Z]$" validateOnChange="true">

    How can we achieve this?

    Regards.

    Leave a comment:


  • Blama
    replied
    Hi xdebugger,

    it is, see here.
    Code:
    public static Long getBuildDate() {
            Config.getGlobal();
            String buildDate = (String) Config.getProperty("buildDate");
    
            SimpleDateFormat parseFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            Date buildDateAsDate = null;
            try {
                buildDateAsDate = parseFormat.parse(buildDate);
    ...
    ...
    If you need it in a DataSource (in order to use it on the client?), use a DMI for your fetch that returns the needed data as a DSResponse.

    Best regards
    Blama

    Leave a comment:


  • Is it possible to retrieve the value from sever.properties inside dataSource XML?

    Is it possible to retrieve the value from sever.properties inside dataSource field attribute ? if Yes then how it can be achieved?
Working...
X