2 Replies Latest reply on Mar 4, 2011 10:04 AM by Some Kid

    reRender does  not work after the value of the backing bean field is changed

    Some Kid Newbie


      I have a seam/richfaces3.3.1 application and I'm having a problem rerendering a field after the value of the backing bean field is changed.

      Here's an example demonstrating my problem.




      <!DOCTYPE compositionPUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN"
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"

      <ui:define name="body">
                     <h:form >
                     <rich:panel >
                     <s:decorate id="alarmLocationField"template="layout/editLongLabel.xhtml">
                            <ui:define name="label">First Field</ui:define>
                            <h:inputTextarea id="first" value="#{test.first}"  valueChangeListener="#{test.listen2Me}"

                                   required="true"   immediate="true" >
                            <a4j:support event="onblur" reRender="firstField" bypassUpdates="true"ajaxSingle="true" />   
                            <a4j:commandButton value="Test" action="#{test.setTestCode()}" reRender="firstField,secField" ajaxSingle="true"

                                oncomplete=" alert('I am back');"   />
                     <s:decorate id="secField" template="layout/editLongLabel.xhtml">
                            <ui:define name="label">Second Field</ui:define>
                            <h:inputTextarea id="second" value="#{test.second}" 
                                   required="true"   immediate="true" >






      And here's the bean




      publicclass TestBean
        private String first;
        private String second;


        public String getName() {
             return second;

        public void setSecond(String second) {
             this.second= second;

        public String getFirst() {
                return first;
         public void setFirst(String first)
             this.first= first;
         public String setTestCode()
             setFirst("new code");
             setSecond("new name");
          public void listen2Me(ValueChangeEventevent)
             System.out.println("I'm in listen2Me" + event.getNewValue());




      The problem is that if I type a text in field "first" and click "Test" I expect the following to happen:

      1. The function of the eventChangeListener is executed
      2. The values of fields "first" and "second" are changed
      3. UI component values are rerendered with the new ones - "new code" and "new name"


      What happens however is:

      1. The function of the eventChangeListener is executed
      2. The values of fields "first" and "second"  are changed
      3. Only the "second" field is reRendered with the new value "new name".


      After some debugging I found out that the following line


      <a4j:support event="onblur" reRender="firstField" bypassUpdates="true"ajaxSingle="true" />   



      is the reason for the first field keeping the value that was typed instead of reRendering the new value "new code". If I remove that line, however, the eventChangeListener function is not invoked and I have important functionality there that needs to be executed  .


      Is there a way of reRendering a control's value if the onblur event has done reRendering as in this example?