| Author |
Problem after rendering a commandButton
|
varun prakash
Greenhorn
Joined: Oct 12, 2006
Posts: 17
|
|
Hi friends, I'm facing a strange problem in jsf. First time only one commandButton is shown in my page. When i click that commandButton, one flag is set and it shows another commandButton(second). But after that, when i click the second commandButton even decode method is not getting called and the action method defined below(doAction) is not getting invoked. Is it a problem in JSF framework itself? Code Snippet My Xhtml looks like this: <h:form> <h:commandButton id="test" value="first" action="#{demo.showFlag}" /> <h:panelGrid id="grid"> <h:commandButton id="bt1" value="second" action="#{demo.doAction}" rendered="#{demo.flag}"/> </h:panelGrid> </h:form> Demo.java public void showFlag(){ flag=true; } Thanks in Advance, VarunJ
|
SCJP - 98%<br />SCWCD - 89%
|
 |
Darryl Nortje
Ranch Hand
Joined: Jun 11, 2002
Posts: 140
|
|
Howzit Varun, Do you have the doAction method defined in your Demo.java bean??
|
 |
varun prakash
Greenhorn
Joined: Oct 12, 2006
Posts: 17
|
|
Hi, Ya, I have the doAction() method declared properly.
|
 |
Darryl Nortje
Ranch Hand
Joined: Jun 11, 2002
Posts: 140
|
|
that's odd because I just got it working perfectly here. Can you please then post your entire jsp file as well as your entire bean. Also make sure that the bean is declared in the jsf config xml file, and that that xml config file is referenced in your web.xml. If that is all good, then this works just fine.
|
 |
Venkat Sadasivam
Ranch Hand
Joined: May 10, 2008
Posts: 139
|
|
|
Instead of rendered attribute in <h:commandButton> use <c:if test="#{demo.flag}">
|
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
|
 |
Ted Raymond
Greenhorn
Joined: Jun 17, 2008
Posts: 1
|
|
|
Actually, the <c:if> statement will not work either. I'm going to assume that your backing bean is Request scoped. If you want this to work, you need to change the scope to Session. If the scope is request, when you use the rendered action button, JSF rebuilds the model and does not know that demo.flag should be true, so the action button is not created in the model and hence is not fired. If you change the scope to session, it will work.
|
 |
 |
|
|
subject: Problem after rendering a commandButton
|
|
|