Problem with JSF rendered

Hi,

I have strange problem in my JSF project. When i use rendered along with <h:commandButton> it is not invoking method specified in action attribute. In following code

<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<h:commandButton

action="#{myBean.updateMyData}"

value="EditButton"

rendered ="#{myBean.buttonClicked == 'edit'}">

</h:commandButton>

<h:commandButton

action="#{myBean.saveMyData}"

value="SaveButton"

rendered ="#{myBean.buttonClicked == 'save'}">

</h:commandButton>

It is showing proper buttons on jsp pages. i.e. if value of "myBean.buttonClicked" = save , it shows save button else it shows edit button.

But problem is when i click the button, it is not calling any method.ie. neither "saveMyData" nor "updateMyData".

Now, if i make use of <t:saveState> of myfaces, it works fine. Following is code after inserting which it works fine.

<%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk"%>

<t:saveState value="#{myBean}"/>

Please help me out on this. I dont want to save the state and i want rendered to work fine. Any pointers will be really helpful to me.

Thanks,

Vishal

[1303 byte] By [vishal@screena] at [2007-11-27 7:49:42]
# 1
Did you put your commandButton tags inside a form tag?
RaymondDeCampoa at 2007-7-12 19:30:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Yes, I have put h:commandButton tag under the h:form tag.
vishal@screena at 2007-7-12 19:30:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Yes, I have put h:commandButton tag under the h:form tag.
vishal@screena at 2007-7-12 19:30:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
If your bean you're referring to in the rendered attribute is request scoped, then this behavior is expected. Workarounds are using the t:saveState, using session scoped beans, or modifying the rendered attribute directly via method calls instead of via expressions.
rlubkea at 2007-7-12 19:30:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Hi rlubke,

Thank you very much for replying. I understood first two work arounds but not clear about third one. i.e "modifying the rendered attribute directly via method calls instead of via expressions" .

Can you please elaborate this technique?If you can provide some example code then it would be great.

Thanks,

vishal

vishal@screena at 2007-7-12 19:30:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...