You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rajesh Khater <ra...@wipro.com> on 2003/05/26 09:30:13 UTC
Setting nested properties
Hi,
If a texfield in my JSP is using value[1].value[2] as its property, then while displaying page, Struts will make a method call like this:
formbean.getValue(1).getValue(2).
While setting the value back in formbean, how will the method call look like ? Is it like :
formbean.getValue(1).setValue(2, "the value in the textfield");
That is, the setter method is called on the last element of a nested property. Upto the last element, only getters are called ??
I hope I am clear enough :)
Thanks,
Rajesh.
**************************Disclaimer************************************
Information contained in this E-MAIL being proprietary to Wipro Limited is
'privileged' and 'confidential' and intended for use only by the individual
or entity to which it is addressed. You are notified that any use, copying
or dissemination of the information contained in the E-MAIL in any manner
whatsoever is strictly prohibited.
***************************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: A Basic Q on action mapping
Posted by Nicolas De Loof <ni...@cgey.com>.
Lots of struts-config elements can use this "classname" attribute and <set-property> child elements. It allow you to use
an alternative class for configuration objects.
To give you a concrete example, if you want a mapping to have a "userAllowed" property, that will be a list of user that
are allowed to execute this action (in real lifge you shoul use "role" attribute for this).
You can extend ActionMapping to add a "userAllowed" javabean property and set your struts-config like this :
<action classname="MyActionMapping" path="...">
<set-porperty name="userAllowed" value="admin, manager"/>
</action>
Hope it will help you.
Nico.
HI,
when exactly we use this set-property in the action mapping and can anyone give a live example
<set-property property="" value=""/>
TIA
____________________________________________________
IncrediMail - Email has finally evolved - Click Here
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: A Basic Q on action mapping
Posted by Ted Husted <hu...@apache.org>.
Struts allows pluggable objects just about everywhere (maybe even
everywhere). When you extend an Action, ActionForward, and so forth, you
need a way to set the properties you've added. Plugging in a new DTD
would be a real headache. Alternatively, you can use <set-property> to
set any arbitrary public property on the underlying object.
The Validator and Tiles PlugIn both use <set-property> to populate
public fields regarding their configuration paths.
<
http://cvs.apache.org/viewcvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorPlugIn.java?rev=1.17&content-type=text/vnd.viewcvs-markup
>
<
http://cvs.apache.org/viewcvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesPlugin.java?rev=1.20&content-type=text/vnd.viewcvs-markup
>
-Ted.
Nagendra Kumar O V S wrote:
>
> HI,
> when exactly we use this set-property in the action mapping and can
> anyone give a live example
> <set-property property="" value=""/>
> TIA
>
> ____________________________________________________
> <http://www.incredimail.com/redir.asp?ad_id=309&lang=9> IncrediMail -
> Email has finally evolved - Click Here
> <http://www.incredimail.com/redir.asp?ad_id=309&lang=9>
--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
A Basic Q on action mapping
Posted by Nagendra Kumar O V S <na...@ikigo.com>.
HI,
when exactly we use this set-property in the action mapping and can anyone
give a live example
<set-property property="" value=""/>
TIA
Re: Setting nested properties
Posted by Ted Husted <hu...@apache.org>.
Yes. It's all getters, and then a setter at the end (since that is the
only value which changes).
Rajesh Khater wrote:
> Hi,
>
> If a texfield in my JSP is using value[1].value[2] as its property, then while displaying page, Struts will make a method call like this:
> formbean.getValue(1).getValue(2).
>
> While setting the value back in formbean, how will the method call look like ? Is it like :
>
> formbean.getValue(1).setValue(2, "the value in the textfield");
>
> That is, the setter method is called on the last element of a nested property. Upto the last element, only getters are called ??
>
> I hope I am clear enough :)
>
> Thanks,
> Rajesh.
--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org