0

Trying to build a simple JSF application. One i don't get is, what mechanism is to use to trigger page reload. I have tried following

<h:selectOneMenu 
    id="ChallengesListBox" 
    onchange="submit()" 
    valueChangeListener="#{bean.projectselected}">
    <f:selectItems value="#{bean.projectnames}"/>
</h:selectOneMenu>

<h:commandButton value="submit" action="#{bean.submit}" />

with

public String submit() {
    this.description.setRendered(true);
    return null;
}

But this has no effect. The bean method

public String submit()

remains untouched, as I can see in debug mode.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Galli
  • 23
  • 2
  • 8

1 Answers1

0

This is not related to navigation. There are many causes why a bean action method is not invoked. You can find them all in this answer: commandButton/commandLink/ajax action/listener method not invoked or input value not updated

I suspest that you've either simply no <h:form>, or that you have multiple buttons in the form (the first one would then be invoked on submit()), or that the button is by itself not rendered during processing of the form submit.


Unrelated to the concrete problem, this JSF 1.x style approach is very clumsy. As you're apparently already on JSF 2.x, I suggest the following much simpler approach:

<h:selectOneMenu value="#{bean.projectname}">
    <f:selectItems value="#{bean.projectnames}" />
    <f:ajax render="somepanel" />
</h:selectOneMenu>
<h:panelGroup id="somepanel">
    <h:outputText value="#{bean.description}" rendered="#{not empty bean.projectname}" />
</h:panelGroup>

(this will render the #{bean.description} value whenever the #{bean.projectname} is not null/empty according to the selection of the drop down list)

And make sure that you remove all binding attributes to the backing bean. Also make sure that the bean is @ViewScoped whenever you have input/button components inside the <h:panelGroup id="somepanel">.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555