This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:setProperty body-content

 
Yoshita Jain
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the <body-content> of the <jsp:setProperty> tag? Don't remember reading anywhere that its empty.

I was also wondering if we could use a embeded tag to assign the the <jsp:setProperty> value....

Something like this:

<jsp:useBean id="person" type="foo.Person" class="foo.Employee">
<jsp:setProperty name="person" property="name" value="<myTag:test/>"/>
</jsp:useBean>

where <myTag:test/> returns a String value
[ October 21, 2007: Message edited by: Yoshita Jain ]
 
Lalit mishra
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For <jsp:setProperty> body content is empty
 
Yoshita Jain
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guess the embeded thing doesn't work

'dealerAddrBean' has been previously defined and its 'cityName' set to 'New Delhi'

<jsp:useBean id="dab" class="com.bean.DealerAddrBean">
<jsp:setProperty name="dab" property="dealerName" value='<bean:write name="dealerAddrBean" property="cityName"/>'/>
</jsp:useBean>

and then I did a ${dab.dealerName} it resulted in printing
<bean:write name="dealerAddrBean" property="cityName"/>
rather than 'New Delhi', which I was expecting.

However,the following worked and set the value correctly as

'New DelhiABCDEFG'

<jsp:useBean id="dab" class="com.bean.DealerAddrBean">
<jsp:setProperty name="dab" property="dealerName" >
<bean:write name="dealerAddrBean" property="cityName"/>ABCDEFG
</jsp:setProperty>
</jsp:useBean>
[ October 21, 2007: Message edited by: Yoshita Jain ]
 
Jan van Mansum
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:setProperty> must be empty, so

</jsp:setProperty name="beanName" property="propName">val</jsp:setPoperty>

or

</jsp:setProperty name="beanName" property="propName">
</jsp:setPoperty>

is wrong


Be careful not to confuse with <c:set> from the JSTL, which can have a body, e.g,

<c:set var="myVar">myValue</c:set>

is correct.
[ October 22, 2007: Message edited by: Jan van Mansum ]
 
Tarun Yadav
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, keep in mind that you can't 'nest' custom tags in the sense that while it's legal to have a tag as the body for another tag, you can't have a tag within another tag.

For example,


is fine but

is not ok.
 
Yoshita Jain
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all of you...

But I'm still puzzled coz as I said.. for me..this worked

<jsp:useBean id="dab" class="com.bean.DealerAddrBean">
<jsp:setProperty name="dab" property="dealerName" >
<bean:write name="dealerAddrBean" property="cityName"/>ABCDEFG
</jsp:setProperty>
</jsp:useBean>

and for ${dab.dealerName} it gave me the output 'New DelhiABCDEFG'

And yeah Tarun, 'nested' is incorrect for what I was referring to.. mebbe 'embeded makes more sense..and embeded tags are disallowed.

Thanks,

Yoshita
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic