场景如下所示:
屏幕上有两个按钮,比如button1和button2.在页面加载时,button2被禁用.当用户单击button1时,将启用button2.我使用javascript window.onload事件和button1上的onclick事件实现了这个功能.我的问题是,当用户点击button1时,它会触发页面重新加载.话虽如此,在重新加载页面后,由于onload事件,button2被禁用.
有没有其他方法来实现此功能?
顺便说一句,我正在使用primefaces.
Kus*_*han 13
primeface页面是这样的,
<p:commandButton update="panel1" actionListener="#{bean.button1}" value="button1" disabled="#{bean.disable}">
<f:setPropertyActionListener value="#{false}" target="#{bean.disable}"/>
</p:commandButton>
<p:commandButton update="panel2" actionListener="#{bean.button2}" value="button1" disabled="#{!(bean.disable)}">
<f:setPropertyActionListener value="#{true}" target="#{bean.disable}"/>
</p:commandButton>
Run Code Online (Sandbox Code Playgroud)
管理Bean:
public class Bean {
private boolean disable;
// default constructor
public Bean(){
this.disable= false;
}
public boolean isDisable() {
return disable;
}
public void setDisable(boolean disable) {
this.disable = disable;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
59554 次 |
| 最近记录: |