First, in the page, the Button text is set to "Edit" and show.
When I clicked the "Edit" button, then the Button text will change to "Done", meanwhile, it will do a action to render some checkBoxs on the page.
After I pick some checkBox, and click the "Done" button, it will do another action.
I don't know how to do it in ADF Mobile. Can we just using this one button to do all these?
Thanks!
I chose to use two button, here is my code:
<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>
This code can show the DONE button when click the edit button. And in my test page, it works. But when I put them into my project page, it cannot show the DONE button immediately. I should turn to the previous page, and go back to the page again, then the DONE button will show. Do you know why?
You can do it using the same button. You can set the value of text field for the button as a property of a bean. And in the action listener which is a function in the same bean, you can do different actions based on the text.
AMX Page will look something like
<amx:commandButton text="{applicationScope.myBean.buttonText}" id="cb3" styleClass="actions-button" actionListener="#{applicationScope.myBean.myListener}"></amx:commandButton>
The bean should look something like
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);
}
}