Announcement

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

    Applying Server custom validator on listgrid field

    Hi all,
    I have a datasource on which I have applied a server side custom valdiator. This datasource is being used at many places So I want to move this validator from ds.xml to listgrid field.

    Code:
     <validators>
                    <validator type="serverCustom">
                        <serverObject lookupStyle="spring"
                            bean="myValidator"
                            className="com.server.services.impl.MyValidator" />
                        <errorMessage>Data already exists</errorMessage>
                    </validator>
                </validators>
    Is it possible to move it to listgrid field like below :
    Code:
    ListGridField field = new ListGridfield("name","title");
    Validator validator = new Validator();
    // here I can set the valdiator type to serverCustom but how do I provide other attributes?
    field.setValidators(validator);
    Thanks in advance.

    #2
    preeti_kanyal,

    this definitely does not work - your Validator class uses server classes that are not emulated by GWT.
    If the logic inside is simple you might be able to rebuild it with some clientside validator.

    Best regards
    Blama

    Comment


      #3
      THanks Blama , the documentation on https://www.smartclient.com/smartgwt...Validator.html says :

      Smart GWT supports a powerful library of ValidatorTypes which have identical behavior on both the client and the server. Beyond this, custom validators can be defined on the client and custom validation logic added on the server.

      But I am not able to find a way to apply server side validtor in client code on listgrid field.

      Comment


        #4
        Hi preetikanyal,

        99% sure this means:
        • Smart GWT supports a powerful library of ValidatorTypes which have identical behavior on both the client and the server
        • Custom validators can be defined on the client
        • Custom validation logic can be added on the server
        What is your usecase?

        Best regards
        Blama

        Comment


          #5
          My case is that I can't add the validator in DS.xml as this data source is used at multiple places where this validator is not required. So I want to just query on server before adding new data based on some parameters and stop user from adding data. That is why I want to add this server side validator on ListGridField, not in DS.xml.

          Comment


            #6
            Hi preeti_kanyal,

            see Validator.html#serverObject. You can add DSRequest dsRequest to your condition() method.
            Then just check the operationId and directly return true, if you do not want to check stuff here.

            Best regards
            Blama

            Comment

            Working...
            X