bknights
Aug 19th, 2004, 01:58 PM
Hi,
I am wanting to have a form that has two submit buttons. One of them does the actual submit and one of them retrieves some data and populates a select object on the form. When I populate the select ojbject I want to preserve any entries already made on the form.
I'd have thought that the sessionForm parameter would be the way to do this.
e.g.
the servlet configuration:
<bean id="searchItemsController" class="web.SearchItemsFormController">
<property name="sessionForm"><value>true</value></property>
<property name="commandName"><value>searcher</value></property>
<property name="commandClass"><value>com.ledgerdemain.matrixeditor.MatrixItemSearcher</value></property>
<property name="formView"><value>searchTargetsForm</value></property>
<property name="successView"><value>searchTargetsForm</value></property>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
<prop key="*">searchItemsController</prop>
</props>
</property>
</bean>
the controller class:
public class SearchItemsFormController extends SimpleFormController {
/** Logger for this class and subclasses */
protected final Logger logger = Logger.getLogger(this.getClass().getName());
private MatrixItemSearcher searcher;
public ModelAndView onSubmit(Object command)
throws ServletException {
MatrixItemSearcher searcher = ((MatrixItemSearcher) command);
return new ModelAndView(new RedirectView(getSuccessView()));
}
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
MatrixItemSearcher searcher = new MatrixItemSearcher();
searcher.setSearchManagedItems(false);
searcher.setSearchLDMarkedItems(true);
searcher.setItemName("Fred");
return searcher;
}
Its success view just currently redirects back to itself.
In searching the Spring code I can't find anyplace where session.setAttribute is called on the object returned by the initial getFormBackingObject call.
I am wanting to have a form that has two submit buttons. One of them does the actual submit and one of them retrieves some data and populates a select object on the form. When I populate the select ojbject I want to preserve any entries already made on the form.
I'd have thought that the sessionForm parameter would be the way to do this.
e.g.
the servlet configuration:
<bean id="searchItemsController" class="web.SearchItemsFormController">
<property name="sessionForm"><value>true</value></property>
<property name="commandName"><value>searcher</value></property>
<property name="commandClass"><value>com.ledgerdemain.matrixeditor.MatrixItemSearcher</value></property>
<property name="formView"><value>searchTargetsForm</value></property>
<property name="successView"><value>searchTargetsForm</value></property>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
<prop key="*">searchItemsController</prop>
</props>
</property>
</bean>
the controller class:
public class SearchItemsFormController extends SimpleFormController {
/** Logger for this class and subclasses */
protected final Logger logger = Logger.getLogger(this.getClass().getName());
private MatrixItemSearcher searcher;
public ModelAndView onSubmit(Object command)
throws ServletException {
MatrixItemSearcher searcher = ((MatrixItemSearcher) command);
return new ModelAndView(new RedirectView(getSuccessView()));
}
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
MatrixItemSearcher searcher = new MatrixItemSearcher();
searcher.setSearchManagedItems(false);
searcher.setSearchLDMarkedItems(true);
searcher.setItemName("Fred");
return searcher;
}
Its success view just currently redirects back to itself.
In searching the Spring code I can't find anyplace where session.setAttribute is called on the object returned by the initial getFormBackingObject call.