Dovrai crearti la tua classe Tag simile a questa che ho creato e che ti mostro :
Codice PHP:
public class ForEachReverseTag extends BodyTagSupport {
static final long serialVersionUID = 4230004230004230001L;
private int begin = 0;
private int end = 0;
private static final Logger _LOGGER = Logger.getLogger( "ipi.portal.search" );
public void setBegin (String begin){
try{
this.begin = Integer.parseInt((String)ExpressionEvaluatorManager.evaluate("begin", begin,
String.class, this, pageContext));
}catch(JspException ex){
_LOGGER.error("JspException : ", ex);
}
}
public void setEnd (String end) {
try{
this.end = Integer.parseInt((String)ExpressionEvaluatorManager.evaluate("end", end,
String.class, this, pageContext));
}catch(JspException ex){
_LOGGER.error("JspException : ", ex);
}
}
public void doInitBody() throws JspException{
if(this.end <= this.begin) {
pageContext.setAttribute(Attributes.LOOP_ITEM, Integer.toString(this.begin));
this.begin --;
}
}
public int doAfterBody() throws JspException{
if(this.end <= this.begin) {
pageContext.setAttribute(Attributes.LOOP_ITEM, new Integer(this.begin));
this.begin --;
//Continue looping
return EVAL_BODY_TAG;
} else {
// We're done
return SKIP_BODY;
}
}
public int doEndTag() throws JspException {
try {
pageContext.getOut().print(bodyContent.getString());
return EVAL_PAGE;
} catch (Exception e) {
throw new JspException(e.getMessage());
}
}
}
Dovresti studiarti che cosa fa ogni singolo metodo doEndTag(),doStartTag(),doInitBody(),doAfterBody() . Dopo aver creato il tuo Custom Tag dovrai configurarlo nel file .tld nel seguente modo :
Codice PHP:
<tag>
<name>forEachReverse</name>
<tag-class>com.informa.ipi.admin.tags.ForEachReverseTag</tag-class>
<body-content>JSP</body-content>
<description>
I've made this tag to print year option values reverse. From 2006 to whereever I want.
It works from a begin number major than end number.
</description>
<attribute>
<name>begin</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>end</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag
Questo è un'esempio ora dovresti studiare un pò di più J2EE, visita qui :
http://java.sun.com/j2ee/1.4/docs/tu...doc/index.html
Ho capito che lavorare stanca ma studiare ti mantiene la mente elastica ...