I m passing multiple attributes in my custom tag like
< mytag Firstname="Thadeus" Lastname="Jones" >
Then how would I access the individual attributes in the TagHandler class..
Kindly specify any suggestions..
Regards, Vinayak
I m passing multiple attributes in my custom tag like
< mytag Firstname="Thadeus" Lastname="Jones" >
Then how would I access the individual attributes in the TagHandler class..
Kindly specify any suggestions..
Regards, Vinayak
Hi,
Not really the answer to what you asked, but I hate (ie have never written) TagHandler's but I love tag files. Lets you write custom tags using jsp files. You probably know about them and are not available/applicable - but thought I'd mention them just in case.
In order to access the parameters your TagHandler class should define the private members and provide accessor methods.
public class TagHandler extends TagSupport {
private String firstName;
private String lastName;
public void setFirstName(String firstname) { firstName = firstname; }
public void setLastName(String lastname) { lastName = lastname;}
}
you can then access the parameters through the TagHandler variables.
public int doStartTag() throws JspException {
pageContext.getOut().print(lastName + ", " + firstName);
}
If you still have problems double check your naming conventions, the Java interpeter is trying to guess what the setter method is. So if your parameter is "FirstName" than the set method must be "setFirstName" if the parameter is "lastname" the set parameter must be "setlastname". I perfer to follow the former, since it is the standard Java naming convention.