6 Replies Latest reply on Feb 21, 2012 5:55 AM by warrior87.it

    a4j:commandButton makes a full page reload RichFaces 3.3.3 CR1

    Cesar Correia Newbie

      I have migrated one application from jsf1.2 to jsf2 and RichFaces 3.3.3 CR1. After some adjustments to the application became stable but my a4j:commandButtons doing a full page reload rather than rebuild only the piece of the tree indicated. Below i show my page:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:a4j="http://richfaces.org/a4j">

      <f:loadBundle basename="ApplicationResources" var="msgs" />

      <ui:composition>
          <rich:panel id="detailActorsPanel" styleClass="detailBox" columnClasses="detailBox" headerClass="detailBoxTitle" bodyClass="detailBox">
              <f:facet name="header">
                  <h:panelGrid columns="2" width="100%"
                      style="height: 25; vertical-align: middle;" border="0"
                      cellpadding="0" cellspacing="0" id="projectDetailPanel"
                      columnClasses="buttonsInsertItem,titleDetailItem">
                      <a4j:commandButton value="#{msgs.buttonNewItem}"
                          rendered="#{not projectMasterDetail.dataReadOnly}"
                          onmouseover="hover(this,'menuButtonOver')"
                          onmouseout="hover(this,'menuButton')"
                          oncomplete="onErrorsJumpToTop();"
                          action="#{facesViewEventHandler.newItem}"
                          actionListener="#{facesViewEventHandler.newItem}"
                          reRender="detailActorsTable"
                          onclick="getField('registerForm:detailPropertyName').value='actors';"
                          styleClass="menuButton" id="detailProjectNew" />
                      <h:outputText value="#{msgs.titleDetailActors}"
                          styleClass="detailTitle" />
                  </h:panelGrid>
              </f:facet>

              <rich:dataTable var="item" value="#{project.actors}"
                  styleClass="detail" columnClasses="detail" headerClass="detail"
                  id="detailActorsTable" binding="#{arangiDataTableDetail1.table}">

                  <h:column>
                      <f:facet name="header">
                          <h:graphicImage value="/img/trash.gif" />
                      </f:facet>
                      <h:selectBooleanCheckbox value="#{item.checkDelete}"
                          rendered="#{not empty item.id}"
                          disabled="#{projectMasterDetail.dataReadOnly}"
                          title="#{msgs.markToDelete}" />
                  </h:column>

                  <h:column>
                      <f:facet name="header">
                          <h:outputText value="#{msgs.actorNumber} *" />
                      </f:facet>
                      <h:inputText value="#{item.number}" id="actorNumber"
                          readonly="#{projectMasterDetail.dataReadOnly}" maxlength="255"
                          size="4" />
                  </h:column>

                  <h:column>
                      <f:facet name="header">
                          <h:outputText value="#{msgs.actorName} *" />
                      </f:facet>
                      <h:inputText value="#{item.name}" id="actorName"
                          readonly="#{projectMasterDetail.dataReadOnly}" maxlength="100"
                          size="40" />
                  </h:column>

                  <h:column>
                      <f:facet name="header">
                          <h:outputText value="#{msgs.actorDescription}" />
                      </f:facet>
                      <h:inputTextarea value="#{item.description}" id="actorDescription"
                          readonly="#{projectMasterDetail.dataReadOnly}" rows="3" cols="62"
                          title="#{msgs.actorDescriptionHelp}" >
                          <f:validateLength maximum="255" />
                      </h:inputTextarea>
                  </h:column>           

              </rich:dataTable>
          </rich:panel>
      </ui:composition>
      </html>

        • 2. Re: a4j:commandButton makes a full page reload RichFaces 3.3.3 CR1
          Cesar Correia Newbie

          Note: controller class has no JSF code. It simply includes some objects in a list. It is the code below.

           

           

          ###################

          public String newItem(){
                  log.debug("Entering in newItem event");
                  LogicBean logic = getLogicBean();
                  StandardApplicationController controller = (StandardApplicationController)getBean(logic.getControllerBeanName());
                  IApplicationContext context = getApplicationContext();
                  ControllerBean controllerBean = this.mountControllerBean(getFacesContext(), logic);
                 
                  FacesContext facesContext = FacesContext.getCurrentInstance();
                  Map<String, String> map = facesContext.getExternalContext().getRequestParameterMap();
                  String detailPropertyName = map.get("detailPropertyName");
                  if (StringUtils.isNotEmpty(detailPropertyName)){
                      controllerBean.setDetailPropertyName(detailPropertyName);
                  }
                  try {
                      controllerBean = controller.newItem(context, controllerBean);
                  } catch (Exception e) {
                      addMessageError(e);
                  }

           

                  setBean(logic.getDtoBeanName(), controllerBean.getDto());
                  setBean("arangiButtonBarController", controllerBean.getButtonBarController());
                 
                  processMessages(controllerBean);
                  return controllerBean.getForward();
              }

           


          protected void setBean(String name, Object value) {

           

                  setValue("#{" + name + "}", value);

           

              }

           


          protected void setValue(String expr, Object value) {

           

                  ValueBinding vb = getFacesContext().getApplication().createValueBinding(expr);
                  vb.setValue(getFacesContext(), value);

           

              }

           


          protected void processMessages(ControllerBean controllerBean){
                 
                  List messages  = controllerBean.getMessages();
                 
                  for (int i = 0; i < messages.size(); i++){
                      Message message = (Message)messages.get(i);
                      Severity severity = null;
                      switch(message.getType()){
                          case Message.TYPE_INFO:
                              severity = FacesMessage.SEVERITY_INFO;
                              break;
                          case Message.TYPE_ERROR:
                              severity = FacesMessage.SEVERITY_ERROR;
                              break;
                          case Message.TYPE_WARN:
                              severity = FacesMessage.SEVERITY_WARN;
                              break;
                          case Message.TYPE_FATAL:
                              severity = FacesMessage.SEVERITY_FATAL;
                             
                      }
                      addMessage(message.getKey(), message.getArgs(), severity, message.getBundle(), message.getIdField());
                  }
          }

           

          protected void addMessage(String key, String[] args, Severity severity, String bundle, String id) {
                  FacesContext facesContext = this.getFacesContext();
                  Locale locale = facesContext.getExternalContext().getRequestLocale();
                         
                  String message = MessageFactory.getLocalizedMessage(bundle, key, args, locale);
                  FacesMessage facesMessage = new FacesMessage(severity, message, "");
                  facesContext.addMessage(id, facesMessage);
              }

          • 3. Re: a4j:commandButton makes a full page reload RichFaces 3.3.3 CR1
            Ilya Shaikovsky Master
            return controllerBean.getForward(); - chage to return null; as you not need to navigate.
            • 4. Re: a4j:commandButton makes a full page reload RichFaces 3.3.3 CR1
              Cesar Correia Newbie

              Thanks Ilya, it woks now!

               

              Your hint solved another problem I was having here, which was the  duplication of object IDs in some ajax calls.

              • 5. Re: a4j:commandButton makes a full page reload RichFaces 3.3.3 CR1
                warrior87.it Newbie

                Hi  illya..

                 

                I am using a4j:CommandButton...i want to show one value in popuppanel ...the value is in grid...

                 

                so i am call the action by giving the value ..and give it to the poupup panel ...which was highlighted.....

                 

                but the value is not reveived in the popup panel..

                 

                after refreshing the page...and again click the link only it will giving the value...

                 

                so..how to get the value with out refreshing the page ..by using a4j:commandButton

                 

                 

                 

                <rich:dataTable value="#{spiffProduct.productList}" var="c" styleClass="order-table" id="prodList" rows="100">                        

                                    <h:column>

                                        <f:facet name="header">

                                            #{spiff['product_incen_amt']}

                                        </f:facet>

                                        #{c.incenAmount}

                                    </h:column>

                                    <h:column>

                                        <f:facet name="header">

                                            #{spiff['product_status']}

                                        </f:facet>

                                        <a4j:commandLink value="#{c.incenStatus}" action="#{spiffProduct.viewpopup(c.invDetId,c.styleNo)}" reRender="popup1" oncomplete="#{rich:component('popup1')}.show(); return false;">                      

                                            

                                        </a4j:commandLink>

                                       

                                    </h:column>

                                </rich:dataTable>

                 

                 

                          <rich:popupPanel id="popup1" domElementAttachment="form" width="400" height="230" resizeable="true" modal="true" autosized="false">

                                                    <f:facet name="header">

                                                        <h:panelGroup>

                                                            <h:outputText value="#{spiff['product_style_no']}"></h:outputText>

                                                            :

                                                           #{spiffProduct.hidStyle}

                                                        </h:panelGroup>

                 

                                                    </f:facet>

                                                    <f:facet name="controls">

                                                        <h:panelGroup style="padding-right:4px">                       

                                                            <h:commandLink value="X" onclick="#{rich:component('popup1')}.hide(); return false;" ></h:commandLink>                                             

                                                        </h:panelGroup>

                                                    </f:facet>

                </rich:popupPanel>

                 

                 

                 

                Action Class:

                 

                public List<SpiffProduct> getProductList()

                    {  

                        return spiffProductBO.getProductDetails();       

                    }   

                   

                    public String  viewpopup(long invdet,String styleno)

                    {

                              setHidStyle(styleno);

                              setHidInvDetId(invdet);

                                         return "";    

                    }

                • 6. Re: a4j:commandButton makes a full page reload RichFaces 3.3.3 CR1
                  warrior87.it Newbie

                  hi frnds..

                   

                  i got the answer...i used the render attribute in a4jcommandbutton ...i got the value