Hi,
my jsp is dynamically populated/displayed Indeed :
Code:
<html>
<%-- .............................. --%>
<c:forEach items="${Item}" var="item">
<center>
<<c:out value="${item.html}"escapeXml="false"/>>
</center>
</c:forEach>
</form>
</body>
</html>
here my actual controller:
Code:
public class GenericFormController extends SimpleFormController {
public ModelAndView onSubmit(Object command)
throws ServletException {
return new ModelAndView(new RedirectView(getSuccessView()));
}
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
Test test = new Test();
/*...........*/
return test;
}
and my xml:
Code:
<bean id="test" class="bean.Test"/>
<bean id="testVal" class="validator.TestVal">
<property name="test">
<ref bean="test"/>
</property>
</bean>
<bean id="genericFormController" class="web.GenericFormController">
<property name="sessionForm"><value>true</value></property>
<property name="commandName"><value>bean</value></property>
<property name="commandClass"><value>bean.Test</value></property>
<property name="validator"><ref bean="testVal"/></property>
<property name="formView"><value>test</value></property>
<property name="successView"><value>done.html</value></property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="test.html">genericFormController</prop>
<prop key="done.html">sqlController</prop>
</props>
</property>
</bean>
Without a validator I just used to use a Controller to connect to the data base, put the information into a Object's List than display the jsp:
Code:
public class GenericController extends AbstractController
{
DataSource dataSource;
HashMap<String, Object> map;
public GenericController()
{
}
public void setDataSource(DataSource dataSource){
this.dataSource = dataSource;
}
public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse httpServletResponse) throws Exception
{
map = new HashMap<String, Object>();
PageQuery pq = new PageQuery(dataSource);
Page p = pq.runQuery(1);
map.put("Page",p);
ItemQuery iq = new ItemQuery(dataSource);
ArrayList items = iq.runQuery(1);
map.put("Item",items);
return new ModelAndView("test", map);
}
}
Right now, I catch test.html which launches 'genericFormController', validator and the formView (test.jsp) is displayed, but I have a blank page.
So, I think you better understood that I would like to add a step to populate dynamically my test.jsp via one other Controller before being displayed.
I tried to create a such Controller, but the xml file doesn't like me to assign something else than:
Code:
<property name="formView"><value>test</value></property>
<!-- 'test' here is test.jsp -->
I tried to set the bean of the new Controller (which populate AND Display the jsp) as a value of "formView" but I got an error.
Thanks for your help.