Custom Tag with boolean Attribute problems
Hi,
I've created a simple custom tag that is expecting a boolean attribute called "disabled". In my Tag derived class I've created a setDisabled(boolean b) method and set the following in the tag descriptor:
<attribute>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
I'm using a JSTL expression "${someExpression}" which, when I do a c:out on the value, returns true.
I call the tag like this:
<mytag disabled="${someExpression}"/>
However, in my custom tag class the value is passed as false. I can get true passed in if I hard code it, but that isn't going to work.
I've tried a number of different combinations and even read through this forum for the last 2 hours and cannot seem to figure it out.
What am I doing wrong?
Thanks,
John
[960 byte] By [
jdubchaka] at [2007-10-3 3:29:36]

You are missing the TYPE of the attribute. It defaults to java.lang.String.
<attribute>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>boolean</type>
</attribute>
evnafets,
Thanks for the reply, however, it didn't seem to help. I've verified that the expression evaluates to true based on doing both a <c:out> on the value and wrapping everything up as a <c:choose> expression.
But, if I rely on the boolean being set on my custom tag the expression from above always evaluates to false, even if I hard code it using a <c:set>.
Any other ideas?
Thanks again.
TLD File, per your previous recommendation:
<attribute>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>boolean</type>
</attribute>
My Tag class (snippet):
public class ButtonTag extends TagSupport
{
private boolean disabled;
public ButtonTag() {}
public boolean isDisabled()
{
return disabled;
}
public void setDisabled(boolean b)
{
disabled = b;
}
}
A sample of the jsp file invoking it:
<c:set var="result" value="${computedValue}"/>
<ltm:button disabled="${result}"/>
Regardless of the value of result, ("true" or "false") it always passes false to the setDisabled method of the button tag class.
Well it works fine on my machine.
My diagnosis would be that EL is not enabled in your webpage, outside of the JSTL tags.
If you put ${1+1} on your page do you get ${1 + 1} or 2?
You do have a JSP2.0 container (eg Tomcat 5)
Using JSTL1.1?
If so try putting this at the top of your jsp:
<%@ page isELIgnored="false" %>
You will probably need to update your web.xml file to 2.4.
See my post about configuration issues here: [url http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0]reply #6[/url]
Cheers,
evnafets