Question

I am calling an Action, it returns json as a result in JSP page. My problem is, how to set this json result to my datepickers name varaible. My code is like that.

<s:url id="datePickerUrl" action="jsonReloadDatePickerAction" />
<sj:div href="%{datePickerUrl}">
     <sj:datepicker id="idStartDate" name="startDate" displayFormat="dd-mm-yy" showOn="focus"/>
     <sj:datepicker id="idEndDate" name="endDate" displayFormat="dd-mm-yy" showOn="focus" />
</sj:div>

And struts.xml code is -

<action name="jsonReloadDatePickerAction"  class="com.ebhasin.fitnessbliss.actions.GraphsAction" method="reloadDatePicker">
     <result   type="json" name="success">
        <param name="includeProperties">startDate,endDate</param>
     </result>
</action>

I am getting this on JSP page.

{"endDate":"18-11-2012","startDate":"07-12-2012"}
Was it helpful?

Solution

Put your datepicker-s to JSP page (e.g. dates.jsp) and change your action to return this page instead of json result.

<action name="jsonReloadDatePickerAction" class="com.ebhasin.fitnessbliss.actions.GraphsAction" method="reloadDatePicker">
  <result>path_to_your_dates.jsp</result>
</action>

Of course you need to have getters/setters for startDate and endDate in your GraphsAction action.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top