Hi All,
I have create a custom tag to translate texts. I have to pass 3 parameters to this tag. As the parameter values are on static. I have to pass runtime expression as parameter values.I have tried various ways for this, but did not suceed. Please let me know how to achieve this.
My TLD file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>html</shortname>
<tag>
<name>translate</name>
<tagclass>TranslateTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>key</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>arg0</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>arg1</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>arg2</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>arg3</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>arg4</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>isHTML</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
My Tag handler class:
I have getter setters for arguments here
public void release() {
super.release();
args = null;
key = null;
lang = null;
}
public int doStartTag() throws JspException {
//Some processing code is written here
// Continue processing this page
return (SKIP_BODY);
}
Now I am calling this tag from a JSP file :
<itc:translate key="access" arg0="<%=itemName%>" arg1 = "<%=itemIndex%>" arg2 = <%=numOfItems%> />
Here itemName ,itemIndex and numOfItems are three variables .I want to pass variable values as parameters.But I am getting whole string "<%=itemName%>" as parameter valuse. i even tried simply with itemName an "itemName". But i did not get the variable value .
Can anyone help me here.
Thanks,