1

i have a not resolveable problem, or at least with my limited knowledge about jsf. I know there are some good solutions to find on stackoverflow, but i can't figure out my error.

i just want to have some commandlinks like a navigationbar and they should change the content of a pre defined div tag which got an include clause. So i guess my Index could be reinterpreted as a kind of template.

my Index:

 <h:panelGroup id="navigation" layout="block"> <h:form> <h:panelGrid columns="4" columnClasses="colDefault,colDefault,colDefault,colDefault"> <f:ajax render=":include"> <h:commandLink value="entry1" action="#{menuController.setPage('login')}" /> <h:commandLink value="entry2" action="#{menuController.setPage('register')}" /> <h:commandLink value="entry3" action="#{menuController.setPage('welcome')}" /> </f:ajax> </h:panelGrid> </h:form> </h:panelGroup> <h:panelGroup id="center_content" layout="block" class="center_content" > <h:panelGroup id="include"> <ui:include src="#{menuController.page}.xhtml" /> </h:panelGroup> </h:panelGroup> 

its just like in this post of BalusC with a small and pretty simple bean:

@ManagedBean public class MenuController implements Serializable{ private String page; public String getPage() { return page; } public void setPage(String page) { this.page = page; } } 

but i got a TagAttributeException @

/index.xhtml @17,92 action="#{menuController.setPage('login')}" Could not Resolve Variable [Overflow]: menuController 

i've tryed, but i have no clue what to do.

3
  • #{menuController.setPage('login')} this is nowhere to be seen in your posted code. Did you miss some code? Commented Sep 6, 2013 at 7:14
  • edited, yes, i've copied a testversion Commented Sep 6, 2013 at 7:18
  • Are you running Servlet 3.0 / EL 2.2? Commented Sep 6, 2013 at 9:54

1 Answer 1

1

You need to put the bean in a fixed scope:

@ManagedBean @ViewScoped public class MenuController implements Serializable {} 

And you need to preinitialize page with a default value:

private String page; @PostConstruct public void init() { page = "login"; // Default value. } 
Sign up to request clarification or add additional context in comments.

1 Comment

ups, of corse, thanks for your help, BalusC! Always appreciate your work :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.