You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Michal Glowacki <mg...@projektpro.internetdsl.pl> on 2006/10/09 13:46:06 UTC

Tree2 value loaded twice during page load

Hi

I've got a tree2 component with backing bean set as value in jsp. What I discovered is that it's loaded twice during page load. I believe it has rather something to do with jsp than with myfaces but.... Can anyone help?

This is the fragment of jsp:


<t:tree2 binding="#{remote_data$RemoteMatchlists.categoryTree}" clientSideToggle="true" id="categoryTree"
                                            imageLocation="../category/images/" javascriptLocation="../category/js/"
                                            value="#{remote_data$RemoteMatchlists.categoryTreeModel}" var="node" varNodeToggler="t">
                                            <f:facet name="foo-folder">
                                                <h:panelGroup>
                                                    <f:facet name="expand">
                                                        <t:graphicImage border="0" rendered="#{t.nodeExpanded}" value="../category/images/yellow-folder-open.png"/>
                                                    </f:facet>
                                                    <f:facet name="collapse">
                                                        <t:graphicImage border="0" rendered="#{!t.nodeExpanded}" value="../category/images/yellow-folder-closed.png"/>
                                                    </f:facet>
                                                    <h:outputText styleClass="nodeFolder" value="#{node.description}"/>
                                                </h:panelGroup>
                                            </f:facet>
                                            <f:facet name="document">
                                                <h:panelGroup>
                                                    <t:graphicImage border="0" value="../category/images/document.png"/>
                                                    <h:commandLink immediate="false" styleClass="#{t.nodeSelected ? 'documentSelected':'document'}">
                                                        <h:outputText value="#{node.description}"/>
                                                    </h:commandLink>
                                                    <f:param name="docNum" value="#{node.identifier}"/>
                                                </h:panelGroup>
                                            </f:facet>
                                        </t:tree2>
 


and page bean (I'm using Creator2):


 public org.apache.myfaces.custom.tree2.TreeNode getCategoryTreeModel() {
        return adminconsole.category.CategoryData.getTreeModel();
    }


It simply calls backing bean method which creates tree from db data.

Thanks in advance for any help.
Michal 

Re: Tree2 value loaded twice during page load

Posted by Andrew Robinson <an...@gmail.com>.
Do not create new classes in a get property method. EL expressions are
often evaluated more than once. This is often do to other phases,
checking the rendered property, etc.

Load your tree model when the page is loaded and not in the getter
method. Either that or create a request-scope attribute to hold the
tree model so that it is only created once per request.

On 10/9/06, Michal Glowacki <mg...@projektpro.internetdsl.pl> wrote:
>
>
>
> Hi
>
> I've got a tree2 component with backing bean set as value in jsp. What I
> discovered is that it's loaded twice during page load. I believe it has
> rather something to do with jsp than with myfaces but.... Can anyone help?
>
> This is the fragment of jsp:
>
> <t:tree2
> binding="#{remote_data$RemoteMatchlists.categoryTree}"
> clientSideToggle="true" id="categoryTree"
>  imageLocation="../category/images/" javascriptLocation="../category/js/"
>  value="#{remote_data$RemoteMatchlists.categoryTreeModel}"
> var="node" varNodeToggler="t">
>  <f:facet name="foo-folder">
>  <h:panelGroup>
>  <f:facet name="expand">
>  <t:graphicImage border="0" rendered="#{t.nodeExpanded}"
> value="../category/images/yellow-folder-open.png"/>
>  </f:facet>
>  <f:facet name="collapse">
>  <t:graphicImage border="0" rendered="#{!t.nodeExpanded}"
> value="../category/images/yellow-folder-closed.png"/>
>  </f:facet>
>  <h:outputText styleClass="nodeFolder" value="#{node.description}"/>
>  </h:panelGroup>
>  </f:facet>
>  <f:facet name="document">
>  <h:panelGroup>
>  <t:graphicImage border="0"
> value="../category/images/document.png"/>
>  <h:commandLink immediate="false" styleClass="#{t.nodeSelected ?
> 'documentSelected':'document'}">
>  <h:outputText value="#{node.description}"/>
>  </h:commandLink>
>  <f:param name="docNum" value="#{node.identifier}"/>
>  </h:panelGroup>
>  </f:facet>
>  </t:tree2>
>
>
>
>
> and page bean (I'm using Creator2):
>
>  public org.apache.myfaces.custom.tree2.TreeNode
> getCategoryTreeModel() {
>  return adminconsole.category.CategoryData.getTreeModel();
>  }
>
>
>
> It simply calls backing bean method which creates tree from db data.
>
> Thanks in advance for any help.
> Michal