Results 1 to 8 of 8

Thread: XTemplate and null bean properties

  1. #1
    Sencha User
    Join Date
    Apr 2014
    Posts
    3

    Default XTemplate and null bean properties

    What's the right way to handle null bean properties in a GXT XTemplate?


    Assume for example, I have a bean 'trucker' with some string properties, say 'remitToCity' and an XTemplate that looks like this:


    Code:
    "City: {remitToCity}"
    I would have thought that if the 'remitToCity' bean property is null, I would just get "City: " as an output result. Instead, I get an exception in dev mode. Partial stack trace below:


    Code:
    Caused by: java.lang.NullPointerException: null
    at com.google.gwt.safehtml.shared.SafeHtmlUtils.htmlEscape(SafeHtmlUtils.java:156)
    at com.exworks.client.TruckerGrid_RemitToTemplate_remitToAddress_SafeHtml__TruckerDto_truckerDto___SafeHtmlTemplatesImpl.remitToAddress4(TruckerGrid_RemitToTemplateremitToAddress_SafeHtml__TruckerDto_truckerDto___SafeHtmlTemplatesImpl.java:39)
    at com.exworks.client.TruckerGrid_RemitToTemplateImpl.remitToAddress(TruckerGrid_RemitToTemplateImpl.java:102)
    at com.exworks.client.TruckerGrid$addressCell.render(TruckerGrid.java:61)
    at com.exworks.client.TruckerGrid$addressCell.render(TruckerGrid.java:1)
    at com.sencha.gxt.widget.core.client.grid.GridView.getRenderedValue(GridView.java:1765)
    ...
    I thought maybe I could just check for null in the template, i.e.


    Code:
    "City: <tpl if="remitToCity == null">Not Available</tpl><tpl if="remitToCity != null">{remitToCity}</tpl>"
    But that always prints "City: " , even when the property contains a non-null value.


    I must be missing some obvious concept, but what?

  2. #2
    Sencha User
    Join Date
    Dec 2014
    Posts
    1

    Default

    Hey, I have the same problem...

    I use GXT 3.1...

    Did you already solve it? Or is someone else able to help?
    What is the correct syntax to handle possible null-values in a template?

  3. #3
    Sencha Premium Member
    Join Date
    Jan 2011
    Posts
    7

    Default

    I have the same problem. Any feedback would be great

  4. #4
    Sencha User
    Join Date
    Jan 2015
    Posts
    29

    Default

    I encountered the same issue. Did you solve it?

  5. #5
    Sencha Sr Product Manager
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    1,167

    Default

    This should work, I'm investigating.

  6. #6
    Sencha User
    Join Date
    Jan 2015
    Posts
    29

    Default

    Unfortunately it is not working. In that case, can you report a bug?

  7. #7
    Sencha Sr Product Manager
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    1,167

    Default

    Could you provide a test case that I could test locally? I wasn't able to replicate the issue. If I can replicate the issue, I we can fix it.

  8. #8
    Ext GWT Premium Member
    Join Date
    Oct 2010
    Posts
    193

    Default

    You are missing the values attribute, Please try

    Code:
    "City: <tpl if="values.remitToCity == null">Not Available</tpl><tpl if="values.remitToCity != null">{remitToCity}</tpl>"
    This used to work for me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •