1 Reply Latest reply on Mar 26, 2013 7:53 PM by overattribution

    Is it possible to share data between a Struts action class and a SOY template in JIVE 5.0.3?

    ranadeep

      I have made the example How to: Add a Tab to a Place  to run successfully on my JIVE instance. Now, I would like to set a property of type java.util.List in the action class (say, List<Customer> custList) with the GETTER method specified as well (i.e. getCustList() in the action class). By the way, Customer is a simple JAVA bean.

      Now, I am trying to access the "custList" property on the SOY template file (mentioned in the said example) as -

       

      {foreach $cust in $custList}

       

           {$cust.name}

       

           {ifempty}

                No customers found.

      {/foreach}

      But I am getting exception on the server side -

       

      com.jivesoftware.community.web.soy.SoyResult - Render error:

       

      com.google.template.soy.tofu.SoyTofuException: In 'foreach' command {foreach $cust in $custList}{$cust.name}{ifempty}No customers found.{/foreach}, the data reference does not resolve to a SoyListData.

       

      Can anyone advise on what is wrong here?

       

      Thanks in advance.

       

        • Re: Is it possible to share data between a Struts action class and a SOY template in JIVE 5.0.3?
          overattribution

          Sounds to me like your result isn't using the specified "soy" type.

           

          Take a look at Jive's struts-community.xml.  In it you'll find:

          <result-types>

             ...

              <result-type name="soy" class="com.jivesoftware.community.web.soy.SoyResult"/>

          </result-types>

           

           

          Now take a look at com.jivesoftware.community.web.soy.SoyResult.  SoyResult is expecting the action class to extend SoyModelDriven.

           

          Is your struts action is defined correctly?

          <result name="input" type="soy">{templateName}</result>

           

          Is your action class implementing SoyModelDriven?  Are you adding your "custList" object to the model returned in this method?