Sunday, 8 September 2013

Unable to get object from Controller to JSP

Unable to get object from Controller to JSP

I am trying to pass an object from Spring Controller to my JSP page and
plan to iterate the object in JSP using JSTL. But I am unable to print the
object in JSP. From the controller side, the value is sent successfully. I
am thinking something is wrong in Javascript or JSP.
Request your valuable inputs. Pls find the code below,
Controller :
@RequestMapping("/changehistory/getSearchHistory.htm") public ModelAndView
getSearchHistory(@ModelAttribute(HISTORY_CRITERIA) HistoryCriteria
historyCriteria,ModelMap model) { ModelAndView mav = new
ModelAndView("changehistory/changeHistory_new"); List result=new
ArrayList();
result=changeHistoryService.getHistory(historyCriteria);
mav.addObject("historyCriteriaResult", result); return mav; }
JSP:
<div class="ItemListNavBoxLeft" style="margin-top: -2px; padding-left: 20px;"
id="accordianRefreshBtn">
<div class="OrangeFB" style="width: auto; " onclick="RP.getSearchHistory()">
<div class="Q2"><div class="Q8"><div class="Q4"><div class="Q6"><div
class="Q1"><div
class="Q3"><div class="Q7"><div class="Q9"><div class="Q5">
&nbsp;<spring:message
code='label.button.history'/>&nbsp;
</div></div></div></div></div></div></div></div></div>
</div>
</div>
<div id="changeHistorydiv" style="display:<c:choose><c:when
test='${fn:length(historyCriteriaResult) > }'>block</c:when>
<c:otherwise>none</c:otherwise></c:choose>;">
<ul class="FormBody" style="padding-left:150px;">
<li class="FormFieldTitle"></li>
id="RP.changeHist"
name="changeHist">
<c:forEach items="${historyCriteriaResult}"
var="HCList">
${HCList.code}
${HCList.name}
</c:forEach>
</ul>
</div>
JS :
RP.getSearchHistory = function() {
dojo.xhrPost({
url : "/RMT/rateplan/getSearchHistory.htm?",
timeout : 100000,
load : function(content) {
var iList = content['result'], i;
HCList.options.length = 0;
for (i = 0; i < iList.length; i++) {
HCList.options[HCList.options.length] = new
Option(iList[i].name, iList[i].code);
}
},
error : function(error) {
rmt.ErrorMessage.show(error);
}
});
}

No comments:

Post a Comment