• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

action vs outcome attributes

 
Calvin Hughes
Greenhorn
Posts: 8
Flex MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm just learning the basics of JSF and I have gotten myself confused just working through some simple navigation.

Here's my code:
JSF Page:

<h:form>
<h:link value="Index 1" outcome="#{menuBean.index}" />
<h:commandLink value="Index 2" action="#{menuBean.index}" />
</h:form>

MenuBean:

package edu.unmc.codawards.beans;

import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named
@RequestScoped
public class MenuBean implements Serializable{
private String index = "index"

public String getIndex() {
return index;
}
}

Index 1 works just fine but Index 2 gives me a "javax.el.MethodNotFoundException: /WEB-INF/CODAwardsTemplate.xhtml @27,87 action="#{menuBean.index}": Method not found: edu.unmc.codawards.beans.MenuBean@64743887.index()"

If I change my MenuBean getIndex method to just index I can get the action to work with action="#{menuBean.index()}"

While it works, this has me worried since all of the tutorials I am working through seem to treat both the outcome and action attributes the same with no need to include "()"

Surely I'm missing something so incredibly basic but I would appreciate any help I can get

Thanks
Calvin
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Outcome:



Expects a method getIndex() which returns a String in class MenuBean.

Action:



Expects a method index() in class MenuBean. You shouldn't need the () in the JSF code.



 
Calvin Hughes
Greenhorn
Posts: 8
Flex MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. I can't tell you how much that was annoying me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic