Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 840635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:39:24+00:00 2026-05-15T05:39:24+00:00

I want to have a generic menu in my JSF (MyFaces 1.2) application. <h:form>

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:39:25+00:00Added an answer on May 15, 2026 at 5:39 am

    That’s because anonymous classes are not accessible from outside the package containing the anonymous class.

    Here’s a demonstration what’s happening behind the scenes:

    public static void main(String[] args) throws Exception {
        Portal portal = new Portal();
        Object list = portal.getClass().getDeclaredMethod("getActionList", null).invoke(portal, null);
        Object action = list.getClass().getDeclaredMethod("get", new Class[] { int.class }).invoke(list, 0);
        action.getClass().getDeclaredMethod("action", null).invoke(action, null);
    }
    

    Try executing this in the same package as Portal class and then once again in another class outside the package. In the other package, the last line would then throw exactly the same exception. That’s the problem EL is struggling with since it’s based on reflection.

    I don’t see other ways to solve this nicely than just creating a public (inner) class. Reflection (and thus also EL) can access them from other packages.

    public class Portal {
    
        private List<IAction> list = new ArrayList<IAction>();
    
        public Portal() {
            list.add(new IActionImpl());
        }
    
        public class IActionImpl implements IAction {
            public void action() {
                System.out.println("called action here");
            }
        }
    
        public List<IAction> getActionList() {
            return list;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a generic event that I can fire that will take
I want to have a generic function for a few types such as long,
I want to have a generic object that implements an interface. I mean if
Okay, so I want to have a generic method that can read data from
I want to write in Delphi (2009 - so I have generic dictionary class)
I have a Generic Base Class that I want to allow one of two
If I have two generic lists, List, and I want to merge all the
I want to have a generic PHP function that builds a mysql query based
Goal I have a generic class GenericClass<T> and I want to pool instances. I'm
I have in XAML 3 menu items defined (using WPF-MDI): <MenuItem Header=_Generic Name=Generic ToolTip=Generic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.