Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tag question  RSS feed

 
zamies banno
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no specific type means the type is determined at runtime.
 
zamies banno
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This would mean that the servlet container takes care of it?
Like with the implicit conversion in setProperty() with JavaBeans?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!