Java学习

java,spring,structs,hibernate,jsf,ireport,jfreechart,jasperreport,tomcat,jboss -----本博客已经搬家了,新的地址是 http://www.javaly.cn 如果有对文章有任何疑问或者有任何不懂的地方,欢迎到www.javaly.cn (Java乐园)指出,我会尽力帮助解决。一起进步

 

tomahawk JSF组件扩展组件(三)

tomahawk JSF组件扩展组件(三)

关键字: jsf

<t:jsValueChangeListener>组件:

Java代码 复制代码
  1. <h:panelGrid columns="2">  
  2.         <h:outputLabel for="text1" value="Text:"/>  
  3.         <h:inputText id="text1">  
  4.             <t:jsValueChangeListener for="text2" property="value" expressionValue="($srcElem.value=='yes')?'true':'false'" />  
  5.             <t:jsValueChangeListener for="text3" property="value" expressionValue="$srcElem.value" />  
  6.             <t:jsValueChangeListener for="text4" expressionValue="$destElem.innerHTML = $srcElem.value" />  
  7.             <t:jsValueChangeListener for="text5" expressionValue="($srcElem.value=='hide')?$destElem.style.display='none':$destElem.style.display='inline'" />  
  8.             <t:jsValueSet name="countryMap" value="#{countryList.countryMap}"/>  
  9.             <t:jsValueChangeListener for="text6" expressionValue="$destElem.innerHTML = countryMap[$srcElem.value]" />  
  10.         </h:inputText>  
  11.         <h:inputText id="text2"/>  
  12.         <h:inputText id="text3"/>  
  13.         <h:panelGroup id="text4" />  
  14.         <h:panelGroup id="text5" >  
  15.             <h:outputText value="Hide me - enter hide in first input-field."/>  
  16.         </h:panelGroup>  
  17.         <h:panelGroup id="text6" >  
  18.             <h:outputText value="Countryname - enter ISO Code in first input-field (e.g. AT)"/>  
  19.         </h:panelGroup>  
  20.         <h:panelGroup/>  
  21.         <h:selectOneMenu id="selone_menu_colors" value="red" styleClass="selectOneMenu">  
  22.             <f:selectItem itemValue="" itemLabel="#{example_messages['empty_selitem']}" />  
  23.             <f:selectItems value="#{carconf.colors}" />  
  24.             <t:jsValueChangeListener for="selone_menu_subcolors" expressionValue="($srcElem.options[$srcElem.selectedIndex].value=='color_black')?$destElem.style.display='inline':$destElem.style.display='none';"/>  
  25.         </h:selectOneMenu>  
  26.         <h:inputText id="selone_menu_subcolors"/>  
  27. </h:panelGrid>  

<t:inputDate>组件的使用:

<t:inputDate id="date3" value="#{date3}" type="both"/>

type属性可以是time或both等...

<t:dataList>组件:

Java代码 复制代码
  1. <t:dataList id="data3"  
  2.         styleClass="standardList"  
  3.         var="country"  
  4.         value="#{countryList.countries}"  
  5.         layout="orderedList">  
  6.         <h:inputText value="#{country.name}" />  
  7. </t:dataList>  

 

<t:tree>组件:

Java代码 复制代码
  1. <%  
  2.    if (pageContext.getAttribute("treeModel", PageContext.SESSION_SCOPE) == null) {  
  3.       DefaultMutableTreeNode root = new DefaultMutableTreeNode("XY");  
  4.       DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");  
  5.       root.insert(a);  
  6.       DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");  
  7.       root.insert(b);  
  8.       DefaultMutableTreeNode c = new DefaultMutableTreeNode("C");  
  9.       root.insert(c);  
  10.   
  11.       DefaultMutableTreeNode node = new DefaultMutableTreeNode("a1");  
  12.       a.insert(node);  
  13.       node = new DefaultMutableTreeNode("a2 ");  
  14.       a.insert(node);  
  15.       node = new DefaultMutableTreeNode("b ");  
  16.       b.insert(node);  
  17.   
  18.       a = node;  
  19.       node = new DefaultMutableTreeNode("x1");  
  20.       a.insert(node);  
  21.       node = new DefaultMutableTreeNode("x2");  
  22.       a.insert(node);  
  23.   
  24.       pageContext.setAttribute("treeModel"new DefaultTreeModel(root), PageContext.SESSION_SCOPE);  
  25.    }  
  26. %>  
  27.   
  28. <f:view>  
  29.   
  30.     <t:tree id="tree" value="#{treeModel}"  
  31.         styleClass="tree"  
  32.         nodeClass="treenode"  
  33.         selectedNodeClass="treenodeSelected"  
  34.         expandRoot="true">  
  35.     </t:tree>  
  36.   
  37. </f:view>  

 treeTable:

Java代码 复制代码
  1. <t:tree id="tree" value="#{treeTable.treeModel}"  
  2.                     var="treeItem"  
  3.                     styleClass="tree"  
  4.                 nodeClass="treenode"  
  5.                 headerClass="treeHeader"  
  6.                 footerClass="treeFooter"  
  7.             rowClasses="a, b"  
  8.             columnClasses="col1, col2"  
  9.                 selectedNodeClass="treenodeSelected"  
  10.                 expandRoot="true">  
  11.             <h:column>  
  12.                     <f:facet name="header">  
  13.                     <h:outputText value="Header 1" />  
  14.             </f:facet>  
  15.             <h:outputText value="#{treeItem.isoCode}" />  
  16.         </h:column>  
  17.             <t:treeColumn>  
  18.                     <f:facet name="header">  
  19.                     <h:outputText value="Header 2" />  
  20.             </f:facet>  
  21.                     <h:outputText value="#{treeItem.name}" />  
  22.             </t:treeColumn>  
  23.             <h:column>  
  24.                     <f:facet name="header">  
  25.                     <h:outputText value="Header 3" />  
  26.             </f:facet>  
  27.                     <h:outputText value="#{treeItem.description}" />  
  28.         </h:column>  
  29.         <f:facet name="footer">  
  30.             <h:outputText value="Footer" />  
  31.         </f:facet>  
  32. </t:tree>  

 treeTable.java:

Java代码 复制代码
  1. public TreeTable()  
  2.     {  
  3.         DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TreeItem(1"XY""9001""XY 9001"));  
  4.         DefaultMutableTreeNode a = new DefaultMutableTreeNode(new TreeItem(2"A""9001""A 9001"));  
  5.         root.insert(a);  
  6.         DefaultMutableTreeNode b = new DefaultMutableTreeNode(new TreeItem(3"B""9001""B 9001"));  
  7.         root.insert(b);  
  8.         DefaultMutableTreeNode c = new DefaultMutableTreeNode(new TreeItem(4"C""9001""C 9001"));  
  9.         root.insert(c);  
  10.         DefaultMutableTreeNode node = new DefaultMutableTreeNode(new TreeItem(5"a1""9002""a1 9002"));  
  11.         a.insert(node);  
  12.         node = new DefaultMutableTreeNode(new TreeItem(6"a2""9002""a2 9002"));  
  13.         a.insert(node);  
  14.         node = new DefaultMutableTreeNode(new TreeItem(7"a3""9002""a3 9002"));  
  15.         a.insert(node);  
  16.         node = new DefaultMutableTreeNode(new TreeItem(8"b""9002""b 9002"));  
  17.         b.insert(node);  
  18.         a = node;  
  19.         node = new DefaultMutableTreeNode(new TreeItem(9"x1""9003""x1 9003"));  
  20.         a.insert(node);  
  21.         node = new DefaultMutableTreeNode(new TreeItem(9"x2""9003""x2 9003"));  
  22.         a.insert(node);  
  23.         this.treeModel = new DefaultTreeModel(root);  
  24.     }  
  25.     /** 
  26.      * @return Returns the treeModel. 
  27.      */  
  28.     public DefaultTreeModel getTreeModel()  
  29.     {  
  30.         return treeModel;  
  31.     }  

<t:tree2>组件:

Java代码 复制代码
  1. <!-- clientSideToggle="false"指是否一次过从服务器下载结点信息.showRootNode="false"指是否显示根结点 -->  
  2. <t:tree2 id="serverTree" value="#{treeBacker.treeData}" var="node" varNodeToggler="t" clientSideToggle="false" showRootNode="false">    
  3.         <f:facet name="person">  
  4.             <h:panelGroup>  
  5.                 <t:graphicImage value="/images/yellow-folder-open.png" rendered="#{t.nodeExpanded}" border="0"/>  
  6.                 <t:graphicImage value="/images/yellow-folder-closed.png" rendered="#{!t.nodeExpanded}" border="0"/>  
  7.                 <h:outputText value="#{node.description}" styleClass="nodeFolder"/>  
  8.             </h:panelGroup>  
  9.         </f:facet>  
  10.         <f:facet name="foo-folder">  
  11.             <h:panelGroup>  
  12.                 <t:graphicImage value="/images/yellow-folder-open.png" rendered="#{t.nodeExpanded}" border="0"/>  
  13.                 <t:graphicImage value="/images/yellow-folder-closed.png" rendered="#{!t.nodeExpanded}" border="0"/>  
  14.                 <h:outputText value="#{node.description}" styleClass="nodeFolder"/>  
  15.                 <h:outputText value=" (#{node.childCount})" styleClass="childCount" rendered="#{!empty node.children}"/>  
  16.             </h:panelGroup>  
  17.         </f:facet>  
  18.         <f:facet name="bar-folder">  
  19.             <h:panelGroup>  
  20.                 <t:graphicImage value="/images/blue-folder-open.gif" rendered="#{t.nodeExpanded}" border="0"/>  
  21.                 <t:graphicImage value="/images/blue-folder-closed.png" rendered="#{!t.nodeExpanded}" border="0"/>  
  22.                 <h:outputText value="#{node.description}" styleClass="nodeFolder"/>  
  23.                 <h:outputText value=" (#{node.childCount})" styleClass="childCount" rendered="#{!empty node.children}"/>  
  24.             </h:panelGroup>  
  25.         </f:facet>  
  26.         <f:facet name="document">  
  27.             <h:panelGroup>  
  28.                 <h:commandLink immediate="true" styleClass="#{t.nodeSelected ? 'documentSelected':'document'}" actionListener="#{t.setNodeSelected}">  
  29.                     <t:graphicImage value="/images/document.png" border="0"/>  
  30.                     <h:outputText value="#{node.description}"/>  
  31.                     <f:param name="docNum" value="#{node.identifier}"/>  
  32.                 </h:commandLink>  
  33.             </h:panelGroup>  
  34.         </f:facet>  
  35.     </t:tree2>  

 

也可以使用<h:panelGrid>组件做为<f:fact>的子组件,并设置cellpadding和cellspacing属性,以取得好有布局.

Java代码 复制代码
  1. <f:facet name="foo-folder">  
  2.                 <h:panelGrid id="b" columns="2" cellpadding="2" cellspacing="0">  
  3.                     <t:graphicImage value="/images/yellow-folder-open.png" rendered="#{t.nodeExpanded}" border="0"/>  
  4.                     <t:graphicImage value="/images/yellow-folder-closed.png" rendered="#{!t.nodeExpanded}" border="0"/>  
  5.                     <h:panelGroup>  
  6.                         <h:outputText value="#{node.description}" styleClass="nodeFolder"/>  
  7.                         <h:outputText value=" (#{node.childCount})" styleClass="childCount" rendered="#{!empty node.children}"/>  
  8.                     </h:panelGroup>  
  9.                 </h:panelGrid>  
  10. </f:facet>  

 treeData:

Java代码 复制代码
  1. public TreeNode getTreeData()  
  2.     {  
  3.         TreeNode treeData = new TreeNodeBase("foo-folder""Inbox"false);  
  4.         // construct a set of fake data (normally your data would come from a database)  
  5.         // populate Frank's portion of the tree  
  6.         TreeNodeBase personNode = new TreeNodeBase("person""Frank Foo"false);  
  7.         personNode.getChildren().add(new TreeNodeBase("foo-folder""Requires Foo"false));  
  8.         TreeNodeBase folderNode = new TreeNodeBase("foo-folder""Requires Foo Reviewer"false);  
  9.         folderNode.getChildren().add(new TreeNodeBase("document""X050001"true));  
  10.         folderNode.getChildren().add(new TreeNodeBase("document""X050002"true));  
  11.         folderNode.getChildren().add(new TreeNodeBase("document""X050003"true));  
  12.         personNode.getChildren().add(folderNode);  
  13.         personNode.getChildren().add(new TreeNodeBase("foo-folder""Requires Foo Recommendation"false));  
  14.         folderNode = new TreeNodeBase("foo-folder""Requires Foo Approval"false);  
  15.         folderNode.getChildren().add(new TreeNodeBase("document""J050001"true));  
  16.         folderNode.getChildren().add(new TreeNodeBase("document""J050002"true));  
  17.         folderNode.getChildren().add(new TreeNodeBase("document""J050003"true));  
  18.         folderNode.getChildren().add(new TreeNodeBase("document""E050011"true));  
  19.         folderNode.getChildren().add(new TreeNodeBase("document""R050002"true));  
  20.         folderNode.getChildren().add(new TreeNodeBase("document""C050003"true));  
  21.         personNode.getChildren().add(folderNode);  
  22.         folderNode = new TreeNodeBase("bar-folder""Requires Bar Processing"false);  
  23.         folderNode.getChildren().add(new TreeNodeBase("document""X050003"true));  
  24.         folderNode.getChildren().add(new TreeNodeBase("document""X050011"true));  
  25.         folderNode.getChildren().add(new TreeNodeBase("document""F050002"true));  
  26.         folderNode.getChildren().add(new TreeNodeBase("document""G050003"true));  
  27.         personNode.getChildren().add(folderNode);  
  28.         folderNode = new TreeNodeBase("bar-folder""Requires Bar Approval"false);  
  29.         folderNode.getChildren().add(new TreeNodeBase("document""J050006"true));  
  30.         folderNode.getChildren().add(new TreeNodeBase("document""J050007"true));  
  31.         personNode.getChildren().add(folderNode);  
  32.         treeData.getChildren().add(personNode);  
  33.         // populate Betty's portion of the tree  
  34.         personNode = new TreeNodeBase("person""Betty Bar"false);  
  35.         personNode.getChildren().add(new TreeNodeBase("foo-folder""Requires Foo"false));  
  36.         folderNode = new TreeNodeBase("foo-folder""Requires Foo Reviewer"false);  
  37.         folderNode.getChildren().add(new TreeNodeBase("document""X012000"true));  
  38.         folderNode.getChildren().add(new TreeNodeBase("document""X013000"true));  
  39.         folderNode.getChildren().add(new TreeNodeBase("document""X014000"true));  
  40.         personNode.getChildren().add(folderNode);  
  41.         folderNode = new TreeNodeBase("foo-folder""Requires Foo Recommendation"false);  
  42.         folderNode.getChildren().add(new TreeNodeBase("document""J010026"true));  
  43.         folderNode.getChildren().add(new TreeNodeBase("document""J020002"true));  
  44.         folderNode.getChildren().add(new TreeNodeBase("document""J030103"true));  
  45.         folderNode.getChildren().add(new TreeNodeBase("document""E030214"true));  
  46.         folderNode.getChildren().add(new TreeNodeBase("document""R020444"true));  
  47.         folderNode.getChildren().add(new TreeNodeBase("document""C010000"true));  
  48.         personNode.getChildren().add(folderNode);  
  49.         personNode.getChildren().add(new TreeNodeBase("foo-folder""Requires Foo Approval"false));  
  50.         folderNode = new TreeNodeBase("bar-folder""Requires Bar Processing"false);  
  51.         folderNode.getChildren().add(new TreeNodeBase("document""T052003"true));  
  52.         folderNode.getChildren().add(new TreeNodeBase("document""T020011"true));  
  53.         personNode.getChildren().add(folderNode);  
  54.         folderNode = new TreeNodeBase("bar-folder""Requires Bar Approval"false);  
  55.         folderNode.getChildren().add(new TreeNodeBase("document""J010002"true));  
  56.         folderNode.getChildren().add(new TreeNodeBase("document""J030047"true));  
  57.         folderNode.getChildren().add(new TreeNodeBase("document""F030112"true));  
  58.         personNode.getChildren().add(folderNode);  
  59.         treeData.getChildren().add(personNode);  
  60.         return treeData;  
  61.     }  

<t:collapsiblePanel>组件:

Java代码 复制代码
  1. <t:collapsiblePanel collapsed="#{collapsiblePanelBean.collapsed}" value="testTitle">  
  2.         <h:panelGrid>  
  3.             <h:outputText value="Test"/>  
  4.             <h:inputText value="test2"/>  
  5.             <t:inputCalendar value="" renderAsPopup="true"/>  
  6.         </h:panelGrid>  
  7. </t:collapsiblePanel>  

posted on 2008-09-01 13:15 找个美女做老婆 阅读(422) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

公告

本blog已经搬到新家了, 新家:www.javaly.cn
 http://www.javaly.cn

常用链接

留言簿(6)

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜