AW: actionforms and validate()
"Bernhard Woehrlin" <[email protected]>
| Newsgroups | gmane.comp.java.strutscx.user |
|---|---|
| Organization | IT.CappuccinoNet.com |
| Message-ID | <000201c3bb79$9996f530$4b01a8c0@javaws> |
Hi Kiryl,
I figured out how to make the invocation of the validate() method in
your Action unnecessary!
Here an example you can try yourself - it builds on the latest
strutscx-demo.war
1. InfoUpdateAction: Pull out the EDIT code in a separate Action and
call it i.e. InfoEditAction. Uncomment the error check section inside
the InfoUpdateAction.
2. struts-config.xml: Make sure there are action elements for the
InfoEdit and one for the InfoUpdateAction - like this:
<action path="/infoedit"
type="com.cappuccinonet.strutscx.sample01.presentation.action.InfoEditAc
tion"
scope="request"
unknown="false"
name="infoForm"
validate="false">
<forward name="success" path="/StrutsCXServlet" redirect="false"
/>
</action>
<action path="/infoupdate"
type="com.cappuccinonet.strutscx.sample01.presentation.action.InfoUpdate
Action"
scope="request"
unknown="false"
name="infoForm"
validate="true"
input="/infoedit.do">
<forward name="success" path="/infosingle.do" redirect="false" />
<forward name="error" path="/StrutsCXServlet" redirect="false" />
<forward name="filledForm" path="/StrutsCXServlet"
redirect="false" />
</action>
Note: Take care on the the attribute settings. In case of an error at
/infoupdate the Request gets forwarded to the /infoedit. Struts
automatically puts the ActionErrors container to the request. StrutsCX
serializes all ActionErrors object into the XML-Output-Document (since
v0.9.4) - If you do prefer to error check inside the InfoUpdateAction
set validate=false
3. info_retrievesingle.xsl: Make sure the edit button points to the
/infoedit.do and not any longer to the infoupdate.do
There is a slight difference in the result while error-check inside the
Action or setting the attributes in the struts-config.xml. It's because
with the latter the execute() method of the Action does not get invoced,
the datasource won't get updated in case of errors.
However, please check this out and let me know what you think about it.
Regards,
Berny
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von
Bernhard Woehrlin
Gesendet: Freitag, 5. Dezember 2003 12:35
An: 'Navyshny, Kiryl'; [email protected]
Betreff: AW: [Strutscx-user] actionforms and validate()
Hi Kiryl,
I agree on that. - The invocation von the validate() method is necessary
to copy the ActionErrors container to the HttpServletReqeust. There
should be a way to automate this process... - hints appreciated...
Regards,
Berny
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von
Navyshny, Kiryl
Gesendet: Freitag, 5. Dezember 2003 11:37
An: '[email protected]'
Betreff: [Strutscx-user] actionforms and validate()
Hi all,
I found, that
validate="true" for form bean in struts-config.xml
and form description in validation.xml
is not enough to provide validation process.
You need to execute formBean.validate(),
how it is in StrutsCX example:
com.cappuccinonet.strutscx.prototype.presentation.action.InfoUpdateActio
n.
Why it is necessary to invoke direct validate() function of ActionForm
in
Action class ?
I suppose it is possibly to make such action direct after initialize
of form beans. It is better from my point of view to include such thing
in StrutsCX core. Isn't it.
Thank you.
Best regards/Mit freundlichen Grüßen.
Kiryl Navyshny
Software Entwickler
Deutsche Automobil Treuhand GmbH
Helmuth-Hirth-Str 1.
73760 Ostfildern-Scharnhausen
Phone: +49 (0)711 / 4503 141
mailto:[email protected]
http://www.dat.de
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for
IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys
admin.
Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=ick
_______________________________________________
Strutscx-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strutscx-user
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for
IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys
admin.
Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=ick
_______________________________________________
Strutscx-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strutscx-user
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click