I have an index.jsp, which optionally <%@ include %>s two fragments: one is a login form (connected to a LoginForm action form bean), the other a list of items.

The login form is only included if there is no "user" bean in the session scope (determined via <logic:present> tags). The other fragment is always included, but if the user is logged in, each item has a form associated with it.

I have an action (FrontPageAction, frontPage.do) which puts an ArrayList of Foo objects in the request scope, then forwards to the index.jsp. Easier to explain with a code snippet... "foos" is a request scoped ArrayList of Foo objects (which has legLength and fooID properties):

<logic:iterate id="element" name="foo">
<p><bean:write name="element" property="legLength"/></p>
<logic:present name="user" scope="session">
<html:form action="/rateFoo">
<input type="hidden"
name="fooID"
value="<%=((Foo)element).getFooID()%>"/>
<html:radio property="rating" value="1"/>
<html:radio property="rating" value="2"/>
<html:radio property="rating" value="3"/>
<html:submit value="Rate!"/>
</html:form>
</logic:present>
<logic:iterate/>

So, with nobody logged in, hitting frontPage.do displays the front page correctly. I get my list of Foo objects (with no rating forms) and my login form. I log in, and the last thing my LoginAction does is forward back to frontPage.do. The login box is no longer displayed, and the rating forms should be, but it breaks because the LoginForm bean is still there, instead of a RatingForm!

So I get a stack trace, complaining that org.apache.struts.taglib.html.BEAN doesn't have a "rating" property. But if I then type "frontPage.do" into my address bar, everything works as expected!

So my questions are:

1. Is this a good design? Am I allowed to have multiple different forms on the one page, or should I have a seperate "guestIndex.jsp" and "memberIndex.jsp"?

2. Am I allowed to have many of the *same* form on the one page, distinguishing which element is having its form submitted by looking at a hidden property? Or should I go about this differently, using javascript tricks (I'd prefer to avoid this if possible).

3. Should I need to remove anything from the request scope at the end of my LoginAction, and if so, what?

Cheers, Robert.


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to