• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp:setProperty body-content

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For <jsp:setProperty> body content is empty
 
Yoshita Jain
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
She'll be back. I'm just gonna wait here. With this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic