Disabling an input text when a button is pressed in ADF mobile

1.6k views Asked by At

In an ADF mobile application I want to disable an input-text when a button is pressed. How to do it ? Please help

1

There are 1 answers

1
amishra On BEST ANSWER

Create a managed bean property to be used for inputText readOnly

private boolean readOnlyText = false;

Right click on the managed bean class and choose Generate Accessors from the menu. Select readOnlyText to genearate getter/setter methods. Make sure to check

Notify listeners when property change

check box as this will add PropertyChangeSupport to the bean. As a result the setter method will have following code:

public void setReadOnlyText(boolean readOnlyText) {
    boolean oldReadOnlyText = this.readOnlyText;
    this.readOnlyText = readOnlyText;
    propertyChangeSupport.firePropertyChange("readOnlyText", oldReadOnlyText, readOnlyText);
}

Use this property in your inputText:

<amx:inputText label="label1" id="it1" readOnly="#{viewScope.mBean.readOnlyText}"/>

Bound the ActionListener of the button to a method in managed bean:

<amx:commandButton text="Disable" id="cb3" actionListener="#{viewScope.mBean.buttonActionListener}"/>

In buttonActionListener set readOnlyText = true;

public void hideInputActionListener(ActionEvent actionEvent) {
    setReadOnlyText(true);       
}

For more details refer OTN Code Corner