首先,在页面中,将Button文本设置为"Edit"并显示。
当我点击"编辑"按钮时,按钮文本将变为"完成",同时,它会做一个动作来渲染页面上的一些复选框。
在我选中某个复选框后,点击"完成"按钮,它会做另一个动作。
我不知道如何在ADF移动。我们可以只用这个按钮来做所有这些吗?
谢谢!
我选择使用两个按钮,这是我的代码:
<amx:facet name="secondary">
<amx:commandButton id="cb2" text="#{viewcontrollerBundle.EDIT}" rendered="#{viewScope.editMode == ''}">
<amx:setPropertyListener id="spl1" from="EditMode" to="#{viewScope.editMode}" type="action"/>
</amx:commandButton>
<amx:commandButton id="cb3" text="#{viewcontrollerBundle.DONE}" rendered="#{viewScope.editMode == 'EditMode'}">
<amx:actionListener id="al1" binding="#{bindings.removeFromImageList.execute}"/>
<amx:setPropertyListener id="spl2" from="" to="#{viewScope.editMode}" type="action"/>
</amx:commandButton>
</amx:facet>
这段代码可以在单击编辑按钮时显示DONE按钮。在我的测试页面中,它是有效的。但是当我把它们放入我的项目页面时,它不能立即显示DONE按钮。我应该翻到前一页,然后再回到该页,然后DONE按钮将显示。你知道为什么吗?
您可以使用相同的按钮。您可以将按钮的文本字段的值设置为bean的属性。动作监听器是同一个bean中的一个函数,你可以根据文本执行不同的操作。
AMX页面看起来像
<amx:commandButton text="{applicationScope.myBean.buttonText}" id="cb3" styleClass="actions-button" actionListener="#{applicationScope.myBean.myListener}"></amx:commandButton>
bean应该看起来像
public class Class1 {
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
public Class1() {
super();
}
private String textButton;
public void myListener(ActionEvent ae) {
if (textButton.equals("Edit")) {
//DO THE ACTION WHICH NEEDS TO BE DONE FOR EDIT BUTTON
setTextButton("Done");
} else if (textButton.equals("Done")) {
//DO THE ACTION FOR DONE BUTTON
}
}
public void setTextButton(String textButton) {
String oldTextButton = this.textButton;
this.textButton = textButton;
propertyChangeSupport.firePropertyChange("textButton", oldTextButton, textButton);
}
public String getTextButton() {
return textButton;
}
public void addPropertyChangeListener(PropertyChangeListener l) {
propertyChangeSupport.addPropertyChangeListener(l);
}
public void removePropertyChangeListener(PropertyChangeListener l) {
propertyChangeSupport.removePropertyChangeListener(l);
}
}