3 Replies Latest reply on Jun 21, 2012 7:06 AM by ivan_ra

    a4j:support and partial page updating

      Hello!

       

      I'm new in richafces and I need help in this problem.

      1. I have the following elements on page:

      <f:view>

          <a4j:form>

          <h:selectOneMenu style="width:100px" value="#{userSessionBean.simpleDictPreffix}" id="dict-preffix"

                           valueChangeListener="#{userSessionBean.dictPreffixListValueChanged}">

              <f:selectItems value="#{applicationData.searchList}"/>

              <a4j:support event="onchange" ajaxSingle="true" action="#{userSessionBean.changeDictionaryAction}" reRender="showDictBtn"/>

          </h:selectOneMenu>

          ...

      <%-- AND -- %>

         ...

          <a4j:commandButton value="..." title="#{header_var.dict_btn_tip}"

                             action="#{userSessionBean.showDictAction}"

                             reRender="mpViewSearchValues"

                             rendered="#{userSessionBean.showDictBtnVisible}"

                             id="showDictBtn"/>

          .....

          </a4j:form>

      </f:view>

       

      2. userSessionBean.changeDictionaryAction is:

              public String changeDictionaryAction() {

                  ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();

         

                  List<SearchItemDescriptor> searchItemList = (List<SearchItemDescriptor>) ec.getApplicationMap().get("search-list");

         

                  for (SearchItemDescriptor sid : searchItemList) {

                      String s = sid.getPreffix();

         

                      if (s.equals(simpleDictPreffix) == true) {

                          if (sid.getMenu() != null) {

                              showDictBtnVisible = true;

         

                              return null;

                          }

                      }

                  }

         

                  showDictBtnVisible = false;

         

                  return null;

              }

       

      But when showDictBtnVisible is true, the button showDictBtn is not appear.

      What is wrong? I use RichFaces 3.3.2.

       

      Thanks, to all.

        • 1. Re: a4j:support and partial page updating
          sivaprasad9394

          Hi,

           

          If you are able to set the value to true in the backend  function ..please foloww the step and try,

          <a4j:support event="onchange" ajaxSingle="true" action="#{userSessionBean.changeDictionaryAction}" reRender="displayBtnPanel,showDictBtn"/>

          _____________

          <a4j:outputPanel id="displayBtnPanel">

                          <a4j:region   rendered="#{userSessionBean.showDictBtnVisible == true}">    

            <a4j:commandButton value="..." title="#{header_var.dict_btn_tip}"

                                 action="#{userSessionBean.showDictAction}"

                                 reRender="mpViewSearchValues"

                                 rendered="#{userSessionBean.showDictBtnVisible}"

                                 id="showDictBtn"/>

          </a4j:region>

                          </a4j:outputPanel>  

          • 2. Re: a4j:support and partial page updating

            Thank you, but unfortunately this has effect

            • 3. Re: a4j:support and partial page updating
              ivan_ra

              showDictBtn initially not present on form, so it cant be rerendered.

              You have to rerender already existing component, like this:

               

                  <h:selectOneMenu style="width:100px" value="#{userSessionBean.simpleDictPreffix}" id="dict-preffix"

                                   valueChangeListener="#{userSessionBean.dictPreffixListValueChanged}">

                      <f:selectItems value="#{applicationData.searchList}"/>

                      <a4j:support event="onchange" ajaxSingle="true" action="#{userSessionBean.changeDictionaryAction}" reRender="dictBtnPanel"/>

                  </h:selectOneMenu>

              ...

                <h:panelGroup id="dictBtnPanel">

                  <a4j:commandButton value="..." title="#{header_var.dict_btn_tip}"

                                     action="#{userSessionBean.showDictAction}"

                                     reRender="mpViewSearchValues"

                                     rendered="#{userSessionBean.showDictBtnVisible}"

                                     id="showDictBtn"/>

                </h:panelGroup>