• 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

nesting the bean:write tag

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi I want to nest the <bean:write tag into any other html tag

i.e.

<html:hidden property="color" value="<bean:write name="colorSet" property="colorValue" />"/>


Could you tell me if I am missing any quotes or something ?

Thanks
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,
I thought you couldn't nest tags. The tags get evaluated in a single pass.
 
mark anthony
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so ,
what if I need to write a value that comes from a bean into a html tag?
Do I need to use scriplets?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the standard struts tags, your only option is to use scriptlets instead of nesting tags.


However, in cases like this, I prefer to use the struts-el version of the tags. They allow you to embed EL expressions in the tags.

Using your example, the code would be:

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html-el" %>

<html-el:hidden property="color" value="${colorSet.colorValue}"/>

Just remember to include the struts-el.jar file in your classpath.
[ December 18, 2005: Message edited by: Merrill Higginson ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One other fact about html:xxx tags that's not very well documented is that if you supply a body for the tag, it is used as if you had coded a value attribute for that tag.

So, in the example you gave, the following would work:

<html:hidden property="color"><bean:write name="colorSet" property="colorValue" /></html:hidden>
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>One other fact about html:xxx tags that's not very well documented is that
>if you supply a body for the tag, it is used as if you had coded a value
>attribute for that tag.
Unfortunately it doesn't work for the html:hidden tag.
The tld specifies that it can't have a body.


I would say the best approach here is to populate your ActionForm in the Action used to load the page.
ie in java code:

form.setColor(colorSet.getColorValue());

Then when you forward to your jsp page with just

<html:hidden property="color">
It is automagically populated for you.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alternately:



should work.
 
reply
    Bookmark Topic Watch Topic
  • New Topic