I understand that your bean is request scoped, otherwise you wouldn't have this problem. This is a timing problem.
The rendered
attribute is also determined during "apply request values" phase of JSF lifecycle. However, the submitted values are only been set in the model during "update model values" phase of JSF lifecycle, which is later. Thus, when rendered
attribute is evaluated, it doesn't get the submitted value from the hidden input, but instead the property's default value.
If it's not an option to change the request scope to the view scope, then you'd need to salvage this problem differently. One of the simplest ways changing the <h:inputHidden>
to be a <f:param>
and inject the value via @ManagedProperty
on #{param}
map:
<h:commandButton value="Button"
action="#{bean.method}"
rendered="#{bean.conditon}"
>
<f:param name="condition" value="#{bean.condition}" />
</h:commandButton>
(note that I omitted type="submit"
as it's the default already)
with
@ManagedProperty("#{param.condition}")
private boolean condition;
See also: