0

I have an application running JSF2.0 on the front end. In the backend instead of using managed beans I'm using weld's named beans. The bean in question is annotated @Named @Singleton @Startup and is an EJB Singleton. The bean gets the top level category to populate the front end. In the top level navigation of the front end I have code that look like so

<h:dataTable var="items" value="#{topCategorySingleton.topCat}">
<h:column>
<h:commandLink class="menu-link" action="#{categoryBackingBean.category}">
<f:setPropertyActionListener target="#{categoryBackingBean.catID}" value="#{item.sku}" />
 <h:outputText value="#{item.title}" />
 </h:commandLink>
 </h:column>
 </h:dataTable>

When this code runs I get an error stating javax.servlet.ServletException: The class 'com.webintel.backingbeans.org$jboss$weld$bean-testing-SessionBean-CategoryBackingBean_$$_WeldProxy' does not have the property 'category'.

I thought the action attribute of commandLink should bind to a method of the bean, not a property? Anyone have any ideas?

At startup the @Singleton is started and the code as follows:

@Singleton
@Named
@Startup
@ConcurrencyManagement(CONTAINER)
public class TopCategorySingleton{
  public TopCategoryStingleton(){}
  private int sku;
  private String title;
  private List<TopCategorySingleton> topCat;
....getters and setters
  public void getTop_Cat(){
   ....logic
   setTopCat(List<TopCateogrySingleton>);
  }

Then the backing bean code look like so:

@Stateless
@Named
@RequestScoped
public class CategoryBackingBean{
  public CategoryBackingBean(){}
  private int catID;
  ....getters and setters
  public String category(){
    ...logic
    if(!true){
      return "error";
    }
    return "success";
  }

For some reason it is still not binding the categoryBackingBean.category to the method. I am running this app on a Glassfish 3.1 server with Java 6. Thanks in advance for your help.

stirling
  • 143
  • 2
  • 3
  • 8
  • 2
    can you try use brackets 'category()' or do you have category method in your bean. because seems like application looking for getCategory(); field in your bean. – HRgiger Oct 12 '12 at 13:15
  • I've tried using 'category()' in the action attribute, still didn't work. I didn't think it would, the action attribute should bind to an action method on the bean, and yes I have a category method in the bean. – stirling Oct 12 '12 at 13:21
  • 1
    have you referenced the category method somewhere else in your xhtml?, Check even in the commented code! – Oscar Castiblanco Oct 12 '12 at 13:23
  • For testing purposes, I eliminated the dataTable and hard coded the list of top categories with the commandLink's for each and it worked perfectly. I don't want to hard code these values as they might change, so I would like to generate the list dynamically. – stirling Oct 12 '12 at 21:25
  • Where's the backing bean code? Can we see the method implementation/signature? – kolossus Oct 13 '12 at 05:06
  • I've updated my original post with the code you asked for. Thanks for all your help. – stirling Oct 14 '12 at 04:18
  • @ojota Find the problem, there was commented at the bottom of the page. I didn't think that would be a problem, guess I was wrong...not the first of last. Thanks for the help. – stirling Oct 14 '12 at 21:12
  • Yes, that is a common error. If you want to avoid the problem, you can use put this into your web.xml so that the comments are really ignored javax.faces.FACELETS_SKIP_COMMENTS true – Oscar Castiblanco Oct 15 '12 at 06:27

0 Answers0