3

我在屏幕上有两个按钮。首次加载页面时,我想禁用按钮 2,直到单击按钮 1。单击 button1 时,必须启用 button2。

我试过了:

<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>

我的豆子:

@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;
    }
}

但它不起作用。当我单击按钮 1 时,按钮 2 仍然被禁用。怎么了?

4

2 回答 2

5

尝试在单击第一个按钮时更新第二个按钮,例如dataTable


您应该将beanindisabled="#{!(bean.disable)}">替换为mainTable=>disabled="#{!(mainTable.disable)}">

于 2013-10-04T07:49:17.740 回答
1

您应该在输出面板中交换 2 个按钮,并将此输出面板更改为下一个按钮,如下所示:

<p:outputPanel id="pnltest">
  <p:commandButton value="Normalize"
    actionListener="#{mainTable.normalize}" update="dataTable,pnltest"
    ...
  </p:commandButton>
  <p:commandButton value="To Verify Next->" action="verify.xhtml"
    actionListener="#{mainTable.verify}" id="next"
    ...
  </p:commandButton>
<p:outputPanel>
于 2013-10-04T07:58:11.257 回答