inderjeet
Jun 6th, 2008, 01:12 AM
Hi All,
I have one JSP where I have a search criteria and a submit button. When I enter the search criteria and click on submit button, the request goes back and using the hibernate mappings, fetch the results back till the controller (controller extends from Simple Form Controller). I have printed the results fetched from controller in the logs. I am able to print those.
Now in controller I save that results list in a map and return the ModelAndView Object with 2 params, one is the new RedirectView(getSuccessView()) and the second one as hmProducts which is a hashmap containing the data. I redirect the control to the initial page where I want is to have the results displayed below the original search criteria fields. For that in JSP I have fetched the hashmap from request object and written the code for the display of its contents.
Currently what I get is the same search page again with no results being displayed. Am I doing something wrong?
Please help me. Code snippets from my code are below:
controller
public ModelAndView onSubmit(Object command) throws ServletException {
StProductMaster productMaster = (StProductMaster) command;
List lstProducts = enquiryBL.searchResults(productMaster);
for(int i=0; i<lstProducts.size();i++){
logger.debug(i+"-"+lstProducts.get(i));
}
HashMap hmProducts = new HashMap();
logger.debug("SIZE-"+lstProducts.size());
hmProducts.put("Products", lstProducts);
return new ModelAndView(new RedirectView(getSuccessView()), hmProducts);
}
jsp
<%
List alProducts = (ArrayList)request.getAttribute("Products");
out.print(alProducts);
if(alProducts != null && alProducts.size() > 0){
out.print(alProducts.size());
%>
<FIELDSET style="width:100%">
<LEGEND class="label2">
<fmt:message key="enquiry.products" />
</LEGEND>
<TABLE>
<%for(int i=0;i<alProducts.size();i++){
%>
<TR>
<TD class=label>
<%
StProductMaster product = (StProductMaster)alProducts.get(i);
%>
<%=product.getSfProductCode() %>
</TD>
</TR>
<%} %>
</TABLE>
</FIELDSET>
<%} %>
config-servlet.xml file
<bean name="/enquire.htm"
class="com.sis.rating.gprs.controller.EnquiryController">
<property name="sessionForm">
<value>true</value>
</property>
<property name="successView">
<value>enquire.htm</value>
</property>
<property name="commandName">
<value>ProductMaster</value>
</property>
<property name="commandClass"
value="com.sis.rating.gprs.dto.StProductMaster" />
<property name="formView">
<value>/misc/enquiry</value>
</property>
<property name="enquiryBL">
<ref bean="EnquiryBL" />
</property>
</bean>
Thanks & Regards
Inder Jeet Singh
I have one JSP where I have a search criteria and a submit button. When I enter the search criteria and click on submit button, the request goes back and using the hibernate mappings, fetch the results back till the controller (controller extends from Simple Form Controller). I have printed the results fetched from controller in the logs. I am able to print those.
Now in controller I save that results list in a map and return the ModelAndView Object with 2 params, one is the new RedirectView(getSuccessView()) and the second one as hmProducts which is a hashmap containing the data. I redirect the control to the initial page where I want is to have the results displayed below the original search criteria fields. For that in JSP I have fetched the hashmap from request object and written the code for the display of its contents.
Currently what I get is the same search page again with no results being displayed. Am I doing something wrong?
Please help me. Code snippets from my code are below:
controller
public ModelAndView onSubmit(Object command) throws ServletException {
StProductMaster productMaster = (StProductMaster) command;
List lstProducts = enquiryBL.searchResults(productMaster);
for(int i=0; i<lstProducts.size();i++){
logger.debug(i+"-"+lstProducts.get(i));
}
HashMap hmProducts = new HashMap();
logger.debug("SIZE-"+lstProducts.size());
hmProducts.put("Products", lstProducts);
return new ModelAndView(new RedirectView(getSuccessView()), hmProducts);
}
jsp
<%
List alProducts = (ArrayList)request.getAttribute("Products");
out.print(alProducts);
if(alProducts != null && alProducts.size() > 0){
out.print(alProducts.size());
%>
<FIELDSET style="width:100%">
<LEGEND class="label2">
<fmt:message key="enquiry.products" />
</LEGEND>
<TABLE>
<%for(int i=0;i<alProducts.size();i++){
%>
<TR>
<TD class=label>
<%
StProductMaster product = (StProductMaster)alProducts.get(i);
%>
<%=product.getSfProductCode() %>
</TD>
</TR>
<%} %>
</TABLE>
</FIELDSET>
<%} %>
config-servlet.xml file
<bean name="/enquire.htm"
class="com.sis.rating.gprs.controller.EnquiryController">
<property name="sessionForm">
<value>true</value>
</property>
<property name="successView">
<value>enquire.htm</value>
</property>
<property name="commandName">
<value>ProductMaster</value>
</property>
<property name="commandClass"
value="com.sis.rating.gprs.dto.StProductMaster" />
<property name="formView">
<value>/misc/enquiry</value>
</property>
<property name="enquiryBL">
<ref bean="EnquiryBL" />
</property>
</bean>
Thanks & Regards
Inder Jeet Singh