2 Replies Latest reply on Apr 2, 2007 11:34 AM by Ilya Shaikovsky

    a4j Speed

    Konstantin Kauz Novice

      I don't now why, but i like not now, why this code is so slowly. i tested it wich different browser:


      VIEW:


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:rich="http://richfaces.ajax4jsf.org/rich"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
       template="templates/temp.xhtml">
      
       <ui:define name="head_links">
      
      
      
       </ui:define>
      
       <ui:define name="main">
      
       <s:div style="margin-top:20px;float:left;">
       <a4j:region>
       <h:form>
      
       <rich:tree nodeSelectListener="#{tmanager.selectNode}" reRender="mns" immediate="true" ajaxSubmitSelection="true" style="width:300px;height:150px;" value="#{tmanager.root}" var="item" nodeFace="root">
       <rich:treeNode type="root">
       <h:outputText value="#{item.type}" />
       </rich:treeNode>
       <rich:treeNode type="item" >
      
       <h:outputText value="#{item.name}" />
       </rich:treeNode>
       </rich:tree>
      
       </h:form>
       </a4j:region>
       </s:div>
      
      
       <h:panelGroup id="mns" style="margin-top:20px;float:left;">
       <h:panelGroup id="cl1" rendered="#{tmanager.showPart == 1}">
       <ui:include src ="/filliale.xhtml" />
       </h:panelGroup>
       <h:panelGroup id="cl2" rendered="#{tmanager.showPart == 2}">
       <ui:include src ="/nfilliale.xhtml" />
       </h:panelGroup>
      
       <h:panelGroup id="cl3" rendered="#{tmanager.showPart == 3}">
       <ui:include src ="/pedit.xhtml" />
       </h:panelGroup>
      
       <h:panelGroup id="cl4" rendered="#{tmanager.showPart == 4}">
       <ui:include src ="/fabmodel.xhtml" />
      
       </h:panelGroup>
      
       <h:panelGroup id="cl5" rendered="#{tmanager.showPart == 5}">
       <ui:include src ="/nmodel.xhtml" />
      
       </h:panelGroup>
      
       <h:panelGroup id="cl6" rendered="#{tmanager.showPart == 6}">
       <ui:include src ="/hmodel.xhtml" />
       </h:panelGroup>
       <h:panelGroup id="cl7" rendered="#{tmanager.showPart == 7}">
       <a4j:include viewId="/firstfr.xhtml" />
       </h:panelGroup>
      
       <h:panelGroup id="cl8" rendered="#{tmanager.showPart == 8}">
       <rich:panel>
      
       <a4j:include viewId="/fahrzeug.xhtml" />
       </rich:panel>
       </h:panelGroup>
       </h:panelGroup>
      
      
      
      
       </ui:define>
      </ui:composition>



      VIEW for include (<ui:include src ="/filliale.xhtml" /> ):


      <s:div xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
      
       <a4j:region>
       <h:form>
      
      
       <h:panelGrid column="2">
       <h:outputText value="Fabrikat" />
       <s:decorate>
       <h:selectOneMenu value="#{hersteller}" required="true">
       <s:convertEntity />
       <s:selectItems value="#{allHer.resultList}" var="her" label="#{her.bezeichnung}" noSelectionLabel="Bitte waehlen..."/>
       </h:selectOneMenu>
       </s:decorate>
      
       <h:outputText value="Modell" />
       <h:inputText id="mdl" value="#{kfzmodel.bezeichnung}" size="15" required="true" > <s:validate/></h:inputText>
       <a4j:commandLink action="#{hmodel.saveMod}" reRender="msg_vl" value="Speichern" />
       </h:panelGrid>
       </h:form>
       </a4j:region>
      </s:div>
      



      Session Bean:


      package kk.rentform.session;
      
      import java.util.Iterator;
      import java.util.List;
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.faces.event.AbortProcessingException;
      import javax.faces.event.ActionEvent;
      import org.jboss.seam.ScopeType;
      
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.richfaces.component.TreeNode;
      import org.richfaces.component.events.NodeSelectedEvent;
      
      import kk.rentform.entity.Treeroot;
      import org.richfaces.component.html.HtmlTree;
      
      /**
       *
       * @author kostja
       */
      
      @Stateful
      @Name("tmanager")
      @Scope(ScopeType.SESSION)
      public class Treemanager implements TreemanagerInterface{
       private Treeroot root;
      
       private int showPart = 0;
      
       @Remove
       @Destroy
       public void destroy() {
      
       }
      
       public void selectNode(NodeSelectedEvent event){
       HtmlTree tree = (HtmlTree)event.getComponent();
       Object rowData = tree.getRowData();
       String select = rowData.toString();
      
       if (select.equals("Filliale bearbeiten")){
       showPart = 1;
       }else if (select.equals("Neue Filliale")){
       showPart = 2;
       }else if (select.equals("Persoenliche Daten")){
       showPart = 3;
       }else if (select.equals("Neues Fabrikat")){
       showPart = 4;
       }else if (select.equals("Neues Modell")){
       showPart = 5;
       }else if (select.equals("Fabrikat/Modell bearbeiten")){
       showPart = 6;
       }else if (select.equals("Neues Fahrzeug")){
       showPart = 7;
       }else if (select.equals("Fahrzeug bearbeiten")){
       showPart = 8;
       }
      
      
      
      
       }
      
      
      
       public void setRoot(kk.rentform.entity.Treeroot root) {
       this.root = root;
       }
      
       public kk.rentform.entity.Treeroot getRoot() {
       if (root == null)
       init();
      
       return root;
       }
      
       public Object getData() {
       if (root == null)
       init();
      
       return root;
       }
      
       public int getShowPart() {
       return showPart;
       }
      
       public void setShowPart(int showPart) {
       this.showPart = showPart;
       }
      
      
      
       private void init() {
      
       this.root = new Treeroot();
       this.root.setType("root");
       this.root.setName("root");
       this.root.setParent(null);
      
      
       /*
       * Items
       */
      
      
      
      
       // Neue Filliale
      
       Treeroot item1 = new Treeroot();
       item1.setType("item");
       item1.setParent(this.root);
       item1.setId(1);
       this.root.addChild(1,item1);
       item1.setName("Neue Filliale");
      
      
       // Filliale bearbeiten
      
       Treeroot item2 = new Treeroot();
       item2.setType("item");
       item2.setParent(this.root);
       item2.setId(2);
       this.root.addChild(2,item2);
      
       item2.setName("Filliale bearbeiten");
      
       // Persoenliche Daten
      
       Treeroot item = new Treeroot();
       item.setType("item");
       item.setParent(this.root);
       item.setId(0);
       this.root.addChild(0,item);
      
       item.setName("Persoenliche Daten");
      
       // Fabrkat
      
       Treeroot item3 = new Treeroot();
       item3.setType("item");
       item3.setParent(this.root);
       item3.setId(3);
       this.root.addChild(3,item3);
       item3.setName("Neues Fabrikat");
      
      
       //Modell
      
       Treeroot item5 = new Treeroot();
       item5.setType("item");
       item5.setParent(this.root);
       item5.setId(5);
       this.root.addChild(5,item5);
       item5.setName("Neues Modell");
      
       // Fabrkat bearbeiten
      
       Treeroot item4 = new Treeroot();
       item4.setType("item");
       item4.setParent(this.root);
       item4.setId(4);
       this.root.addChild(4,item4);
       item4.setName("Fabrikat/Modell bearbeiten");
      
       // Neues Fahrzeug
      
       Treeroot item6 = new Treeroot();
       item6.setType("item");
       item6.setParent(this.root);
       item6.setId(6);
       this.root.addChild(6,item6);
       item6.setName("Neues Fahrzeug");
      
       // Fahrzeug bearbeiten
      
       Treeroot item7 = new Treeroot();
       item7.setType("item");
       item7.setParent(this.root);
       item7.setId(7);
       this.root.addChild(7,item7);
       item7.setName("Fahrzeug bearbeiten");
      
       }
      
      
      }



      Some request take several seconds, also locally.
      Whitout a4j is the speed good.

      I use JBoss AP 4.0.5 + Seam last release.