I have two buttons on screen. When page first loaded I want to button2 is disabled until button1 is clicked. When button1 is clicked, button2 must be enabled.
I tried:
<p:commandButton value="Normalize"
actionListener="#{mainTable.normalize}" update="dataTable"
id="normalize" styleClass="ui-priority-primary"
style="font-size: 14px">
<f:setPropertyActionListener value="#{true}"
target="#{mainTable.disable}" />
</p:commandButton>
<p:commandButton value="To Verify Next->" action="verify.xhtml"
actionListener="#{mainTable.verify}" id="next"
styleClass="ui-priority-primary" style="font-size: 14px"
disabled="#{!(bean.disable)}">
</p:commandButton>
My bean:
@ManagedBean
@SessionScoped
public class MainTable
{
private boolean disable;
public MainTable()
{
disable = false;
}
public boolean isDisable()
{
return disable;
}
public void setDisable(boolean disable)
{
this.disable = disable;
}
}
But it doesn't work. When I clicked button1, button2 is still disabled. What is wrong?
Try to update the second button on clicking the first one like the dataTable
You should replace the bean
in disabled="#{!(bean.disable)}">
with mainTable
=> disabled="#{!(mainTable.disable)}">