Tree component + Seam 1.1 example wanted
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
Tree component + Seam 1.1 example wanted  XML
Forum Index -> JBoss Seam Integration
Author Message
vkovalyuk

Joined: 15/12/2006 00:00:00
Messages: 4
Offline


Could anybody share the example of use tree component in Seam contextual environment?

I has been struggling with different combinations of settings in web.xml, faces-config.xml etc and hasn't succeeded.

Appreciate your help in advance.
atzbert

Joined: 11/12/2006 00:00:00
Messages: 13
Offline


i basically followed an example. my backing bean builds the model by creating treenodes from my menunodes. i guess this is pretty straight forwar and no issue here:
Code:
 import com.icesoft.faces.component.tree.IceUserObject;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.DefaultMutableTreeNode;
 import org.jboss.seam.annotations.*;
 import org.jboss.seam.log.*;
 import java.util.*;
 /**
  * <p/>
  * A basic backing bean for a ice:tree component.  The only instance variable
  * needed is a DefaultTreeModel Object which is bound to the icefaces tree
  * component in the jspx code.</p>
  * <p/>
  * The tree created by this backing bean is used to control the selected
  * panel in a ice:panelStack.
  * </p>
  */
 @Name("tree")
 public class TreeBean {
 
     @Logger
     Log log;
     // tree default model, used as a value for the tree component
     private DefaultTreeModel model;
 
     // default node icons for xp thme
     private static final String XP_BRANCH_CONTRACTED_ICON = "./xmlhttp/css/xp/css-images/tree_folder_open.gif";
     private static final String XP_BRANCH_EXPANDED_ICON = "./xmlhttp/css/xp/css-images/tree_folder_close.gif";
     private static final String XP_BRANCH_LEAF_ICON = "./xmlhttp/css/xp/css-images/tree_document.gif";
 
     public TreeBean() {
 
         MenuNode node = MenuBean.MENU;
         // create root node with its children expanded
         DefaultMutableTreeNode rootTreeNode = new DefaultMutableTreeNode();
         IceUserObject rootObject = new IceUserObject(rootTreeNode);
         rootObject.setText(node.getLabel());
         rootObject.setExpanded(true);
         rootObject.setBranchContractedIcon(XP_BRANCH_CONTRACTED_ICON);
         rootObject.setBranchExpandedIcon(XP_BRANCH_EXPANDED_ICON);
         rootObject.setLeafIcon(XP_BRANCH_LEAF_ICON);
         rootTreeNode.setUserObject(rootObject);
 
         // model is accessed by by the ice:tree component
         model = new DefaultTreeModel(rootTreeNode);
 
         fillSubbranch(node, rootTreeNode);
     }
 
     private void fillSubbranch(MenuNode node, DefaultMutableTreeNode rootTreeNode) {
         List<MenuNode> nodes = node.getMenuEntries();
         if (nodes != null) {
             for (MenuNode menuNode : nodes) {
                 DefaultMutableTreeNode branchNode = new DefaultMutableTreeNode();
                 IceUserObject branchObject = new IceUserObject(branchNode);
                 branchObject.setText(menuNode.getLabel());
                 branchObject.setBranchContractedIcon(XP_BRANCH_CONTRACTED_ICON);
                 branchObject.setBranchExpandedIcon(XP_BRANCH_EXPANDED_ICON);
                 branchObject.setLeafIcon(XP_BRANCH_LEAF_ICON);
                 branchNode.setUserObject(branchObject);
                 rootTreeNode.add(branchNode);
                 if(menuNode.getMenuEntries() != null && !menuNode.getMenuEntries().isEmpty()){
                     fillSubbranch(menuNode, branchNode);
                 }
             }
         }
     }
 
     /**
      * Gets the tree's default model.
      *
      * @return tree model.
      */
     public DefaultTreeModel getModel() {
         return model;
     }
 }
 
 


my htmlx looks like this:
Code:
 ...
         <f:subview id="west">
             <ui:insert name="west">
                 <ice:form>
                 <ice:tree id="tree"
                           value="#{tree.model}"
                           var="item"
                           hideRootNode="false"
                           hideNavigation="false"
                           imageDir="./xmlhttp/css/xp/css-images/">
                     <ice:treeNode>
                         <f:facet name="icon">
                             <ice:panelGroup style="display: inline">
                                 <h:graphicImage value="#{item.userObject.icon}"/>
                             </ice:panelGroup>
                         </f:facet>
                         <f:facet name="content">
                             <ice:panelGroup style="display: inline">
                                 <ice:commandLink
                                         value="#{item.userObject.text}"/>
                             </ice:panelGroup>
                         </f:facet>
                     </ice:treeNode>
                 </ice:tree>
                 </ice:form>
             </ui:insert>
         </f:subview>
 ...
 


One very important thing for me was to enable the jboss-webloader:

Try using the JBossWebLoader setting. Check out this posting.  



That was it. It's running like a charm.
david.lgj

Joined: 07/03/2007 00:00:00
Messages: 1
Offline




Has anyone tried this with seam 1.2 and icefaces 1.5.3?
Can't get it to work, the tree can collapse but it doesn't expand again.

Is there something else you need to do? Can you post your web.xml?

Thanks

/david
 
Forum Index -> JBoss Seam Integration
Go to:   
Powered by JForum 2.1.7ice © JForum Team