Monday 9 May 2016

How to get input values in Managed bean

ADF : How to get input values in Managed bean

                 
Use case :

When I click a button, I want the button to call a method in a java bean and access the value of an input text fields  from ADF Faces pages .

There are many solutions available . This one is basic and easy approach

Solution : 

you can do this by creating binding for each component in a managed/backing bean so that bean will have getter/setter property created for you . Add a button in the page that will have the action listener method to the same bean where you have created bindings for the input components and you can access the values using this.getId().getValue() .

 <b>in Jsff :</b>

 <af:inputText label="Id" id="it1" binding="#{pageFlowScope.SourceFile1.id}"/>
        
 <b>in Bean</b>



       
JAVA CODE:-
 


private RichInputText id;

 public void setId(RichInputText id) {
this.id = id;
 }

 public RichInputText getId() {
 return id;
  }
       
  public void onClickSubmit(ActionEvent actionEvent) {
  System.out.println(this.getId().getValue().toString());
  }


 

1 comment: