aspose file tools
The moose likes JSP and the fly likes Tag question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Tag question" Watch "Tag question" New topic
Author

Tag question

zamies banno
Greenhorn

Joined: Jun 17, 2004
Posts: 3
Hi you all,

I encountered an example of a custom tag and deployment of that tag which raised a question. The example is as follows:

A custom tag implementing the Tag interface.

public class ifTag implements Tag
{
private boolean condition;
public void setCondition(boolean condition)
{
this.condition = condition;
}
public int doStartTag() throws JspException
{
if (condition)
....something
else
...something else
}
...all other methods
....
}

Now if I deploy this custom tag in a TLD as follows:
<tag>
...name
... etc
<attribute>
.....
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

Isn't this wrong? Shouldn't you get an compile time error because of mismatching types? No type means default java.lang.String type? I mean aren't you supposed to declare the type of the attribute as being boolean?
And what if you declare the following in the TLD:

<attribute>
...
<rtexprvalue>true</rtexprvalue>
<type>boolean</type>
</attribute>

Does that means you can't use a request parameter as the trexprvalue for this custom tag directly, because you'll have to convert it from String to boolean first?

well any help appreciated (on this subject that is).

grtsBanno
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
no specific type means the type is determined at runtime.


42
zamies banno
Greenhorn

Joined: Jun 17, 2004
Posts: 3
This would mean that the servlet container takes care of it?
Like with the implicit conversion in setProperty() with JavaBeans?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Tag question
 
Similar Threads
tags as other tags' attribute value
Problem while Tag lib Up gradation
String[] as attribute to custom tag
custom tag and getAttribute
Programming HTML content inside Custom Tag Handler