Eric,

What you are trying to do doesn't really require the JSTL expression
language. All you need to do is specify that runtime expressions are to be
evaluated for the "parameter" attribute of your custom tag in your TLD file.
If you were to look at any of the TLD files that come with Struts, you would
see plenty of examples of this. For example, here is the <html:base> tag TLD
definition that enables runtime expression evaluation for both the "target"
and the "server" optional attributes for the tag:

<tag>
  <name>base</name>
  <tagclass>org.apache.struts.taglib.html.BaseTag</tagclass>
  <bodycontent>empty</bodycontent>
  <attribute>
    <name>target</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue> <!-- This is what I think is needed! -->
  </attribute>
  <attribute>
    <name>server</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
  </attribute>
</tag>

Runtime expression evaluation is what allows you to evaluate Java
expressions inside of <%= ...%> for your custom tag parameters. If you use
the JSTL expression language (EL), you don't use the Java expression tag.
They are two separate ways to refer to dynamic content for custom tag
attributes. To use the JSTL EL, you have to build your custom tag such that
it has EL support in it. If you really want to go that route, I haven't done
that yet myself. So, I can't help you with that. However, you can look at
how the contributed taglib (html-el) that extends the HTML taglib of Struts
1.1 to add EL support for the parameters of the Struts HTML custom tags does
just that.

Also, your example used the <%= ...%> tag correctly for a custom tag
parameter. However, many people initially stumble on getting this to work
correctly even when runtime expression evaluation is enabled because they
try to define only part of the custome tag attribute with the tag. For it to
work even when properly enabled for the attribute in the TLD, you have to
define the entire contents of the custom tag attribute value to be the <%=
...%> Java expression. If there is static content you want to include as
part of the attribute value, you typically use string operations inside the
JSP expression to concatenate and build up the final attribute value merging
your dynamic and static data.

Hope this helps, Van

Mike Van Riper
Silicon Valley Struts User Group
mail: mike.vanriper at baychi.org
http://www.baychi.org/bof/struts/

> -----Original Message-----
> From: Eric SCHULTZ [mailto:[EMAIL PROTECTED]
> Sent: Friday, December 05, 2003 7:54 AM
> To: '[EMAIL PROTECTED]'
> Subject: RT expr value in custom tag
> 
> 
> Good morning...
> 
> I'm trying to write my own custom tag library for Struts.  
> I've had some
> initial success, but now I'm having some trouble.
> 
> I want to set an attribute value from the value of a bean 
> get.  But what I
> end up with in my tag is JSP code, not the value in the bean.
> 
> I.e.: 
> <v:properties template="inputmode" parameter="<%=
> UserSessionBean.getInputMode() %>"/>
> 
> is not translated.
> 
> How do I get the result of UserSessionBean.getInputMode() in 
> my tag?  Do I
> need to implement Expression Language?  Is there already a 
> utility class
> somewhere in Struts 1.1 that would evaluate something like
> ${UserSessionBean.inputMode} for me?
> 
> Thanks.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to