Potresti risolvere inserendo un attributo nel tag ad esempio:
Codice PHP:
<tag>
<name>select</name>
<tagclass>percorso.del.tuoPackage.SelectTag</tagclass>
<bodycontent>empty</bodycontent>
<info>Crea una select</info>
<attribute>
<name>nome</name>
<required>true</required>
</attribute>
<attribute>
<name>list</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
La tua classe Tag
Codice PHP:
public class SelectTag extends TagSupport {
//...
public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
out.println("<select name=\""+nome+"\" >");
if (list!=null){
Iterator it=list.iterator();
while(it.hasNext()){
Selectable s=(Selectable)it.next();
out.println("<option value=\""+s.getValueID()+"\">"+s.getValueName()+"</option>");
}
}
} catch (Exception e) {
e.printStackTrace();
}
return TagSupport.SKIP_BODY;
}
public int doEndTag(){
try {
JspWriter out = pageContext.getOut();
out.println("</select>");
} catch (Exception e){
e.printStackTrace();
}
return TagSupport.EVAL_PAGE;
}
}
public interface Selectable {
public String getValueName();
public String getValueID();
}
E infine la jsp:
Codice PHP:
<jsp:useBean id="tuoBean" scope="......." class="percorso.delPackage.TuoBean" />
<%@ taglib uri="/WEB-INF/selectTag.tld" prefix="st" %>
<html>
<head>
<title>Custom Tag</title>
</head>
<body>
<st:select nome="s" list="<%=tuoBean.getLista()%>"/></p>
</body>
</html>