rendrered <h:commandLink> problem
lysy78 Aug 3, 2012 12:11 PMHello all,
Configuration:
- RichFaces 4.2.2
- Mojarra 2.1.11
- Jboss 6.1.0.Final
I have a small problem with rendered command link. Let's take a look at this simple code:
<h:head>
</h:head>
<h:body>
<h:form>
<a4j:commandButton value="set flag to true" action="#{renderBean.action}" render="panelId"/>
</h:form>
<h:panelGroup id="panelId">
<h5>rendered link</h5>
<h:form rendered="#{renderBean.flag}">
<h:commandLink value="hard coded" action="/pages/renderTarget.xhtml" />
</h:form>
</h:panelGroup>
<h5>normal links</h5>
<h:form>
<h:commandLink value="hard coded" action="/pages/renderTarget.xhtml" />
</h:form>
</h:body>
Managed bean looks like this:
@ManagedBean(name="renderBean")
@ViewScoped
public class RenderBean {
private boolean flag;
public boolean isFlag() {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
public void action(){
this.flag = true;
}
}
Everything is quite simple. When we first see the page it looks like this:
That's becouse renderBean.flag is set to false. So when we click button 'set flag to true' method action() i called and flag is set to true. Form is rendered and another link apears:
To this point everything looks great. But not so fast!
When I click normal link it works, and new page apears. But when I click rendred link nothing happens. I'm not redirected to the target page. The question of course is why?
I've been thinking for a while, but unfortunatelly without success.
So please, could you help me?
Hubert