Announcement

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

    valueXPath not substituting

    Hello,

    I've got a server DataSource with this field:
    Code:
    <field name="textTheText" title="cccText" type="siString" valueXPath="text/theText"/>
    The bean has got a field 'text' which is another bean which contains field 'theText' as normal String.
    All getters and setters, parameterless constructors are available.

    However, the field is not populated on the client. When I inspect the RPC Response, I see field "text" as such:
    Code:
    text:{
                        id:50005, 
                        theText:"We do this...", 
                        timeStamp:"2006-01-19 15:57:14.140"
                    },
    I don't see a member field "textTheText". Should it be there already in the response coming from server?



    I can make it work by manually setting the datapath to the same value of the valueXPath.
    Code:
    String valueXPath = field.getAttributeAsString("valueXPath");
    if (valueXPath != null) {
      field.setDataPath(valueXPath);
    }
    Is this normal? Do I really need to do this?
    (I can actually just setDataPath manually on the client without setting valueXPath in the DataSource.)



    We do have a custom backend. Do we maybe need to call a special function during fetch which will 'execute' this XPath mapping?


    SmartGWT EE 2.3 official release, development mode

    #2
    See the server-side API DataSource.getProperties() - this is what executes valueXPaths. You may have arranged code in such a way that this is never invoked, for example if you see manually calling DataToos.getProperties() (a different API that doesn't know about the DataSource definition) before dsResponse.setData()

    Comment


      #3
      Hi,
      You're right, I put some breakpoints in the DataSource.getProperties methods, but it never got hit. So I added it myself.

      * Note on previous post: Something that I just remarked: why is the "text" object visible in the RPC ? I didn't add it as a <Field> and I put dropExtraFields="true" on my <DataSource>.



      So I set my bean result to dsResponse.setData(results) (which actually is a List<beans>)

      When I did this:
      Code:
      Map map = dsRequest.getDataSource().getProperties(dsResponse.getData());
      I saw map contained "textTheText" but its value was empty.
      I added "text" then as
      Code:
      <field name="text" title="notReallyText" type="Object" hidden="true"/>
      in my DataSource definition, then the map contained the correct value for "textTheText"! Great!


      However, I still don't succeed in getting the value back to the client. The RPC doesn't mention the attribute.
      I tried with something silly as
      Code:
      dsResponse.setData(DataTools.setProperties(m, dsResponse.getData()))
      but I don't believe this could work as the objects in getData are my beans, which don't have a field "textTheText".

      Comment


        #4
        Sorry, these one-liner code samples don't really help solve the problem. We need to see the whole stretch of code involved in fulfilling the request.

        Comment

        Working...
        X