How to redisplay RichFaces component after a4j link call

Hoping someone can help me with a small hurdle I encountered regarding re-rendering RichFaces components after the a4j / button link performed this action. A simplified version of my problem is this:

I have two output components displaying a text value that displays based on some value in my manager class:

<h:outputText id="on" value="ON" rendered="#{manager.isOn}" /> <h:outputText id="off" value="OFF" rendered="#{not manager.isOn}" /> 

I also have 2 a4j links that trigger some action and then redisplay the above outputText components:

 <a4j:commandLink ajaxSingle="true" value="Set On" action="#{manager.setOn(true)}" reRender="on,off" /> <a4j:commandLink ajaxSingle="true" value="Set Off" action="#{manager.setOn(false)}" reRender="on,off" /> 

What I expect will happen when I click the Install On button, the outputText 'ON' component will be displayed, and the "OFF outputText" component will be displayed. However, this does not happen.

Does anyone have an answer why this is so, and how do I redesign these components after the a4j component has completed its operation?

+6
jboss richfaces ajax4jsf seam
source share
4 answers

Wrap the outputText components in s:div and repeat the rendering as follows:

 <s:div id="myDiv"> <h:outputText id="on" value="ON" rendered="#{manager.isOn}" /> <h:outputText id="off" value="OFF" rendered="#{not manager.isOn}" /> </s:div> <a4j:commandLink ajaxSingle="true" value="Set On" action="#{manager.setOn(true)}" reRender="myDiv" /> <a4j:commandLink ajaxSingle="true" value="Set Off" action="#{manager.setOn(false)}" reRender="myDiv" /> 
+11
source share

I agree with Gene, but the best way I could find the content

<a4j:outputpanel id="whatever_id" />

eg,

 <a4j:outputpanel id="myDiv"> <h:outputText id="on" value="ON" rendered="#{manager.isOn}" /> <h:outputText id="off" value="OFF" rendered="#{not manager.isOn}" /> </a4j:outputpanel> 
+3
source share

You reregister the parent. This should not be a Seam tag.

+1
source share

I assume that your h: outputText elements are turned on and off when the page loads.

RichFaces will not reload these components later, even if the rendered value changes to true.

0
source share

All Articles