4 Replies Latest reply on Nov 10, 2009 9:04 AM by Chris Werner

    update/reRender inputText field on value change

    Chris Werner Newbie


      I have a selectOneListbox with serveral Items. When selecting an item in this box I want a inputText field to be updated with a correspondant value. To achieve this I use a valueChangeListener on the selectOneListbox to update the Values in the backing bean and a a4j:support to reRender the inputText field. Any ideas why this doesn't work?

      <h:form id="viewControllerForm" enctype="multipart/form-data">
       <h:selectOneListbox id="SelectData" size="5" valueChangeListener="#{viewController.selectionChanged}">
       <f:selectItems value="#{viewController.getDataToSelect()}" />
       <a4j:support event="onchange" reRender="InputFields"/>
       <h:panelGrid id="InputFields" columns="2">
       <h:inputText id="input_value_1" value="#{viewController.value1}" />
       <h:inputText id="input_value_2" value="#{viewController.value2}" />

      There is more code inside the form but I left it for reading purposes.
       private String value1;
       private String value2;
       @Out(required = false)
       public String getValue1() {
       return value1;
       @In(required = false, create = true)
       public void setValue1(String value1) {
       this.value1= value1;
       @Out(required = false)
       public String getValue2() {
       return value2;
       @In(required = false, create = true)
       public void setValue2(String value2) {
       this.value2= value2;
       public void selectionChanged(ValueChangeEvent e) {
       if (e.getNewValue() instanceof String) {
       String item = (String) e.getNewValue();
       if (item != null) {
       value1 = item.split(",")[0];
       value2 = item.split(",")[1];

      Something else is strange: The selectionChangedListener is only called if the <a4j:support event="onchange" /> tag is added. As far as I know it should work without, too.

      Thx, for your help.