Struts mapping actions September 21, 2006
Posted by javafoo in javanotes, struts basic.trackback
In this latest project of mine I was thinking about the various ways to map struts actions. I had done this, a couple of different ways and was wondering if there was a classification out there. And sure enough someone had already done this and instead of paraphrasing, I will just provide the link, here at TSS. Another thing/caveat about using named form-beans accross actions For ex, in your struts-config.xml, if you have a form-bean:
<form-bean name=”xyzForm” type=”package.web.XYZForm” />
and you want to use the same form accross two actions:
<action path=”/processAction” type=”package.web.action.ProcessAction”
parameter=”process”
name=”xyzForm” validate=”true”…..
<action path=”/displayAction” type=”package.web.action.DisplayAction”
parameter=”display”
name=”xyzForm” validate=”false”….
Notice here, I am using the same named form-bean for two actions, in the display action I don’t want to validate the form, but in the process action I want to validate the form. In this case I was in for a surprise, the validate=”true” wasn’t working for the process action. This is because the form params are set only once per form-bean. To overcome this, define two different named form-beans of the same type or if you still want to reuse the form-bean, set validate to true for both actions and within the validate method, based on a parameter decide if you want to validate or not.
Default Struts mapping action to action???
greetings. I want to go from a logon page to an action page that
decides whether the user gets an edit page, or a new page with blank
fields.
..jsp
form action=”/ResponseInit” method=”get”
struts-config.xml
=======
In the action execute i will check the DB for logon and password, and
then foward to an Edit register page.
But, i seem to get fowarded to my page with nothing in the fields.
What do I do?
How do I do it?
Is there a good example of this. The one built into the struts
downloade example 1.2.7 was a bit confusing.