Announcement

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

    valueXPath and dealing with null-objects

    Hi,

    I have a complex object which I'm pulling from Hibernate and mapping through a datasource file. Using the example I used in the previous thread; let's say this object is an "Order" and it has a createdBy and assignedTo property; both of which are of type "User".

    The mapping for this object is as follows:

    Code:
    <DataSource
    	ID="Order"
    	serverType="generic">
    	<fields>
    		<field name="id" type="sequence" hidden="false" primaryKey="true"/>
    		<field name="title" type="text" title="Title" length="255" required="true"/>
    		<field name="type" type="enum" title="Type" length="20" required="true"/>
    		<field name="status" type="enum" title="Status" length="20" required="true"/>
    		<field name="requestedDate" type="date" title="Request Date" required="true"/>
    		<field name="closedDate" type="date" title="Closed Date" required="false"/>
    		<field name="account" type="text" title="Account" valueXPath="account/id" required="true"/>
    		<field name="accountId" type="int" title="Account" valueXPath="account/id" required="false"/>
    		<field name="accountName" type="text" title="Account" valueXPath="account/company" required="false"/>
    		<field name="csa" type="text" title="CSA" valueXPath="csa/id" required="false"/>
    		<field name="csaId" type="int" title="CSA" valueXPath="csa/id" required="false"/>
    		<field name="csaName" type="text" title="CSA" valueXPath="concat(csa/account/username, ':', csa/id)"/>
    		<field name="createdBy" type="text" title="Created By" valueXPath="createdBy/userId" required="true"/>
    		<field name="createdById" type="text" title="Created By" valueXPath="createdBy/userId" required="false"/>
    		<field name="createdByName" type="text" title="Created By" valueXPath="concat(createdBy/firstName, ' ', createdBy/lastName)" required="false"/>
    		<field name="assignedTo" type="text" title="Assigned To" valueXPath="assignedTo/userId" required="false"/>
    		<field name="assignedToId" type="text" title="Assigned To" valueXPath="assignedTo/userId" required="false"/>
    		<field name="assignedToName" type="text" title="Assigned To" valueXPath="concat(assignedTo/firstName, ' ', assignedTo/lastName)" required="false"/>
    		
    	</fields>
    	
    	 <serverObject lookupStyle="spring" bean="orderDAO"/>
    	 
    </DataSource>
    The problem I have is that some fields which are derived from complex objects; such as CSA and AssignedTo are optional and can be null.

    When this objects are pulled from the datasource; they result in the following warning message:

    Code:
    Couldn't get value at valueXPath: assignedTo/userId for datasource: Order- ignoring.  Actual error: org.apache.commons.jxpath.JXPathNotFoundException: No value for xpath: assignedTo/userId
    The datasource still renders fine (in a ListGrid, for instance); but I would like to surpress these warnings, because my datasource could potentially have thousands of items that don't have this property set and I don't want the server logs filling up with these warnings.

    The JXPath documentation indicates that for this scenario; there is a "context.setLenient(true)" option you can enable (http://today.java.net/pub/a/today/2006/08/03/java-object-querying-using-jxpath.html); but I'm not sure how to enable this with the SmartGwt server components, since the calls to JXPath are actually burried inside the SmartGWT code.

    Any ideas? This has to be a pretty common occurence...

    #2
    Can you shoe the whole log message? If it's not a warning, just use log4j to set the log category threshold to WARN to suppress those messages.

    Comment


      #3
      Here is the log message:

      11:31:57,482 WARN DataSource:364 - Couldn't get value at valueXPath: assignedTo/userId for datasource: Order- ignoring. Actual error: org.apache.commons.jxpath.JXPathNotFoundException: No value for xpath: assignedTo/userId
      I guess I could turn logging on the datasource off altogether but that would also mean that if something was genuinely wrong; I'd never find out.

      Comment


        #4
        Yeah, you definitely do not want to suppress all such logs. We'll look at whether we're also seeing a warning for this use case (which should definitely be considered normal).

        Comment


          #5
          Hi Isomorphic,

          I was wondering if there was any update on this issue? Would it help if I adapted one of the showcase examples to reproduce this error?

          Comment

          Working...
          X