请问一下有关自定义标签库的问题?
TagExtraInfo类有什么作用,VariableInfo类也是什么与TagExtraInfo有什么关系?
小弟的E文很差!看了半天有关JBuilder帮助也没看明白!以下是自定义标签库的处理代
码:
public class FooTag exends ExampleTagBase implements BodyTag {
private String atts[] = new String[3];
int i = 0;
private final void setAtt(int index , String value) {
atts[index] = value;
}
// 在这个标签中定义了三个属性 att1 att2 att3
public void setAtt1(String value) {
setAtt(0 , value);
}
public void setAtt2(String value) {
setAtt(1 , value);
}
public void setAtt3(String value) {
setAtt(2 , value);
}
public void doInitBody() throws JspException {
pageContext.setAttribute("member" , atts[i]);
i++;
}
public int doAfterBody() throws JspException {
try {
if (i == 3) {
bodyOut.writeOut(bodyOut.getEnclosingWriter());
return SKIP_BODY;
}
else {
pageContext.setAttribute("member" , attrs[i]);
}
i++;
return EVAL_BODY_TAG;
} catch (EOException ex) {
throw new JspTagException(ex.toString());
}
}
}
public class FooTagExtraInfo extends TagExtraInfo {
public VariableInfo[] getVariableInfo ( TagData data ) {
return new VariableInfo[]
{ new VariableInfo("member" , "String" , true , VariableInfo.NESTED) }
}
}