struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Durham <ddur...@vailsys.com>
Subject Re: Mapping between a request parameter name and a Struts form property name
Date Tue, 05 Sep 2006 23:45:08 GMT
David Friedman wrote:
> You jogged my memory and I have a solution from the Appendix of "Struts In
> Action."  Version 1.1 and onward (possibly even in 1.0), struts
> ActionMappings have had two attributes: "prefix" and "suffix." The are from
> the ActionConfig class but carry over to the ActionMapping class used by the
> Struts-Config.xml. Their use would be (you probably shouldn't mix them as in
> this stupid example):
> 
> <action ....
> 	name="someForm"
> 	prefix="..."
> 	suffix="..."
> 	/>
> </action>
> 
> The JavaDocs from the ActionConfig class (ActionMapping extends it) are:
> 
> Prefix used to match request parameter names to form bean property names, if
> any.
> Suffix used to match request parameter names to form bean property names, if
> any.
> 
> So how/why would you use it?  Do you plan on having a wizard where some
> field names are the same on different pages?  That way page 1 variables
> could be oneId, oneTextField, etc. then page two could be
> twoId, twoUsername, twoPassword, and page3 could be threeId,
> threeShippingAddr1, etc. all within the same ActionForm/Pojo?  If that is
> the case I guess it could make wizards easier and avoid variable collision.

That's an interesting feature.  I missed that while looking at the 
RequestUtils.populate method, skipping straight to BeanUtils.populate. 
 From the source, it looks like request parameters are skipped 
altogether if their prefix and suffix do not match a specified config 
(if one exists), so you can't pick and choose which parameters will have 
a prefix and suffix.  All or nothing option.


-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message