如何在每次单击后继续更改命令按钮名称
How to keep changing commandbutton name after every clicks
我的问题是,例如,我有一个名为 "A" 的按钮,单击后会将按钮名称更改为 "B",如果我再次单击将更改回 [=12] =] 并在单击时在 "A" 和 "B" 之间不断变化。我怎样才能做到这一点?
在操作方法中切换一个布尔值并检查按钮的布尔值状态。
private boolean toggle;
public void toggle() {
toggle = !toggle;
}
public boolean isToggle() {
return toggle;
}
<h:commandButton value="#{bean.toggle ? 'B' : 'A'}" action="#{bean.toggle}">
<f:ajax render="@this" />
</h:commandButton>
我的问题是,例如,我有一个名为 "A" 的按钮,单击后会将按钮名称更改为 "B",如果我再次单击将更改回 [=12] =] 并在单击时在 "A" 和 "B" 之间不断变化。我怎样才能做到这一点?
在操作方法中切换一个布尔值并检查按钮的布尔值状态。
private boolean toggle;
public void toggle() {
toggle = !toggle;
}
public boolean isToggle() {
return toggle;
}
<h:commandButton value="#{bean.toggle ? 'B' : 'A'}" action="#{bean.toggle}">
<f:ajax render="@this" />
</h:commandButton>