I'm using JSF 1.2 and RichFaces in my project. I'm trying to implement a scenario which is as follows, I have two rich:panel
in my page and their rendered attribute is set to a boolean
variable in a bean and the default values of the variable is set to false, so the first time the page is loaded the panels do not get rendered. I have a a4j:commandButton
in my page and on the action attribute of the button I am calling a method in my bean which sets the two flag variable but the panels are not getting rendered even after the variables are set, and I am also setting the rerendered
attribute of the button, I don't think I am missing any steps.
Asked
Active
Viewed 1,065 times
0

Tiny
- 27,221
- 105
- 339
- 599

Abhishek Singh
- 67
- 10
1 Answers
0
If component is not rendred when page is loaded then it will not make any change even when you will change the value of boolean variable to true on some commanad button click as well. Your component should be in view to rendered on Button click . So put your component inside another component Please chek below code
Following will not work when #{bean.renderResult}
defaults to false:
<h:form id="form">
<h:commandButton value="Submit" action="#{bean.toggleRenderResult}">
<f:ajax render=":result" />
</h:commandButton>
</h:form>
<h:outputText id="result" value="#{bean.result}" rendered="#{bean.renderResult}" />
You need to ensure that the render ID points to a component which is already present in the JSF-generated HTML output.
Following will work:
<h:form id="form">
<h:commandButton value="Submit" action="#{bean.toggleRenderResult}">
<f:ajax render=":result" />
</h:commandButton>
</h:form>
<h:panelGroup id="result">
<h:outputText value="#{bean.result}" rendered="#{bean.renderResult}" />
</h:panelGroup>
For more information check http://balusc.blogspot.in/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichIsByItselfConditionallyRendered

Subodh Joshi
- 12,717
- 29
- 108
- 202
-
3please search for duplicates first if you know the Q is about 'basic' jsf concepts/problems/caveats/... – Kukeltje Aug 12 '15 at 13:51
-
Ok thanks for the information – Subodh Joshi Aug 12 '15 at 13:53