Hi ,
May be this is a newbie question.
There is a SearchProductsController which implement interface Controller in jpetstore . (most of the time the interface Controller use to do search action)
The SearchProductsController in jpetstore return a ModelAndView.
The above "SearchProducts" is a view that hardcode in the controller ,if we don't want hardcode it , we can add a property successView in the class , and get/set it , then use IOC to inject the view "SearchProducts"Code:public ModelAndView handleRequest(..){ ... return new ModelAndView("SearchProducts", "productList", productList); }
into the SearchProductsController in petstore-servlet.xml.
Since SearchProductsController in jpetstore just return SAME successView for each jsp pages , but in my imagination scenario , SearchProductsController can be reuse in many jsp pages to display products , it may need DIFFERENT successView.
Let's consider the folowing scenario , l have two views , View1.jsp and View2.jsp .
View1.jsp -- have two forms .
form1 use SimpleformController to add something to DB.
form2 use SearchProductsController to search products . After a success search , it will back to View1.jsp and display products.
View2.jsp -- have two forms also.
form3 use SimpleformController to edit something to DB.
form4 use SearchProductsController to search products . After a success search , it will back to View2.jsp and display products.
both REUSE the SAME SearchProductsController to display products in the SAME pages.
If the description above OK , then l first came to the code bellow ,
Then my question is , if l want to REUSE SearchProductsController in N jsp pages , then l have to write above code N times ? initialize MULTI SearchProductsController instances ?Code:<bean id="searchProductsControllerForView1" class="com.amazon.web.SearchProductsController"> <property name="store"><ref bean="store"/></property> <property name="successView"><value>View1</value></property> </bean> <bean id="searchProductsControllerForView2" class="com.amazon.web.SearchProductsController"> <property name="store"><ref bean="store"/></property> <property name="successView"><value>View2</value></property> </bean>
Or
Make a "just in time SuccesssView" from View1.jsp/View2.jsp using request's parameter to "inject" a successView into view's SearchProductsController , it seen a lot security problem here ??
Any thought ?



Reply With Quote