Question

I have a taglib below

<po:create-option-entry var="optionEntry">

    <li>${optionEntry.name}: <%=HtmlElementUtil.printAction(optionEntry.getAction())%></li>

</po:create-option-entry>

and I'm getting the exception that optionEntry is not defined.. I've already seen some code like that but cant remember how it was wired to make the variable visible inside the body of the taglib.

ps.: the taglib's definition follows

<tag>  
    <name>create-option-entry</name>
    <tagclass>br.com.facilit.portlets.planooperativo.taglib.action_menu_entry.CreateOptionEntryTag</tagclass>   
    <bodycontent>JSP</bodycontent>

    <attribute>
        <name>var</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
</tag>
Was it helpful?

Solution

I have found a way to accomplish my question. all I need to do is create a CreateOptionEntryTei

<tag>  
    <name>create-option-entry</name>
    <tagclass>pack.CreateOptionEntryTag</tagclass>
    <teiclass>pack.CreateOptionEntryTei</teiclass>
    <bodycontent>JSP</bodycontent>
    <attribute>
        <name>var</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
</tag>

and define the class like this

public class CreateOptionEntryTei extends TagExtraInfo {

    public VariableInfo[] getVariableInfo(TagData data) {

        String var = data.getAttributeString("var");

        return new VariableInfo[] { new VariableInfo(var, OptionEntry.class.getName(), true, VariableInfo.NESTED), };
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top