Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
Textbox is not displaying the values onChange Dropdown
posted

Hi, On selection of a dropdown i,m calling onChange method in that setting Global variables with some data. The Global variables are binded to the InputText boxes in the form. But my problem is those setted values are not displaying in the form after Onchange dropdown but it is setting in bean variables(tested with System.out.print)

 

JSP :

 <ig:dropDownList binding="#{Page1.htmlDropDownList1}" dataSource="#{Page1.list}" id="htmlDropDownList1" smartRefreshIds="textField1"

       style="position: absolute; left: 264px; top: 72px" valueChangeListener="#{Page1.onChange}"/>
 
   <h:inputText binding="#{Page1.textField1}" id="textField1" style="position: absolute; left: 264px; top: 120px" value="#{Page1.fld}"/>
 
 
Bean :

 public void onChange(ValueChangeEvent event) {

       System.out.println("Drop Down changed");

       setFld("Aslam");

       System.out.println("get "+getFld());

   }

pls provide me the solution

Thanks

Rgds
Aslam

 

 

Parents
  • 2301
    posted

     You should not use the setFld method to control the value of fld. In JSF the setters are used by the JSF framework to update values arriving from the browser.

     Instead, use the getFld method. When JSF wants to get the value of fld, this is the method it'll use. 

    So, you might pattern your code like this:

      public class Bean {

            private boolean male;

            public void onChange(ActionEvent e) {

                  if(e.newValue().equals("male")) male=true;

                  else male = false;

           }

          public String getFld() {

             if(male) return "Hello Sir";

            else return "Hello Miss";

       }
     

Reply Children