My apologies. For a Collection of objects, one must state which members of the object in the list to include. For example, to retrieve every attribute of the Product object:
products.*, productsTotal ...and one can select which attributes to include like so: products.name, products.description, productsTotal Credit goes to my colleague for figuring this out :) Hope this helps others. Cheers, James Gadbury wrote: > > Hi all, > > Does anyone have a solution to this? I have exactly the same problem. > For example: > > <action name="ProductAction_*" method="{1}" > class="jp1980.actions.ProductAction"> > <result > name="list">/customer/products/list_ext.jsp</result> > <result name="json_list" type="json"> > products, productsTotal > </result> > <result name="error">/error.jsp</result> > <result name="success">/missing.jsp</result> > </action> > > products is a List. If I specify products as the root, or specify no root > or includeParams and return everything from my action, products is > returned and populated fine in the JSON. However, if i use the > includeParams as above, products is empty when I inspect the JSON. > > Thanks for reading and kind regards, > > James > > > Gregory Slonim wrote: >> >> All, >> >> I am having a problem returning collections (or arrays) from struts >> action as JSON. All collection-type data comes back empty (map, array, >> etc). >> >> Setup: >> >> struts.xml >> >> <package name="json" extends="json-default"> >> <action name="getPayPlanGradesAjaxCall" >> class="com.intellidyne.rms.action.accession.AccessionAction" >> method="getPayPlanGradesAjaxCall"> >> <interceptor-ref name="json"> >> true >> </interceptor-ref> >> >> <result type="json"> >> true >> >> dutyHours, >> payPlanTypes >> >> >> </result> >> </action> >> </package >> >> Action: >> >> public class AccessionAction extends BaseAction implements >> ConversationScopeAware, ValidationAware >> { >> private static final long serialVersionUID = -1249579868850221888L; >> >> private String dutyHours; >> private List<String> payPlanTypes; >> >> public String getDutyHours() >> { >> return dutyHours; >> } >> >> public void setDutyHours(String dutyHours) >> { >> this.dutyHours = dutyHours; >> } >> >> public final List<String> getPayPlanTypes() >> { >> return payPlanTypes; >> } >> >> public final void setPayPlanTypes(List<String> payPlanTypes) >> { >> this.payPlanTypes = payPlanTypes; >> } >> >> public String getPayPlanGradesAjaxCall() >> { >> dutyHours="12345"; >> payPlanTypes = new ArrayList<String>(); >> payPlanTypes.add("TEST1"); >> payPlanTypes.add("TEST2"); >> return SUCCESS; >> } >> } >> >> JSP: >> >> ...... >> >> <button dojoType="dijit.form.Button" >> label="TEST" >> value="Test"> >> <script type="dojo/method" event="onClick"> >> console.debug("Getting JSON DATA"); >> dojo.xhrGet ({ >> url: "getPayPlanGradesAjaxCall.html", >> handleAs: "json", >> load: function(response, ioArgs) { >> console.debug("Returned from the call. Response >> is >> "+response.dutyHours); >> console.debug("Returned content: >> "+response.payPlanTypes); >> return response; >> } >> }); >> </script> >> </button> >> >> The button does not do anything besides making AJAX call. Here is the >> response in FF Fbug: >> >> {"dutyHours":"12345","payPlanTypes":[]} >> >> Even if I use various dojo methods (such as dojo.toJson, etc) on >> response object, the collection is still empty. >> I used arrays, maps, whatever. It is still empty. >> >> The main problem I am trying to solve is how to populate one select >> from something selected in another. (typical car makes/models scenario) >> >> Please advise, your help is greatly appreciated. >> >> Greg >> >> >> >> > > -- View this message in context: http://www.nabble.com/JSON-plugin-0.33-and-Struts-2.1.6-%28integrated-with-Spring-2.5%29-tp22463902p25189224.html Sent from the Struts - Dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org For additional commands, e-mail: dev-h...@struts.apache.org