Instead, you need to update the generic parent <div class="rightContent">
. This one is always visualized and thus ensures that JavaScript / Ajax can access and focus its children. Replace it with <h:panelGroup layout="block">
and give it an id
.
<h:panelGroup layout="block" id="content" class="rightContent"> <h:panelGroup rendered="#{test.firstStep}"> <h3>This should disappear</h3> <h:form id="newPollForm1"> <fieldset> <h:commandLink value="Next" action="#{test.firstStepCompleted()}" > <f:ajax execute="@form" render=":content" /> </h:commandLink> </fieldset> </h:form> </h:panelGroup> <h:panelGroup rendered="#{test.secondStep}"> Works! </h:panelGroup> </h:panelGroup>
Using this Test.java
class:
import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; @ManagedBean @ViewScoped public class Test { private int number = 0; public void firstStepCompleted() { number++; } public boolean isFirstStep() { return number == 0; } public boolean isSecondStep() { return number == 1; } }
Note that I removed the extra calls to Boolean#booleanValue()
and the duplicated rendered
expression on the form.
If this still does not work, then /elements/templateWithMenu.xhtml
apparently contains another component of the naming container that added its identifier. For beginners who have not yet remembered all the components of the container naming container, an easy way to determine the real correct client identifier is to open the page in the browser, right-click and View Source, and then find the HTML element created by the JSF and take its id
attribute value (and its prefix c :
in <f:ajax render>
).
source share