Using rendered= stops action method being called on commandButton

Help help help please.

I have a managed-bean defined at "request" scope. This bean contains an encodedId field which is a string. This string is present in the form as a hidden field. On submit of the form, this setEncodedId is called on my bean, which then decodes the string and does setup of the bean.

The problem I have is that if I use a commandButton with rendered="#{MyBean.renderNextButton}" and the result of isRenderNextButton() is dependent on encodedId from the submit, then the button IS correctly rendered, but the action tied to the button fails to be called and the same page reloads when the button is clicked.

However, if I hardcode 'true' as the return value of isRenderNextButton() then the button renders and the action is called correctly.

I've also noticed that isRenderNextButton() is called four or more times on each submit even through I've only got one button using this rendered expression.

Any ideas anyone?

[978 byte] By [DannyRoba] at [2007-10-1 0:06:09]
# 1

In the Apply Request Values phase, processDecodes method recursively finds activated ActionSources.

According to the javadoc of UIComponent.processDecodes, it stops finding when it reached a component whose rendered property is false.

Since you use a value binding as the rendered property and the request scope bean, it should be evaluated as false.

I think the solution is to use a session scope.

yuki.yoshidaa at 2007-7-7 15:50:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks for the answer. Without spending lots of time investigating, could I write my own implementation of commandButton that could have the render state encoded in the state information I see encoded in the form?
DannyRoba at 2007-7-7 15:50:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

> Without spending lots of time investigating, could I

> write my own implementation of commandButton that

> could have the render state encoded in the state

> information I see encoded in the form?

I can't understand the reason why you insist to hold the information in the component,

while the only you should do is to use a session scope bean to hold it using the standard JSF mechanism.

yuki.yoshidaa at 2007-7-7 15:50:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...