I want to have a generic menu in my JSF (MyFaces 1.2) application.
<h:form>
<h:dataTable id="dt1" value="#{portal.actionList}" var="item">
<f:facet name="header">
<h:outputText value="Menu" />
</f:facet>
<h:column>
<h:commandLink action="#{item.action}">
<h:outputText value="clickme"/>
</h:commandLink>
</h:column>
</h:dataTable>
</h:form>
Then my portal on session-scope would look like this:
class Portal {
private ArrayList<IAction> list = new ArrayList<IAction>();
public Portal() {
list.add(new IAction() {
public action() {
log.info("called action here");
}
});
}
public ArrayList<IAction> getActionList() {
return list;
}
}
When I run this code it will display fine. But when you try to execute the action by clicking the "clickme" command link - the following exception will occur:
Class org.apache.el.parser.AstValue can not access a member of class Portal$1 with modifiers "public"
Is there any way to display a list of anonymous classes, from which an method (in this example ITemplate.action()
) can be executed?
Edit:
It works when I use an (inner) class. Like for example:
class Bla implements IAction {
public void action() {
log.info("yes, i am working");
}
and in the Portal constructor
public Portal() {
list.add( new Bla() );
}
But this is not the way I want it...