mah01
Aug 14th, 2007, 06:13 PM
Hi
I have a jsp page named Reminders.jsp. That page is responsible for displaying a form for editing a reminder, and a list of all reminders. It also displays the header and footer.
I want the list of reminders to be filled when the page is first rendered so I import both the form and the list. This way their respective controllers will be called and their views displayed to the user.
Reminders.jsp
<%@ include file="IncludeTop.jsp" %>
<table align="center">
<tr><td>
<c:import url="/editReminder.htm" />
</td></tr>
<tr><td>
<c:import url="/listReminders.htm" />
</td></tr>
</table>
<%@ include file="IncludeBottom.jsp" %>
My configuration of the three controllers involved: /reminders.htm, /editReminder.htm and /listReminders.htm:
...
<bean name="/reminders.htm" class="com.tika.reminder.reminders.RemindersController" />
<bean name="/editReminder.htm" class="com.tika.reminder.reminders.EditReminderController">
constructor-arg><ref bean="reminderService"/></constructor-arg>
property name="sessionForm"><value>true</value></property>
property name="commandName"><value>reminder</value></property>
property name="commandClass"><value>com.tika.reminder.dao.Reminder</value></property>
property name="validator"><ref bean="reminderValidator"/></property>
property name="formView"><value>EditReminderForm</value></property>
property name="successView"><value>redirect:/reminders.htm</value></property>
property name="dateEditor"><ref bean="customDateEditor"/></property>
</bean>
<bean name="/listReminders.htm" class="com.tika.reminder.reminders.ListRemindersControlle r">
constructor-arg><ref bean="reminderService"/></constructor-arg>
</bean>
...
After logging on, the user is redirected to /reminders.htm (which just forward to Reminders.jsp). This will cause the page with the form and list to be rendered. This far all is well. But now I want to add a validator to the form.
As you can see in the config for "/editReminder.htm" the formView is a jsp page named EditReminderForm.jsp. When the validation fails, this page is displayed. The problem is that this is only halv of the page (the form). The list is not displayed. I would need Reminders.jsp to be displayed again with the command object bound. This way both the form and the list would be redisplayed to the user with suitable error messages.
Is there a way to solve this problem?
I don't want to have to split the page in two, having the form in one page and the list in another, even though that would solve the problem. Because then I could let both EditReminder.jsp and ListReminders.jsp include the header and footer. After logon I would redirect the user to the page with the list of reminders. Selecting one of the reminders would take him to the page with the form where he can modify it and save it (which would take him back to the page with the list again).
But as I said, I hope you guys can help me find another solution to my problem so that I don't have to do it that way.
Best regards,
Mattias
I have a jsp page named Reminders.jsp. That page is responsible for displaying a form for editing a reminder, and a list of all reminders. It also displays the header and footer.
I want the list of reminders to be filled when the page is first rendered so I import both the form and the list. This way their respective controllers will be called and their views displayed to the user.
Reminders.jsp
<%@ include file="IncludeTop.jsp" %>
<table align="center">
<tr><td>
<c:import url="/editReminder.htm" />
</td></tr>
<tr><td>
<c:import url="/listReminders.htm" />
</td></tr>
</table>
<%@ include file="IncludeBottom.jsp" %>
My configuration of the three controllers involved: /reminders.htm, /editReminder.htm and /listReminders.htm:
...
<bean name="/reminders.htm" class="com.tika.reminder.reminders.RemindersController" />
<bean name="/editReminder.htm" class="com.tika.reminder.reminders.EditReminderController">
constructor-arg><ref bean="reminderService"/></constructor-arg>
property name="sessionForm"><value>true</value></property>
property name="commandName"><value>reminder</value></property>
property name="commandClass"><value>com.tika.reminder.dao.Reminder</value></property>
property name="validator"><ref bean="reminderValidator"/></property>
property name="formView"><value>EditReminderForm</value></property>
property name="successView"><value>redirect:/reminders.htm</value></property>
property name="dateEditor"><ref bean="customDateEditor"/></property>
</bean>
<bean name="/listReminders.htm" class="com.tika.reminder.reminders.ListRemindersControlle r">
constructor-arg><ref bean="reminderService"/></constructor-arg>
</bean>
...
After logging on, the user is redirected to /reminders.htm (which just forward to Reminders.jsp). This will cause the page with the form and list to be rendered. This far all is well. But now I want to add a validator to the form.
As you can see in the config for "/editReminder.htm" the formView is a jsp page named EditReminderForm.jsp. When the validation fails, this page is displayed. The problem is that this is only halv of the page (the form). The list is not displayed. I would need Reminders.jsp to be displayed again with the command object bound. This way both the form and the list would be redisplayed to the user with suitable error messages.
Is there a way to solve this problem?
I don't want to have to split the page in two, having the form in one page and the list in another, even though that would solve the problem. Because then I could let both EditReminder.jsp and ListReminders.jsp include the header and footer. After logon I would redirect the user to the page with the list of reminders. Selecting one of the reminders would take him to the page with the form where he can modify it and save it (which would take him back to the page with the list again).
But as I said, I hope you guys can help me find another solution to my problem so that I don't have to do it that way.
Best regards,
Mattias