Announcement

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

    DynamicForm validate

    SmartClient Version: SC_SNAPSHOT-2012-01-19_v8.2p/PowerEdition Deployment (built 2012-01-19)

    Hi,

    I have a dynamicForm where I do server side validation using the DMI in the dataSource. In my Java class I always return false, but when I click the button and I do an alert I see that the whole validation form is always true, even if there is a field with a validation error. Am I missing something? Well as far as I understand if one field is not passing validation than the form.validate() should return false for the whole form and specified field is pointed out with exclamation mark, or am I missunderstanding something.

    Here is my code:
    DynamicForm:
    Code:
    isc.DynamicForm.create({
            ID: "frm_main_search",
            dataSource:"search_validationDMI",
            autoDraw:false,
            numCols: 4,
            synchronousValidation:true,
            fields: [
                {name:"criteria", title: "Search By", editorType:"comboBox", wrapTitle:false, defaultToFirstOption: true},
                {name:"criteria_value", title:"Look for", type:"text", width:"200", validateOnExit:true, wrapTitle:false, keyPress: "if (keyName == 'Enter') {btn_main_search.click(); }"}
            ]
          }),
          isc.IButton.create({
            ID:"btn_main_search",
            title:"",
            icon : "icons/magnifier.png",
            autoFit: true,
            autoDraw: false,
            align: "center",
            
            click: function() {
                alert(frm_main_search.validate());
            }                         
          })
    DataSource:
    Code:
     
    <DataSource 
        ID="search_validationDMI"
    >
        <fields>
            <field name="criteria" required="true">           
                <valueMap>
                    <value ID="login">Login</value>
                    <value ID="IP">IPv4 Fix</value>
                    <value ID="surname">Nom</value>
                    <value ID="phone">Phone</value>
                </valueMap>
            </field>
            <field name="criteria_value" type="text" required="true">
                <validators>
                    <validator type="serverCustom">
                        <serverObject lookupStyle="new" className="lu.azevedo.smartclient.ValidationDMI"/>
                        <errorMessage>$message</errorMessage>
                    </validator>
                </validators>
            </field>
         </fields>
    </DataSource>

    #2
    form.validate() is synchronous so it cannot immediately tell you whether the server validator is going to pass.

    Comment


      #3
      Hi,

      Thanks for the feedback but how can I achieve this validation. I know that I could do a DMI call form the page and in the callback depending if the return argument is true or false do an action. Is there not a proper or better way to do this.

      Jero

      Comment


        #4
        What are you trying to do? saveData() validates automatically, and a queue of requests led by a failing saveData() request will not affect server state due to automatic transaction handling in Power. So why are you trying to figure out if server validators will fail, why not just save?

        Comment


          #5
          Hi,

          Well I do not want to save data, it is more a kind of a search where the user can chose from a dropdown list an attribute like login or ip and depending on the attribute choosen I want to check that the value enter in the criteria_value field matches the criterias of the attribute. As an example if the user selects from the dropdoen list IPv4 Fix I want to check that the format he enters is a correct ipv4 format. I hope you get me.

          Thanks,

          Jeronimo

          Comment


            #6
            Same concept - don't check in advance just submit the criteria, and of the criteria are bad, reject them with an error message. Trying to check the criteria before attempting to search just leads to an extra server trip.

            Comment


              #7
              Hi,

              Do you think doing a local validation an do a reject based on the criteria set for that search. Am I right?

              Thanks,

              Jeronimo

              Comment

              Working...
              X