Announcement

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

    Server Application – DMI Validation

    Hi

    I followed the example Server Application – DMI Validation
    But after quantity inputted, it did not call the com.isomorphic.examples.server.validation.ValidatorDMI.java

    Is there any setup required in web.xml or other files?


    Many Thanks



    <DataSource ID="validationDMI_orderForm" serverType="sql">
    <fields>
    <field name="orderItem" type="sequence" primaryKey="true"/>
    <field name="itemId" foreignKey="StockItem.id" required="true"/>
    <field name="quantity" type="integer" length="9">
    <validators>
    <validator type="serverCustom">
    <serverObject lookupStyle="new" className="com.isomorphic.examples.server.validation.ValidatorDMI"/>
    <errorMessage>Only $available in stock</errorMessage>
    </validator>
    </validators>
    </field>
    <field name="instructions" type="text"/>
    </fields>
    </DataSource>

    #2
    This isn't enough information to enable anyone to help you. You need at the least:

    1. product being used and full version

    2. indicate how you are triggering validation

    3. indicate whether you see a request to the server, and if so, the full server logs for the request

    Comment


      #3
      Hi

      I am using SmartClient_v91p_2014-07-18_Evaluation for evaluation purpose

      Hi


      My code is:


      DMI.jsp
      ------------------------------------------------------------------------

      <%@ taglib uri="/WEB-INF/iscTaglib.xml" prefix="isomorphic" %>
      <HEAD><TITLE>
      SmartClient SDK - Component Data Binding example
      </TITLE></HEAD><isomorphic:loadISC skin="SmartClient"/>
      <BODY BGCOLOR=#D3D3D3><SCRIPT>


      // load datasources
      <isomorphic:loadDS ID="validationDMI_orderForm" />
      <isomorphic:loadDS ID="StockItem" />


      isc.DynamicForm.create({
      dataSource:"validationDMI_orderForm_tony",
      fields: [
      { type:"header", defaultValue:"Add an item to your Order" },
      { name:"itemId", title:"Item", editorType:"ComboBoxItem", optionDataSource:"StockItem",
      valueField:"id", displayField:"description" },
      { name:"quantity", validateOnExit:true },
      { name:"instructions", editorType:"TextAreaItem" },
      { type:"submit", title:"Submit Order" }
      ]
      });



      </SCRIPT>
      </BODY></HTML>



      StockItem.ds.xml
      -------------------------------------------------------------------------
      <DataSource
      ID="StockItem" serverType="sql"
      >
      <fields>
      <field name="id" type="integer" primaryKey="true"
      javaClass="java.lang.Integer"/>
      <field name="stockCode" title="Stock Code" type="text" />
      <field name="description" title="Description" type="text" />
      <field name="price" title="Unit Price" type="float" />
      <field name="quantity" title="Quantity" type="integer" />
      </fields>
      </DataSource>



      validationDMI_orderForm.ds.xml
      -------------------------------------------------------------------------
      <DataSource ID="validationDMI_orderForm" serverType="sql">
      <fields>
      <field name="orderItem" type="sequence" primaryKey="true"/>
      <field name="itemId" foreignKey="StockItem.id" required="true"/>
      <field name="quantity" type="integer" length="9">
      <validators>
      <validator type="serverCustom">
      <serverObject lookupStyle="new" className="com.isomorphic.examples.server.validation.ValidatorDMI"/>
      <errorMessage>Only $available in stock</errorMessage>
      </validator>
      </validators>
      </field>
      <field name="instructions" type="text"/>
      </fields>
      </DataSource>





      ValidatorDMI.java
      ------------------------------------------------------------------------

      package com.isomorphic.examples.server.validation;

      import java.util.*;
      import javax.servlet.*;
      import javax.servlet.http.*;

      import com.isomorphic.log.*;
      import com.isomorphic.util.*;
      import com.isomorphic.datasource.*;

      // the <serverObject> declaration in a <validator> delcaration in a DataSource .ds.xml file
      // directs the SmartClient Java server libraries to find the ValidatorDMI class.
      // Several ways of finding or creating the DMI target are supported, including via Spring, or
      // via session or request attributes. See ServerObject.lookupStyle in the SmartClient Reference.
      // You can also provide your own servlet, invoking SmartClient DMI from a Spring Controller or
      // Struts Action.
      public class ValidatorDMI {

      Logger log = new Logger(ValidatorDMI.class.getName());

      // the first four arguments (value, validator, fieldName, record) are required.
      // After those four arguments, you can optionally declare further arguments for any of the
      // objects that are available at validation time, in any order.
      //
      // Here, we declare the four required arguments, and then a fifth argument of type
      // "DataSource" - it receives the DataSource that this validator was declared in.
      public boolean condition(Object value, Validator validator,
      String fieldName, Map record, DataSource ds)
      throws Exception
      {
      System.out.println("testing of DMI : com.isomorphic.examples.server.validation.ValidatorDMI ");
      log.warn("validating value: '" + value +
      "' for fieldName: '" + fieldName +
      "' in DataSource: '" + ds.getID() +
      "'\nin record: " + DataTools.prettyPrint(record) +
      "\nvalidator definition: " + DataTools.prettyPrint(validator));

      int quantityOrdered = Integer.valueOf(value.toString()).intValue();

      // look up the StockItem by id to see current quanity
      DSRequest dsRequest = new DSRequest("StockItem", "fetch");
      Object itemId = record.get("itemId");
      // if no item was selected, no way to run this validation - rely on a required
      // validator on the itemId question to tell the user to populate the form.
      if (itemId == null) return true;

      dsRequest.setCriteria(DataTools.buildMap("id", record.get("itemId")));

      Map dataMap = dsRequest.execute().getDataMap();
      if (dataMap == null) {
      // No row found - throw an error
      throw new Exception("Unrecognized stock item ID");
      }

      long quantityAvailable = ((Integer)dataMap.get("quantity")).intValue();

      if (quantityOrdered > quantityAvailable) {
      validator.addErrorMessageVariable("available", "" + quantityAvailable);
      return false;
      }

      return true;
      }
      }




      When I press the submit order button, nothing happen and ther is nothing in the server.log.

      Please advise

      Comment


        #4
        Well, the most obvious problem here is that you are binding the DynamicForm to a DataSource that doesn't exist (".._tony").

        This sort of error is very easy to troubleshoot using the Developer Console, since prominent warnings are logged.

        If you are unfamiliar with how to use the Developer Console, make sure you have read the QuickStart Guide.

        Comment


          #5
          Hi

          I changed the datasource to validationDMI_orderForm
          But is still the same.
          The java class is not called and nothing show in the server log.

          Please advise.
          Many thanks

          Comment


            #6
            We have reminded you multiple times to always post the diagnostic information covered in the FAQ.

            Please make sure to do this, every time. If we see it is missing yet again, you will not be reminded again.

            Comment


              #7
              Hi,

              But there was nothing shown in the server log when I press the sybmit order button.
              This is the server log starting from thr jsp was loaded.


              Please advise

              Many thanks



              === 2014-10-07 02:05:33,255 [sor8] INFO Compression - /isomorphic/IDACall: 165320 -> 8455 bytes
              === 2014-10-07 02:05:40,445 [sor4] DEBUG RPCDMI - rpc returned data
              === 2014-10-07 02:05:40,446 [sor4] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
              === 2014-10-07 02:05:40,446 [sor4] INFO Compression - /isomorphic/IDACall: 108 -> 108 bytes
              === 2014-10-07 02:06:22,264 [sor1] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
              === 2014-10-07 02:06:22,265 [sor1] DEBUG IDACall - Header Name:Value pair: accept:*/*
              === 2014-10-07 02:06:22,265 [sor1] DEBUG IDACall - Header Name:Value pair: accept-language:en-us
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - Header Name:Value pair: referer:http://localhost:8081/isomorphic/system/helpers/Log.html
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - Header Name:Value pair: content-type:application/x-www-form-urlencoded; charset=UTF-8
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - Header Name:Value pair: accept-encoding:gzip, deflate
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - Header Name:Value pair: user-agent:Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - Header Name:Value pair: host:localhost:8081
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - Header Name:Value pair: content-length:675
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - Header Name:Value pair: connection:Keep-Alive
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - Header Name:Value pair: cache-control:no-cache
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - Header Name:Value pair: cookie:JSESSIONID=13ABE247DB027A847A93278388C577EC; isc_cState=ready; IMyAppUser_DetailView_Main__Tabs=0; GLog=%7B%0D%20%20%20%20left%3A110%2C%20%0D%20%20%20%20top%3A101%2C%20%0D%20%20%20%20width%3A0%2C%20%0D%20%20%20%20height%3A0%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Anull%0D%7D
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - session exists: 13ABE247DB027A847A93278388C577EC
              === 2014-10-07 02:06:22,266 [sor1] DEBUG IDACall - remote user: null
              === 2014-10-07 02:06:22,349 [sor9] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\Splitbar\vsplit_snap.png
              === 2014-10-07 02:06:22,402 [sor8] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\DynamicForm\unchecked.png
              === 2014-10-07 02:06:22,520 [sor4] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\Splitbar\vsplit_snap.png
              === 2014-10-07 02:06:22,632 [sor8] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\ListGrid\header2.png
              === 2014-10-07 02:06:22,650 [sor1] DEBUG XML - Parsed XML from (in memory stream): 40ms
              === 2014-10-07 02:06:22,659 [sor1] DEBUG RPCManager - Processing 1 requests.
              === 2014-10-07 02:06:22,663 [sor1] DEBUG RPCManager - Request #1 (RPCRequest) data: {
              appID:"isc_builtin",
              className:"builtin",
              methodName:"areServerTimingsTracked",
              arguments:[
              ],
              is_ISC_RPC_DMI:true
              }
              === 2014-10-07 02:06:22,663 [sor1] INFO IDACall - Performing 1 operation(s)
              === 2014-10-07 02:06:22,919 [sor1] DEBUG RPCDMI - appConfig: isc.Application.create({
              rpcBindings:[
              {
              ID:"builtin",
              className:"com.isomorphic.rpc.BuiltinRPC",
              visibleMethods:[
              {
              name:"downloadWSDL"
              },
              {
              name:"downloadClientContent"
              },
              {
              name:"downloadClientExport"
              },
              {
              name:"xmlToJS"
              },
              {
              name:"uploadProgressCheck"
              },
              {
              name:"saveFile"
              },
              {
              name:"appendToFile"
              },
              {
              name:"loadFile"
              },
              {
              name:"deleteFile"
              },
              {
              name:"loadSharedXML"
              },
              {
              name:"saveSharedXML"
              },
              {
              name:"getAvailableScriptEngines"
              },
              {
              name:"devConsoleEvalServerScript"
              },
              {
              name:"evalJava"
              },
              {
              name:"getLogNames"
              },
              {
              name:"getLogEntries"
              },
              {
              name:"clearLogEntries"
              },
              {
              name:"getLogThresholds"
              },
              {
              name:"setLogThreshold"
              },
              {
              name:"setTemporaryLogThreshold"
              },
              {
              name:"revertTemporaryLogThresholds"
              },
              {
              name:"getPdfObject"
              },
              {
              name:"exportImage"
              },
              {
              name:"areServerTimingsTracked"
              },
              {
              name:"trackServerTimings"
              }
              ]
              },
              {
              ID:"builtin_tools",
              className:"com.isomorphic.tools.BuiltinRPC",
              visibleMethods:[
              {
              name:"getDataSourceFromTable"
              },
              {
              name:"getDataSourceJSONFromTable"
              },
              {
              name:"getDataSourceFromHibernateMapping"
              },
              {
              name:"getDataSourceJSONFromHibernateMapping"
              },
              {
              name:"getTables"
              },
              {
              name:"getFieldsFromTable"
              },
              {
              name:"getBeanFields"
              },
              {
              name:"getHibernateBeans"
              },
              {
              name:"getDatabaseProductNameAndVersion"
              },
              {
              name:"getDatabaseTableTypes"
              },
              {
              name:"setAttributes"
              },
              {
              name:"clearAttributes"
              },
              {
              name:"getAttributes"
              },
              {
              name:"getAttribute"
              },
              {
              name:"getDataSourceConfigFromJavaClass"
              },
              {
              args:"cName",
              language:"groovy",
              name:"getJavaSource",
              script:"\n if (!com.isomorphic.auth.DevModeAuthFilter.devModeAuthorized(request)) throw new Exception(\"Not Authorized\"); \n //import org.apache.bcel.Repository;\n\n try {\n return org.apache.bcel.Repository.lookupClass(cName).toString();\n } catch (Throwable e) {\n return \"Unable to reverse engineer class \"+cName+\": \"+e.getMessage();\n }\n "
              },
              {
              name:"loadDataSource"
              },
              {
              name:"dsFromXML"
              },
              {
              name:"dsConfigFromXML"
              },
              {
              name:"getDefinedDataSources"
              }
              ]
              },
              {
              ID:"builtin_adminconsole",
              className:"com.isomorphic.tools.AdminConsole",
              visibleMethods:[
              {
              name:"getDefinedDatabases"
              },
              {
              name:"testDB"
              },
              {
              name:"saveDBConfig"
              },
              {
              name:"setDefaultDB"
              },
              {
              name:"importDataSources"
              },
              {
              name:"discoverJNDIDatabases"
              }
              ]
              }
              ]
              })

              === 2014-10-07 02:06:22,920 [sor1] DEBUG RPCDMI - rpc returned RPCResponse
              === 2014-10-07 02:06:22,920 [sor1] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
              === 2014-10-07 02:06:22,920 [sor1] INFO Compression - /isomorphic/IDACall: 68 -> 74 bytes
              === 2014-10-07 02:06:23,391 [sor4] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
              === 2014-10-07 02:06:23,448 [sor4] INFO Compression - /isomorphic/IDACall: 81 -> 86 bytes
              === 2014-10-07 02:06:23,490 [sor8] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
              === 2014-10-07 02:06:23,521 [sor8] INFO Compression - /isomorphic/IDACall: 169764 -> 8509 bytes
              === 2014-10-07 02:07:41,738 [sor5] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\ListGrid\sort_descending.png
              === 2014-10-07 02:07:41,787 [sor8] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\ListGrid\header2_Over.png
              === 2014-10-07 02:08:02,346 [sor5] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\button\button_Disabled_start.png
              === 2014-10-07 02:08:02,369 [sor8] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\button\button_Disabled_stretch.png
              === 2014-10-07 02:08:02,370 [sor5] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\button\button_Disabled_end.png
              === 2014-10-07 02:08:02,479 [sor8] INFO RequestContext - URL: '/isomorphic/skins/Enterprise/images/button/button_Selected_start.png', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
              === 2014-10-07 02:08:02,479 [sor5] INFO RequestContext - URL: '/isomorphic/skins/Enterprise/images/button/button_Selected_stretch.png', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
              === 2014-10-07 02:08:02,481 [sor4] INFO RequestContext - URL: '/isomorphic/skins/Enterprise/images/button/button_Selected_end.png', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
              === 2014-10-07 02:08:02,485 [sor8] INFO Download - done streaming: C:/Tony - Framework/SmartClient_v91p_2014-07-18_Evaluation/smartclientSDK/isomorphic/skins/Enterprise/images/button/button_Selected_start.png
              === 2014-10-07 02:08:02,489 [sor4] INFO Download - done streaming: C:/Tony - Framework/SmartClient_v91p_2014-07-18_Evaluation/smartclientSDK/isomorphic/skins/Enterprise/images/button/button_Selected_end.png
              === 2014-10-07 02:08:02,490 [sor5] INFO Download - done streaming: C:/Tony - Framework/SmartClient_v91p_2014-07-18_Evaluation/smartclientSDK/isomorphic/skins/Enterprise/images/button/button_Selected_stretch.png
              === 2014-10-07 02:08:02,515 [sor8] INFO RequestContext - URL: '/isomorphic/skins/Enterprise/images/TreeGrid/file.png', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
              === 2014-10-07 02:08:02,521 [sor8] INFO Download - done streaming: C:/Tony - Framework/SmartClient_v91p_2014-07-18_Evaluation/smartclientSDK/isomorphic/skins/Enterprise/images/TreeGrid/file.png
              === 2014-10-07 02:08:02,640 [sor4] INFO Download - Returning 304: Not modified on conditional get of: C:\Tony - Framework\SmartClient_v91p_2014-07-18_Evaluation\smartclientSDK\isomorphic\skins\Enterprise\images\Scrollbar\vscroll_sprite.png
              === 2014-10-07 02:08:16,002 [sor5] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
              === 2014-10-07 02:08:16,238 [sor5] INFO Compression - /isomorphic/IDACall: 81 -> 86 bytes
              === 2014-10-07 02:08:16,257 [sor8] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
              === 2014-10-07 02:08:16,290 [sor8] INFO Compression - /isomorphic/IDACall: 165286 -> 8396 bytes
              === 2014-10-07 02:08:18,766 [sor4] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS

              Comment


                #8
                Try using the FAQ to figure out next steps.

                Comment


                  #9
                  Hi

                  FAQ does not mention what I should do in next step.

                  Please advise

                  Many thanks

                  Comment

                  Working...
                  X