rich:componentControl 标签和rich:ModolPanel标签
示例:
<rich:modalPanel id="panel" width="350" height="100">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Modal Panel"></h:outputText>
</h:panelGroup>
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:graphicImage value="/images/modal/close.png" style="cursor:pointer" id="hidelink"/>
<rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
</h:panelGroup>
</f:facet>
<h:outputText value="This panel is called using Component Control Component"></h:outputText>
<br/>
<h:outputText value="Closure link (X) works also through Component Control"></h:outputText>
</rich:modalPanel>
<h:outputLink value="#" id="link">
Show Modal Panel
<rich:componentControl for="panel" attachTo="link" operation="show" event="onclick"/>
</h:outputLink>
ModolPanel效果:当点击页面中的某元素时,弹出一个类似关机效果的面板。
inputNumberSlider 输入数字滑竿
Panel:
带标题栏的panel
它可以通过h:fecter标签指定标题和底部。
PanelBar:
效果说明:该控件可以实现多个面板的折叠效果,在每个面板的数据区域可以放入任何JSF标签。并且面板的标题可以设定。
<rich:panelBar height="400" width="500">
<rich:panelBarItem
label="Write your own custom rich components with built-in AJAX support">
Component Development Kit (CDK) is a design-time extension for Ajax4jsf. The CDK includes
</rich:panelBarItem>
<rich:panelBarItem
label="Package resources with the application's Java classes ">
In addition to its core, Ajax functionality of Ajax4jsf provides an advanced
support for the diff
</rich:panelBarItem>
<rich:panelBarItem label="Easily generate images on-the-fly">
Resource framework can generate images on-the-fly so that it becomes possible
to create images using the familiar approach of the Java graphic2D library.
</rich:panelBarItem>
</rich:panelBar>
PanelMenu标签:
<h:panelGrid columns="2" columnClasses="cols" width="100%">
<rich:panelMenu style="width:200px" mode="ajax"
iconExpandedGroup="disc" iconCollapsedGroup="disc"
iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
iconCollapsedTopGroup="chevronDown" iconCollapsedTopPosition="right" >
<rich:panelMenuGroup label="Group 1">
<rich:panelMenuItem label="Item 1.1" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 1.1"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 1.2" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 1.2"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 1.3" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 1.3"/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
<rich:panelMenuGroup label="Group 2">
<rich:panelMenuItem label="Item 2.1" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.1"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 2.2" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.2"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 2.3" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.3"/>
</rich:panelMenuItem>
<rich:panelMenuGroup label="Group 2.4">
<rich:panelMenuItem label="Item 2.4.1" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.4.1"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 2.4.2" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.4.2"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 2.4.3" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.4.3"/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
<rich:panelMenuItem label="Item 2.5" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.5"/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
<rich:panelMenuGroup label="Group 3">
<rich:panelMenuItem label="Item 3.1" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 3.1"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 3.2" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 3.2"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 3.3" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 3.3"/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
</rich:panelMenu>
<rich:panel bodyClass="rich-laguna-panel-no-header">
<a4j:outputPanel ajaxRendered="true">
<h:outputText value="#{panelMenu.current} selected" id="current"/>
</a4j:outputPanel>
</rich:panel>
</h:panelGrid>
progressBar标签 :
<h:form>
<a4j:outputPanel id="progressPanel">
<rich:progressBar value="#{progressBarBean.currentValue}"
interval="2000" label="#{progressBarBean.currentValue} %"
enabled="#{progressBarBean.enabled}" minValue="-1" maxValue="100"
reRenderAfterComplete="progressPanel">
<f:facet name="initial">
<br />
<h:outputText value="Process doesn't started yet" />
<a4j:commandButton action="#{progressBarBean.startProcess}"
value="Start Process" reRender="progressPanel"
rendered="#{progressBarBean.buttonRendered}"
style="margin: 9px 0px 5px;" />
</f:facet>
<f:facet name="complete">
<br />
<h:outputText value="Process Done" />
<a4j:commandButton action="#{progressBarBean.startProcess}"
value="Restart Process" reRender="progressPanel"
rendered="#{progressBarBean.buttonRendered}"
style="margin: 9px 0px 5px;" />
</f:facet>
</rich:progressBar>
</a4j:outputPanel>
</h:form>
Separator标签:
<p>This is default separator:</p>
<rich:separator/>
<p>This is tick 75% beveled separator aligned to the center:</p>
<rich:separator lineType="beveled" height="8" width="75%" align="center"/>
<p>Here is more examples of different line types:</p>
<rich:separator height="2" lineType="dotted"/><br/>
<rich:separator height="2" lineType="dashed"/><br/>
<rich:separator height="4" lineType="double"/><br/>
<rich:separator height="2" lineType="solid"/><br/>
simpleTogglePanel 标签:
<rich:simpleTogglePanel switchType="client" label="Add AJAX capability to existing JSF applications">
The framework is implemented by using a component library. The library
set Ajax functionality into existing pages, so there is no need to write
any JavaScript code or to replace existing components with new Ajax one.
Ajax4jsf enables page-wide Ajax support instead of the traditional
component-wide support and it gives the opportunity to define the event
on the page. An event invokes an Ajax request and areas of the page
which are synchronized with the JSF Component Tree after changing the
data on the server by Ajax request in accordance with events fired on
the client.
</rich:simpleTogglePanel>
解释:点击该panel的标题栏将隐藏、显示内容部分。其中的switchType为client将无刷新的隐藏显示内容部分。该控件的标题栏不能添加图片,样式不可以自己设定。
tablePanel标签:
<rich:tabPanel>
<rich:tab label="First">
Here is tab #1
</rich:tab>
<rich:tab label="Second">
Here is tab #2
</rich:tab>
<rich:tab label="Third">
Here is tab #3
</rich:tab>
</rich:tabPanel>
<br/><br/>
<p>Here is an example of tab panel switched in "ajax" style. Second tab is disabled.</p>
<rich:tabPanel switchType="ajax">
<rich:tab label="First">
Here is tab #1
</rich:tab>
<rich:tab label="Second" disabled="true">
Here is tab #2
</rich:tab>
<rich:tab label="Third">
Here is tab #3
</rich:tab>
</rich:tabPanel>
<br/><br/>
<p>Here is an example of tab panel switched completely on client.</p>
<rich:tabPanel switchType="client">
<rich:tab label="First">
Here is tab #1
</rich:tab>
<rich:tab label="Second">
Here is tab #2
</rich:tab>
<rich:tab label="Third">
Here is tab #3
</rich:tab>
</rich:tabPanel>
解释:tabPanel 的switchType有server client ajax三种。Server会产生页面的刷新,ajax会异步的刷新,client则不会跟服务器进行交互。
Tool Bar标签:
<style>
.barsearch {
height:14px;
width:100px;
}
.barsearchbutton {
border-width:1px;
background-color:#{a4jSkin.generalBackgroundColor};
}
</style>
<h:form>
<rich:toolBar height="34" itemSeparator="line">
<rich:toolBarGroup>
<h:graphicImage id="edit" value="/images/icons/edit.gif" />
<h:outputLabel value="Edit" for="edit" />
</rich:toolBarGroup>
<rich:toolBarGroup>
<h:graphicImage id="find" value="/images/icons/find.gif" />
<h:outputLabel value="Find" for="find" />
</rich:toolBarGroup>
<rich:toolBarGroup>
<h:graphicImage id="filter" value="/images/icons/filter.gif" />
<h:outputLabel value="Filter" for="filter" />
</rich:toolBarGroup>
<rich:toolBarGroup location="right">
<h:inputText styleClass="barsearch" />
<h:commandButton styleClass="barsearchbutton" onclick="return false;" value="Search" />
</rich:toolBarGroup>
</rich:toolBar>
</h:form>
ToolTip标签:
<style>
.tooltip {
background-color:#{richSkin.generalBackgroundColor};
border-width:3px;
padding:10px;
}
.tooltip-text {
width:350px;
height:80px;
cursor:arrow;
border-width:2px;
text-align:center;
display: table-cell;
vertical-align: middle;
}
.tooltipData {
font-weight: bold;
}
</style>
<h:panelGrid columns="2">
<rich:panel id="sample1" styleClass="tooltip-text" bodyClass="rich-laguna-panel-no-header">
<p>
Here you can see <b>default client-side</b> tool-tip
</p>
<rich:toolTip>
<span style="white-space:nowrap">
This tool-tip content was <strong>pre-rendered</strong> to the page.<br/>
The look of this tool-tip is 100% defined by skin.
</span>
</rich:toolTip>
</rich:panel>
<rich:panel id="sample2" styleClass="tooltip-text" bodyClass="rich-laguna-panel-no-header">
<p>
This tool-tip will <b>follow mouse</b>. Also this tool-tip has a <b>delay 0.5 sec</b>,
so be patient!
</p>
<rich:toolTip followMouse="true" direction="top-right" showDelay="500" styleClass="tooltip">
<span style="white-space:nowrap">
This tool-tip content also <strong>pre-rendered</strong> to the page.<br/>
However, the look of this tool-tip is customized<br/>
by styleClass attribute.
</span>
</rich:toolTip>
</rich:panel>
<h:form>
<rich:panel id="sample3" styleClass="tooltip-text" bodyClass="rich-laguna-panel-no-header">
<p>
This tool-tip rendered on server <b>in separate request</b>.
</p>
<rich:toolTip direction="top-right" mode="ajax" styleClass="tooltip" layout="block">
<f:facet name="defaultContent">
<strong>Wait...</strong>
</f:facet>
<span style="white-space:nowrap">This tool-tip content was <strong>rendered on server</strong>
</span>
<h:panelGrid columns="2">
<h:outputText style="white-space:nowrap" value="tooltips requested:" />
<h:outputText value="#{toolTipData.tooltipCounter}" styleClass="tooltipData" />
</h:panelGrid>
</rich:toolTip>
</rich:panel>
</h:form>
<h:form>
<rich:panel id="sample4" styleClass="tooltip-text" bodyClass="rich-laguna-panel-no-header">
<p>
This tool-tip will be <b>activated on mouse click</b>. It also has a <b>bottom-left</b> position.
</p>
<rich:toolTip showEvent="onclick" direction="bottom-left" mode="ajax" styleClass="tooltip" layout="block">
<f:facet name="defaultContent">
<strong>Wait...</strong>
</f:facet>
<span style="white-space:nowrap">This tool-tip content was <strong>rendered on server</strong><br/></span>
<h:panelGrid columns="2">
<h:outputText style="white-space:nowrap" value="tooltips requested:" />
<h:outputText value="#{toolTipData.tooltipCounter}" styleClass="tooltipData" />
</h:panelGrid>
</rich:toolTip>
</rich:panel>
</h:form>
</h:panelGrid>
Calendar标签:
右边控件绑定been层中的属性都是Calendar的一系列属性。
<style type="text/css">
.ecol1 { vertical-align: top; padding-right : 25px }
.ecol2 { vertical-align: top; border-left: #ACBECE 1px solid; padding-left : 10px }
.rich-calendar-tool-btn{
font-family: Arial, Verdana;
}
</style>
<h:form>
<h:panelGrid id="panel" columns="2" columnClasses="ecol1, ecol2">
<a4j:outputPanel id="calendar" layout="block">
<rich:calendar value="#{calendarBean.selectedDate}"
locale="#{calendarBean.locale}"
popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px" cellHeight="22px" style="width:200px"/>
</a4j:outputPanel>
<h:panelGrid columns="2">
<h:outputText value="Popup Mode:" />
<h:selectBooleanCheckbox value="#{calendarBean.popup}">
<a4j:support event="onclick" reRender="calendar"/>
</h:selectBooleanCheckbox>
<h:outputText value="Apply Button:" />
<h:selectBooleanCheckbox value="#{calendarBean.showApply}">
<a4j:support event="onclick" reRender="calendar"/>
</h:selectBooleanCheckbox>
<h:outputText value="Select Locale" />
<h:selectOneRadio value="en/US" valueChangeListener="#{calendarBean.selectLocale}">
<a4j:support event="onclick" reRender="calendar"/>
<f:selectItem itemLabel="US" itemValue="en/US"/>
<f:selectItem itemLabel="DE" itemValue="de/DE"/>
<f:selectItem itemLabel="FR" itemValue="fr/FR"/>
<f:selectItem itemLabel="RU" itemValue="ru/RU"/>
</h:selectOneRadio>
<h:outputText value="Select Date Pattern:"/>
<h:selectOneMenu value="#{calendarBean.pattern}">
<a4j:support event="onchange" reRender="calendar"/>
<f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy HH:mm"/>
<f:selectItem itemLabel="dd/M/yy hh:mm a" itemValue="dd/M/yy hh:mm a"/>
<f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y"/>
<f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"/>
</h:selectOneMenu>
</h:panelGrid>
</h:panelGrid>
</h:form>
comboBox 标签:
该控件可以实现google搜索框的效果,唯一不同的地方就是右边有一个向下的箭头。
File Upload控件:
说明:在建立的页面中发现不到该标签。
Inplace Input标签:
SuggestionBox标签:
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:form id="suggestionbox_form">
<p>
Suggestion Box will suggest you states capitals names. Comma and space could be used as suggestions separators."
</p>
<h:inputText value="#{capitalsBean.capital}" id="text" />
<rich:suggestionbox id="suggestionBoxId" for="text" tokens=",["
rules="#{suggestionBox.rules}"
suggestionAction="#{capitalsBean.autocomplete}" var="result"
fetchValue="#{result.name}" rows="#{suggestionBox.intRows}"
first="#{suggestionBox.intFirst}"
minChars="#{suggestionBox.minchars}"
shadowOpacity="#{suggestionBox.shadowOpacity}"
border="#{suggestionBox.border}" width="#{suggestionBox.width}"
height="#{suggestionBox.height}"
shadowDepth="#{suggestionBox.shadowDepth}"
cellpadding="#{suggestionBox.cellpadding}"
nothingLabel="No capitals found" columnClasses="center">
<h:column>
<f:facet name="header">
<h:outputText value="123"></h:outputText>
</f:facet>
<h:graphicImage value="#{result.stateFlag}" />
</h:column>
<h:column>
<h:outputText value="#{result.name}" />
</h:column>
<h:column>
<h:outputText value="#{result.state}" style="font-style:italic"/>
</h:column>
</rich:suggestionbox>
<rich:spacer height="30px"/>
<h:panelGrid columns="2" border="0" >
<h:outputText value="Border" />
<rich:inputNumberSlider minValue="1" maxValue="5"
value="#{suggestionBox.border}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Width" />
<rich:inputNumberSlider minValue="150" maxValue="350" step="50"
value="#{suggestionBox.width}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Height" />
<rich:inputNumberSlider minValue="100" maxValue="300" step="50"
value="#{suggestionBox.height}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Shadow Depth" />
<rich:inputNumberSlider minValue="3" maxValue="6"
value="#{suggestionBox.shadowDepth}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Shadow Opacity" />
<rich:inputNumberSlider minValue="1" maxValue="9"
value="#{suggestionBox.shadowOpacity}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Cellpadding" />
<rich:inputNumberSlider minValue="1" maxValue="20"
value="#{suggestionBox.cellpadding}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
</h:panelGrid>
</h:form>
</ui:composition>
Tree标签:
Page Source:
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.col, .col2 {
width:50%;
vertical-align:top;
}
</style>
<h:form>
<h:panelGrid columns="2" width="100%" columnClasses="col1,col2">
<rich:tree style="width:300px" nodeSelectListener="#{simpleTreeBean.processSelection}"
reRender="selectedNode" ajaxSubmitSelection="true" switchType="client"
value="#{simpleTreeBean.treeNode}" var="item">
</rich:tree>
<h:outputText escape="false" value="Selected Node: #{simpleTreeBean.nodeTitle}" id="selectedNode" />
</h:panelGrid>
</h:form>
</ui:composition>
Been层:
package org.richfaces.demo.tree;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.richfaces.component.UITree;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;
public class SimpleTreeBean {
private TreeNode rootNode = null;
private String nodeTitle;
private static final String DATA_PATH = "/richfaces/tree/examples/simple-tree-data.properties";
private void addNodes(String path, TreeNode node, Properties properties) {
boolean end = false;
int counter = 1;
while (!end) {
String key = path != null ? path + '.' + counter : String.valueOf(counter);
String value = properties.getProperty(key);
if (value != null) {
TreeNodeImpl nodeImpl = new TreeNodeImpl();
nodeImpl.setData(value);
node.addChild(new Integer(counter), nodeImpl);
addNodes(key, nodeImpl, properties);
counter++;
} else {
end = true;
}
}
}
private void loadTree() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
InputStream dataStream = externalContext.getResourceAsStream(DATA_PATH);
try {
Properties properties = new Properties();
properties.load(dataStream);
rootNode = new TreeNodeImpl();
addNodes(null, rootNode, properties);
} catch (IOException e) {
throw new FacesException(e.getMessage(), e);
} finally {
if (dataStream != null) {
try {
dataStream.close();
} catch (IOException e) {
externalContext.log(e.getMessage(), e);
}
}
}
}
public TreeNode getTreeNode() {
if (rootNode == null) {
loadTree();
}
return rootNode;
}
public void processSelection(NodeSelectedEvent event) {
UITree tree = (UITree) event.getComponent();
nodeTitle = (String) tree.getRowData();
}
public String getNodeTitle() {
return nodeTitle;
}
public void setNodeTitle(String nodeTitle) {
this.nodeTitle = nodeTitle;
}
}
数据:
1=Daniel Defo
1.1=Robinson Crusoe
1.1.1=Start In Life
1.1.2=Slavery And Escape
1.1.3=Wrecked On A Desert Island
1.1.4=First Weeks On The Island
1.1.5=Builds A House - The Journal
1.1.6=Ill And Conscience-Stricken
1.1.7=Agricultural Experience
1.1.8=Surveys His Position
1.1.9=A Boat
1.1.10=Tames Goats
1.1.11=Finds Print Of Man's Foot On The Sand
1.1.12=A Cave Retreat
1.1.13=Wreck Of A Spanish Ship
1.1.14=A Dream Realised
1.1.15=Friday's Education
1.1.16=Rescue Of Prisoners From Cannibals
1.1.17=Visit Of Mutineers
1.1.18=The Ship Recovered
1.1.19=Return To England
1.1.20=Fight Between Friday And A Bear
2=Edgar Allan Poe
2.1=Plays
2.1.1=Politian
2.2=Short stories
2.2.1=The Assignation
2.2.2=Berenice
2.2.3=The Black Cat
2.2.4=The Cask of Amontillado
2.2.5=A Descent into the Maelstrom
2.3=Poetry
2.3.1=Alone
2.3.2=An Enigma
2.3.3=Annabel Lee
2.3.4=Bridal Ballad
3=Henry Wadsworth Longfellow
3.1=The Song of Hiawatha
3.1.1=Introduction
3.1.2=I. The Peace-Pipe
3.1.3=II. The Four Winds
3.1.4=III. Hiawatha's Childhood
3.1.5=IV. Hiawatha and Mudjekeewis
3.1.6=V. Hiawatha's Fasting
3.1.7=VI. Hiawatha's Friends
3.1.8=VII. Hiawatha's Sailing
3.1.9=VIII. Hiawatha's Fishing
3.1.10=IX. Hiawatha and the Pearl-Feather
3.1.11=X. Hiawatha's Wooing
3.1.12=XI. Hiawatha's Wedding-Feast
3.1.13=XII. The Son of the Evening Star
3.1.14=XIII. Blessing the Cornfields
3.1.15=XIV. Picture-Writing
3.1.16=XV. Hiawatha's Lamentation
3.1.17=XVI. Pau-Puk-Keewis
3.1.18=XVII. The Hunting of Pau-Puk-Keewis
3.1.19=XVIII. The Death of Kwasind
3.1.20=XIX. The Ghosts
3.1.21=XX. The Famine
3.1.22=XXI. The White Man's Foot
3.1.23=XXII. Hiawatha's Departure
3.2=Poetry
3.2.1=A Psalm Of Life
3.2.2=Birds Of Passage
3.2.3=Hiawatha's Childhood
3.2.4=Hymn To The Night
AJAX Support
Action Parameter标签:
解释:parameter标签的value属性会通过assingnto属性赋值给been层中的name。
Ajax Form标签:
当单击左边的按钮时页面看不到刷新效果,当点击右边的按钮时会有刷新效果。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style type="text/css">
.dr-pnl-b {
padding: 25px;
}
</style>
<h:panelGrid columns="2">
<rich:panel>
<f:facet name="header">
<h:outputText value="Form with ajaxSubmit equals true"/>
</f:facet>
<a4j:form ajaxSubmit="true" reRender="name">
<h:panelGrid>
<h:commandButton value="Set Local Name to John (Ajax)" action="#{userBean.nameItJohn}" />
<h:outputText id="name" value="Name:#{userBean.name}" />
</h:panelGrid>
</a4j:form>
</rich:panel>
<rich:panel>
<f:facet name="header">
<h:outputText value="Form with ajaxSubmit equals false"/>
</f:facet>
<a4j:form>
<h:panelGrid>
<h:commandButton value="Set Both Name to Mark (non-Ajax)" action="#{userBean.nameItMark}" />
<h:outputText id="name" value="Name:#{userBean.name}" />
</h:panelGrid>
</a4j:form>
</rich:panel>
</h:panelGrid>
</ui:composition>
JS Function标签:
说明:当鼠标放到三个名字上时在name后会显示相应的名字。
使用说明::jsFunction的name属性绑定的是JS方法名,该方法有一个参数,该参数是通过actionparam 标签的assignTo属性传给been层的。该标签的reRender属性指定要刷新的区域。该标签要用a4j:form标签包起来。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<table width="400">
<tbody>
<tr>
<td><span onmouseover="updateName('Alex')" onmouseout="updateName('')">Alex</span></td>
<td><span onmouseover="updateName('Jonh')" onmouseout="updateName('')">Jonh</span></td>
<td><span onmouseover="updateName('Roger')" onmouseout="updateName('')">Roger</span></td>
</tr>
<rich:spacer height="10" />
<tr>
<td colspan="3">Name: <b><h:outputText id="showname" value="#{userBean.name}" /></b></td>
</tr>
</tbody>
</table>
<a4j:form>
<a4j:jsFunction name="updateName" reRender="showname">
<a4j:actionparam name="param1" assignTo="#{userBean.name}" />
</a4j:jsFunction>
</a4j:form>
<br />
</ui:composition>
Poll标签:
说明:该标签相当于一个计时器,会以某频率刷新页面上的指定区域。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<a4j:region>
<h:form>
<a4j:poll id="poll" interval="500" enabled="#{pollBean.pollEnabled}"
reRender="poll,grid" />
</h:form>
</a4j:region>
<h:form>
<h:panelGrid columns="2" width="80%" id="grid">
<h:panelGrid columns="1">
<h:outputText value="Polling Inactive"
rendered="#{not pollBean.pollEnabled}"></h:outputText>
<h:outputText value="Polling Active"
rendered="#{pollBean.pollEnabled}"></h:outputText>
<a4j:commandButton style="width:120px" id="control"
value="#{pollBean.pollEnabled?'Stop':'Start'} Polling"
reRender="poll, grid">
<a4j:actionparam name="polling" value="#{!pollBean.pollEnabled}"
assignTo="#{pollBean.pollEnabled}" />
</a4j:commandButton>
</h:panelGrid>
<h:outputText id="serverDate" style="font-size:16px"
value="Server Date: #{pollBean.date}" />
</h:panelGrid>
</h:form>
</ui:composition>
Status:标签:
说明:该标签是一个在等待异步刷新过程中需要在页面中呈现的元素。
List Shuttle标签:
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jstl/core">
<style>
.pic {
margin-bottom: -4px;
margin-right: 2px;
}
</style>
<h:form>
<rich:toolBar id="toolBar" itemSeparator="line" height="28px">
<c:forEach items="#{toolBar.items}" var="item">
<h:panelGroup>
<h:graphicImage value="#{item.iconURI}" styleClass="pic" />
<h:outputLink value="#" style="color:#{a4jSkin.generalTextColor}; text-decoration:none;" >
<h:outputText value="#{item.label}" />
</h:outputLink>
</h:panelGroup>
</c:forEach>
</rich:toolBar>
<rich:spacer height="20" />
<rich:listShuttle sourceValue="#{toolBar.freeItems}"
targetValue="#{toolBar.items}" var="items" listHeight="300"
listWidth="300" sourceCaptionLabel="Available Items"
targetCaptionLabel="Currently Active Items"
converter="listShuttleconverter">
<rich:column width="18">
<h:graphicImage value="#{items.iconURI}"></h:graphicImage>
</rich:column>
<rich:column>
<h:outputText value="#{items.label}"></h:outputText>
</rich:column>
<a4j:support event="onlistchanged" reRender="toolBar" />
<a4j:support event="onorderchanged" reRender="toolBar" />
</rich:listShuttle>
</h:form>
</ui:composition>
Ordering List标签:
说明:value为List<T>类型的
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.cent{
text-align:center;
}
</style>
<rich:orderingList value="#{library.libraryAsList}" var="lib" listHeight="300" listWidth="350">
<rich:column width="180">
<f:facet name="header">
<h:outputText value="Song Name" />
</f:facet>
<h:outputText value="#{lib.title}"></h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Artist Name" />
</f:facet>
<h:outputText value="#{lib.album.artist.name}"></h:outputText>
</rich:column>
</rich:orderingList>
</ui:composition>
Pick List标签:
Message标签:
说明:该标签相当于客户端数据验证控件。
该控件要和验证控件一起使用,使用时一起做为某控件的子控件。并且在该控件内要有正确和错误时两种不同的信息。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style type="text/css">
.rich-message-marker img {
padding-right:7px;
}
.rich-message-label {
color:red;
}
</style>
<rich:panel>
<f:facet name="header">
<h:outputText value="Validation Form"/>
</f:facet>
<h:form>
<h:panelGrid columns="3">
<h:outputText value="Name:" />
<h:inputText label="Name" id="name" required="true" value="#{userBean.name}">
<f:validateLength minimum="3" />
</h:inputText>
<rich:message for="name">
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:message>
<h:outputText value="Job:" />
<h:inputText label="Job" id="job" required="true" value="#{userBean.job}">
<f:validateLength minimum="3" maximum="50" />
</h:inputText>
<rich:message for="job">
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:message>
<h:outputText value="Address:" />
<h:inputText label="Address" id="address" required="true" value="#{userBean.address}">
<f:validateLength minimum="10" />
</h:inputText>
<rich:message for="address">
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:message>
<h:outputText value="Zip:" />
<h:inputText label="Zip" id="zip" required="true" value="#{userBean.zip}">
<f:validateLength minimum="4" maximum="9" />
</h:inputText>
<rich:message for="zip">
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:message>
<f:facet name="footer">
<a4j:commandButton value="Validate" />
</f:facet>
</h:panelGrid>
</h:form>
</rich:panel>
</ui:composition>
Messages标签:
该标签可以理解为验证组控件,它将页面上所有的不合法信息打到页面上。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style type="text/css">
.rich-messages-marker img {padding-right:7px;}
.rich-message-label {color:red;}
.top {vertical-align:top;}
</style>
<rich:panel style="width:400px">
<f:facet name="header">
<h:outputText value="Validation Form"/>
</f:facet>
<h:form>
<rich:messages passedLabel="Data is allowed to be stored." layout="list">
<f:facet name="header">
<h:outputText value="Entered Data Status:"></h:outputText>
</f:facet>
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:messages>
<h:panelGrid columns="2">
<h:outputText value="Name:" />
<h:inputText label="Name" id="name" required="true" value="#{userBean.name}">
<f:validateLength minimum="3" />
</h:inputText>
<h:outputText value="Job:" />
<h:inputText label="Job" id="job" required="true" value="#{userBean.job}">
<f:validateLength minimum="3" maximum="50" />
</h:inputText>
<h:outputText value="Address:" />
<h:inputText label="Address" id="address" required="true" value="#{userBean.address}">
<f:validateLength minimum="10" />
</h:inputText>
<h:outputText value="Zip:" />
<h:inputText label="Zip" id="zip" required="true" value="#{userBean.zip}">
<f:validateLength minimum="4" maximum="9" />
</h:inputText>
<f:facet name="footer">
<a4j:commandButton value="Validate" />
</f:facet>
</h:panelGrid>
</h:form>
</rich:panel>
</ui:composition>
jQuery标签:
说明:该标签可以为目标控件设置样式等。在该示例中当鼠标移动到某一数据行时该行背景会发生变化,离开后颜色又恢复。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style type="text/css">
.odd-row {
background-color: #ECF3FE;
}
.even-row {
background-color: #FCFFFE;
}
.active-row {
background-color: #FFEBDA;
}
</style>
<br/>
<rich:dataTable width="483" id="carList" rows="15"
value="#{dataTableScrollerBean.allCars}" var="category">
<f:facet name="header">
<rich:columnGroup>
<h:column><h:outputText value="Make" /></h:column>
<h:column><h:outputText value="Model" /></h:column>
<h:column><h:outputText value="Price" /></h:column>
<h:column><h:outputText value="Mileage" /></h:column>
</rich:columnGroup>
</f:facet>
<h:column>
<h:outputText value="#{category.make}" />
</h:column>
<h:column>
<h:outputText value="#{category.model}" />
</h:column>
<h:column>
<h:outputText value="#{category.price}" />
</h:column>
<h:column>
<h:outputText value="#{category.mileage}" />
</h:column>
</rich:dataTable>
<rich:jQuery selector="#carList tr:odd" query="addClass('odd-row')" />
<rich:jQuery selector="#carList tr:even" query="addClass('even-row')" />
<rich:jQuery selector="#carList tr"
query="mouseover(function(){jQuery(this).addClass('active-row')})"/>
<rich:jQuery selector="#carList tr"
query="mouseout(function(){jQuery(this).removeClass('active-row')})"/>
<br/>
</ui:composition>
DataTable及Column及Columns标签:
说明:一句话,它太强了,照着会超就行了~~~~~~~~~~~~~~~
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<rich:dataTable
onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
cellpadding="0" cellspacing="0"
width="700" border="0" var="record" value="#{report.expReport.records}">
<f:facet name="header">
<rich:columnGroup>
<rich:column rowspan="2">
<rich:spacer />
</rich:column>
<rich:column colspan="3">
<h:outputText value="Expenses" />
</rich:column>
<rich:column rowspan="2">
<h:outputText value="subtotals" />
</rich:column>
<rich:column breakBefore="true">
<h:outputText value="Meals" />
</rich:column>
<rich:column>
<h:outputText value="Hotels" />
</rich:column>
<rich:column>
<h:outputText value="Transport" />
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:column colspan="5">
<h:outputText value="#{record.city}" /></rich:column>
<rich:subTable
onRowMouseOver="this.style.backgroundColor='#F8F8F8'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
var="expense" value="#{record.items}">
<rich:column>
<h:outputText value="#{expense.day}"></h:outputText>
<f:facet name="footer">
<rich:spacer />
</f:facet>
</rich:column>
<rich:column>
<h:outputText value="#{expense.meals}"><f:convertNumber pattern="$####.00" /></h:outputText>
<f:facet name="footer">
<h:outputText value="#{record.totalMeals}"><f:convertNumber pattern="$####.00" /></h:outputText>
</f:facet>
</rich:column>
<rich:column>
<h:outputText value="#{expense.hotels}"><f:convertNumber pattern="$####.00" /></h:outputText>
<f:facet name="footer">
<h:outputText value="#{record.totalHotels}"><f:convertNumber pattern="$####.00" /></h:outputText>
</f:facet>
</rich:column>
<rich:column>
<h:outputText value="#{expense.transport}"><f:convertNumber pattern="$####.00" /></h:outputText>
<f:facet name="footer">
<h:outputText value="#{record.totalTransport}"><f:convertNumber pattern="$####.00" /></h:outputText>
</f:facet>
</rich:column>
<rich:column>
<rich:spacer></rich:spacer>
<f:facet name="footer">
<h:outputText value="#{record.total}"><f:convertNumber pattern="$####.00" /></h:outputText>
</f:facet>
</rich:column>
</rich:subTable>
<f:facet name="footer">
<rich:columnGroup>
<rich:column>Totals</rich:column>
<rich:column>
<h:outputText value="#{report.expReport.totalMeals}"><f:convertNumber pattern="$####.00" /></h:outputText>
</rich:column>
<rich:column>
<h:outputText value="#{report.expReport.totalHotels}"><f:convertNumber pattern="$####.00" /></h:outputText>
</rich:column>
<rich:column>
<h:outputText value="#{report.expReport.totalTransport}"><f:convertNumber pattern="$####.00" /></h:outputText>
</rich:column>
<rich:column>
<h:outputText value="#{report.expReport.grandTotal}"><f:convertNumber pattern="$####.00" /></h:outputText>
</rich:column>
</rich:columnGroup>
</f:facet>
</rich:dataTable>
</ui:composition>
Data Definition List标签:
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.label{
font-weight:bold;
}
</style>
<h:form>
<rich:dataList var="car" value="#{dataTableScrollerBean.allCars}" rows="10">
<h:outputText value="#{car.make} #{car.model}"/><br/>
<h:outputText value="Price:" styleClass="label"></h:outputText>
<h:outputText value="#{car.price} " />
<h:outputText value="Mileage:" styleClass="label"></h:outputText>
<h:outputText value="#{car.mileage} " />
<h:outputText value="VIN:" styleClass="label"></h:outputText>
<h:outputText value="#{car.vin}" />
</rich:dataList>
</h:form>
</ui:composition>
DataFilter Slider标签:
该标签用来对数据进行筛选,它有两种模式,一种模式是存储界面数据对象到session中,所以数据筛选时用户体验比较好,变化比较平缓,另一种模式是只发送先前和新的数据作为sliderEvent被传回到been层。
需要注意的是如果使用rich标签的***Listenr属性时,需要在been层为该属性写一个方法,这个方法要有一个参数,参数的类型就是***Event。如DataFilter Slider标签有sliderListener属性,在been层要有一个含有sliderEvent类型参数的方法于该属性绑定。
其中filterBy属性用来绑定需要筛选的数据,在本例中该属性是对dataTable的mileage字段进行筛选,所以绑定的是getMileage字段。
For属性指定对哪个控件中的数据进行筛选。
Forvalref属性需要绑定一个返回值为string类型的方法。
Onslide属性如果为true,说明以滑竿的形式呈现。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.rich-table-firstrow .rich-table-cell {
border-top-width: 0px;
}
</style>
<h:form id="form1">
<rich:dataFilterSlider sliderListener="#{dfsBean.doSlide}"
binding="#{inventoryList.dataFilterSlider}" for="carList"
forValRef="inventoryList.carInventory" filterBy="getMileage"
manualInput="true" onSlide="true" onChange="true" storeResults="true"
width="200px" startRange="10000" endRange="60000" increment="10000"
trailer="true" handleValue="60000"/>
<rich:spacer height="15" />
<h:dataTable id="carIndex" rows="10"
binding="#{inventoryList.carMakeIndexUIData}"
value="#{inventoryList.carMakeIndex}" var="category"
styleClass="list-table1" columnClasses="column-index"
rowClasses="list-row3">
<h:column>
<a4j:commandLink actionListener="#{inventoryList.filterCarList}"
reRender="carList">
<h:outputText value="#{category}" />
<f:attribute name="filterRule" value="showTable" />
</a4j:commandLink>
</h:column>
</h:dataTable>
<rich:spacer height="15" />
<rich:dataTable width="300" id="carList" rows="10"
value="#{inventoryList.carInventory}" var="category">
<f:facet name="header">
<rich:columnGroup>
<h:column>
<h:outputText styleClass="headerText" value="Make" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Model" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Price" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Mileage" />
</h:column>
</rich:columnGroup>
</f:facet>
<h:column>
<h:outputText value="#{category.make}" />
</h:column>
<h:column>
<h:outputText value="#{category.model}" />
</h:column>
<h:column>
<h:outputText value="#{category.price}" />
</h:column>
<h:column>
<h:outputText value="#{category.mileage}" />
</h:column>
</rich:dataTable>
<rich:spacer height="15" />
</h:form>
</ui:composition>
Data Grid标签:
该控件是一个可与其他控件配合使用的强大数据控件。
该控件从been获取一个数据列表List,在输出到界面时跟h:PanelGrid一样,相当于HTML中的table控件,它可以设置数据显示时分几列,在界面显示几条数据(在于rich:datascroller配合使用时指每一页显示的记录条数)。
Value属性用来绑定数据列表List
Columns属性指定每一页分几列显示
Elements属性指定显示几条数据
如果要为该控件添加分页功能,只需在该控件声明的内部下面添加<f:facet><rich:scroller></rich:scroller></f:facet>即可。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.label{
font-weight:bold;
}
</style>
<rich:panel>
<f:facet name="header">
<h:outputText value="Car Store"></h:outputText>
</f:facet>
<h:form>
<rich:dataGrid value="#{dataTableScrollerBean.allCars}" var="car" columns="3" elements="9">
<rich:panel style="width:200px">
<f:facet name="header">
<h:outputText value="#{car.make} #{car.model}"></h:outputText>
</f:facet>
<h:panelGrid columns="2">
<h:outputText value="Price:" styleClass="label"></h:outputText>
<h:outputText value="#{car.price}" />
<h:outputText value="Mileage:" styleClass="label"></h:outputText>
<h:outputText value="#{car.mileage}" />
<h:outputText value="VIN:" styleClass="label"></h:outputText>
<h:outputText value="#{car.vin}" />
<h:outputText value="Stock:" styleClass="label"></h:outputText>
<h:outputText value="#{car.stock}" />
</h:panelGrid>
</rich:panel>
<f:facet name="footer">
<rich:datascroller></rich:datascroller>
</f:facet>
</rich:dataGrid>
</h:form>
</rich:panel>
</ui:composition>
Datascroller控件:
该控件是一个专门的分页控件。它需要和dataTable等数据控件配合使用。
它的使用有两种方式,一种是在数据控件内部声明,那样则不需要用for指定目标数据控件。另一种是在数据控件外部声明,此时则需要使用for属性指定目标数据控件。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.col {
width: 100px;
}
</style>
<h:form>
<rich:datascroller align="left" for="carList" maxPages="20"
page="#{dataTableScrollerBean.scrollerPage}" reRender="sc2" id="sc1" />
<rich:spacer height="30" />
<rich:dataTable width="483" id="carList" rows="10" columnClasses="col"
value="#{dataTableScrollerBean.allCars}" var="category">
<f:facet name="header">
<rich:columnGroup>
<h:column>
<h:outputText styleClass="headerText" value="Make" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Model" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Price" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Mileage" />
</h:column>
</rich:columnGroup>
</f:facet>
<h:column>
<h:outputText value="#{category.make}" />
</h:column>
<h:column>
<h:outputText value="#{category.model}" />
</h:column>
<h:column>
<h:outputText value="#{category.price}" />
</h:column>
<h:column>
<h:outputText value="#{category.mileage}" />
</h:column>
</rich:dataTable>
<rich:datascroller align="left" for="carList" maxPages="20"
page="#{dataTableScrollerBean.scrollerPage}" id="sc2" reRender="sc1" />
</h:form>
</ui:composition>
Scrollable Data Table标签:
该标签是一个含有滚动条的数据控件。
Row属性指定该控件内存放的最大记录条数,
sortMode属性指定排序方式
selection属性指定该控件选中的行。
frozenColCount属性指定可以选中行的数目。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:form>
<rich:spacer height="30" />
<rich:scrollableDataTable rowKeyVar="rkv" frozenColCount="1" height="400px"
width="700px" id="carList" rows="40" columnClasses="col"
value="#{dataTableScrollerBean.allCars}" var="category" sortMode="single"
binding="#{dataTableScrollerBean.table}"
selection="#{dataTableScrollerBean.selection}">
<rich:column id="make">
<f:facet name="header"><h:outputText styleClass="headerText" value="Make" /></f:facet>
<h:outputText value="#{category.make}" />
</rich:column>
<rich:column id="model">
<f:facet name="header"><h:outputText styleClass="headerText" value="Model" /></f:facet>
<h:outputText value="#{category.model}" />
</rich:column>
<rich:column id="price">
<f:facet name="header"><h:outputText styleClass="headerText" value="Price" /></f:facet>
<h:outputText value="#{category.price}" />
</rich:column>
<rich:column id="mileage">
<f:facet name="header"><h:outputText styleClass="headerText" value="Mileage" /></f:facet>
<h:outputText value="#{category.mileage}" />
</rich:column>
<rich:column width="200px" id="vin">
<f:facet name="header"><h:outputText styleClass="headerText" value="VIN" /></f:facet>
<h:outputText value="#{category.vin}" />
</rich:column>
<rich:column id="stock">
<f:facet name="header"><h:outputText styleClass="headerText" value="Stock" /></f:facet>
<h:outputText value="#{category.stock}" />
</rich:column>
</rich:scrollableDataTable>
<rich:spacer height="20px"/>
<a4j:commandButton value="Show Current Selection" reRender="table"
action="#{dataTableScrollerBean.takeSelection}"
oncomplete="javascript:Richfaces.showModalPanel('panel');"/>
</h:form>
<rich:modalPanel id="panel" autosized="true">
<f:facet name="header">
<h:outputText value="Selected Rows"/>
</f:facet>
<f:facet name="controls">
<span style="cursor:pointer" onclick="javascript:Richfaces.hideModalPanel('panel')">X</span>
</f:facet>
<rich:dataTable value="#{dataTableScrollerBean.selectedCars}" var="sel" id="table">
<rich:column>
<f:facet name="header"><h:outputText value="Make" /></f:facet>
<h:outputText value="#{sel.make}" />
</rich:column>
<rich:column id="model">
<f:facet name="header"><h:outputText value="Model" /></f:facet>
<h:outputText value="#{sel.model}" />
</rich:column>
<rich:column id="price">
<f:facet name="header"><h:outputText value="Price" /></f:facet>
<h:outputText value="#{sel.price}" />
</rich:column>
<rich:column id="mileage">
<f:facet name="header"><h:outputText value="Mileage" /></f:facet>
<h:outputText value="#{sel.mileage}" />
</rich:column>
<rich:column id="stock">
<f:facet name="header"><h:outputText value="Stock" /></f:facet>
<h:outputText value="#{sel.stock}" />
</rich:column>
</rich:dataTable>
</rich:modalPanel>
</ui:composition>
Table Sorting:
它不是一个标签,但可以为rich:column标签添加sortBy属性从而达到排序的目的。
示例:
<rich:modalPanel id="panel" width="350" height="100">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Modal Panel"></h:outputText>
</h:panelGroup>
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:graphicImage value="/images/modal/close.png" style="cursor:pointer" id="hidelink"/>
<rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
</h:panelGroup>
</f:facet>
<h:outputText value="This panel is called using Component Control Component"></h:outputText>
<br/>
<h:outputText value="Closure link (X) works also through Component Control"></h:outputText>
</rich:modalPanel>
<h:outputLink value="#" id="link">
Show Modal Panel
<rich:componentControl for="panel" attachTo="link" operation="show" event="onclick"/>
</h:outputLink>
ModolPanel效果:当点击页面中的某元素时,弹出一个类似关机效果的面板。
inputNumberSlider 输入数字滑竿
Panel:
带标题栏的panel
它可以通过h:fecter标签指定标题和底部。
PanelBar:
效果说明:该控件可以实现多个面板的折叠效果,在每个面板的数据区域可以放入任何JSF标签。并且面板的标题可以设定。
<rich:panelBar height="400" width="500">
<rich:panelBarItem
label="Write your own custom rich components with built-in AJAX support">
Component Development Kit (CDK) is a design-time extension for Ajax4jsf. The CDK includes
</rich:panelBarItem>
<rich:panelBarItem
label="Package resources with the application's Java classes ">
In addition to its core, Ajax functionality of Ajax4jsf provides an advanced
support for the diff
</rich:panelBarItem>
<rich:panelBarItem label="Easily generate images on-the-fly">
Resource framework can generate images on-the-fly so that it becomes possible
to create images using the familiar approach of the Java graphic2D library.
</rich:panelBarItem>
</rich:panelBar>
PanelMenu标签:
<h:panelGrid columns="2" columnClasses="cols" width="100%">
<rich:panelMenu style="width:200px" mode="ajax"
iconExpandedGroup="disc" iconCollapsedGroup="disc"
iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
iconCollapsedTopGroup="chevronDown" iconCollapsedTopPosition="right" >
<rich:panelMenuGroup label="Group 1">
<rich:panelMenuItem label="Item 1.1" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 1.1"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 1.2" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 1.2"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 1.3" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 1.3"/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
<rich:panelMenuGroup label="Group 2">
<rich:panelMenuItem label="Item 2.1" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.1"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 2.2" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.2"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 2.3" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.3"/>
</rich:panelMenuItem>
<rich:panelMenuGroup label="Group 2.4">
<rich:panelMenuItem label="Item 2.4.1" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.4.1"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 2.4.2" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.4.2"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 2.4.3" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.4.3"/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
<rich:panelMenuItem label="Item 2.5" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 2.5"/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
<rich:panelMenuGroup label="Group 3">
<rich:panelMenuItem label="Item 3.1" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 3.1"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 3.2" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 3.2"/>
</rich:panelMenuItem>
<rich:panelMenuItem label="Item 3.3" action="#{panelMenu.updateCurrent}">
<f:param name="current" value="Item 3.3"/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
</rich:panelMenu>
<rich:panel bodyClass="rich-laguna-panel-no-header">
<a4j:outputPanel ajaxRendered="true">
<h:outputText value="#{panelMenu.current} selected" id="current"/>
</a4j:outputPanel>
</rich:panel>
</h:panelGrid>
progressBar标签 :
<h:form>
<a4j:outputPanel id="progressPanel">
<rich:progressBar value="#{progressBarBean.currentValue}"
interval="2000" label="#{progressBarBean.currentValue} %"
enabled="#{progressBarBean.enabled}" minValue="-1" maxValue="100"
reRenderAfterComplete="progressPanel">
<f:facet name="initial">
<br />
<h:outputText value="Process doesn't started yet" />
<a4j:commandButton action="#{progressBarBean.startProcess}"
value="Start Process" reRender="progressPanel"
rendered="#{progressBarBean.buttonRendered}"
style="margin: 9px 0px 5px;" />
</f:facet>
<f:facet name="complete">
<br />
<h:outputText value="Process Done" />
<a4j:commandButton action="#{progressBarBean.startProcess}"
value="Restart Process" reRender="progressPanel"
rendered="#{progressBarBean.buttonRendered}"
style="margin: 9px 0px 5px;" />
</f:facet>
</rich:progressBar>
</a4j:outputPanel>
</h:form>
Separator标签:
<p>This is default separator:</p>
<rich:separator/>
<p>This is tick 75% beveled separator aligned to the center:</p>
<rich:separator lineType="beveled" height="8" width="75%" align="center"/>
<p>Here is more examples of different line types:</p>
<rich:separator height="2" lineType="dotted"/><br/>
<rich:separator height="2" lineType="dashed"/><br/>
<rich:separator height="4" lineType="double"/><br/>
<rich:separator height="2" lineType="solid"/><br/>
simpleTogglePanel 标签:
<rich:simpleTogglePanel switchType="client" label="Add AJAX capability to existing JSF applications">
The framework is implemented by using a component library. The library
set Ajax functionality into existing pages, so there is no need to write
any JavaScript code or to replace existing components with new Ajax one.
Ajax4jsf enables page-wide Ajax support instead of the traditional
component-wide support and it gives the opportunity to define the event
on the page. An event invokes an Ajax request and areas of the page
which are synchronized with the JSF Component Tree after changing the
data on the server by Ajax request in accordance with events fired on
the client.
</rich:simpleTogglePanel>
解释:点击该panel的标题栏将隐藏、显示内容部分。其中的switchType为client将无刷新的隐藏显示内容部分。该控件的标题栏不能添加图片,样式不可以自己设定。
tablePanel标签:
<rich:tabPanel>
<rich:tab label="First">
Here is tab #1
</rich:tab>
<rich:tab label="Second">
Here is tab #2
</rich:tab>
<rich:tab label="Third">
Here is tab #3
</rich:tab>
</rich:tabPanel>
<br/><br/>
<p>Here is an example of tab panel switched in "ajax" style. Second tab is disabled.</p>
<rich:tabPanel switchType="ajax">
<rich:tab label="First">
Here is tab #1
</rich:tab>
<rich:tab label="Second" disabled="true">
Here is tab #2
</rich:tab>
<rich:tab label="Third">
Here is tab #3
</rich:tab>
</rich:tabPanel>
<br/><br/>
<p>Here is an example of tab panel switched completely on client.</p>
<rich:tabPanel switchType="client">
<rich:tab label="First">
Here is tab #1
</rich:tab>
<rich:tab label="Second">
Here is tab #2
</rich:tab>
<rich:tab label="Third">
Here is tab #3
</rich:tab>
</rich:tabPanel>
解释:tabPanel 的switchType有server client ajax三种。Server会产生页面的刷新,ajax会异步的刷新,client则不会跟服务器进行交互。
Tool Bar标签:
<style>
.barsearch {
height:14px;
width:100px;
}
.barsearchbutton {
border-width:1px;
background-color:#{a4jSkin.generalBackgroundColor};
}
</style>
<h:form>
<rich:toolBar height="34" itemSeparator="line">
<rich:toolBarGroup>
<h:graphicImage id="edit" value="/images/icons/edit.gif" />
<h:outputLabel value="Edit" for="edit" />
</rich:toolBarGroup>
<rich:toolBarGroup>
<h:graphicImage id="find" value="/images/icons/find.gif" />
<h:outputLabel value="Find" for="find" />
</rich:toolBarGroup>
<rich:toolBarGroup>
<h:graphicImage id="filter" value="/images/icons/filter.gif" />
<h:outputLabel value="Filter" for="filter" />
</rich:toolBarGroup>
<rich:toolBarGroup location="right">
<h:inputText styleClass="barsearch" />
<h:commandButton styleClass="barsearchbutton" onclick="return false;" value="Search" />
</rich:toolBarGroup>
</rich:toolBar>
</h:form>
ToolTip标签:
<style>
.tooltip {
background-color:#{richSkin.generalBackgroundColor};
border-width:3px;
padding:10px;
}
.tooltip-text {
width:350px;
height:80px;
cursor:arrow;
border-width:2px;
text-align:center;
display: table-cell;
vertical-align: middle;
}
.tooltipData {
font-weight: bold;
}
</style>
<h:panelGrid columns="2">
<rich:panel id="sample1" styleClass="tooltip-text" bodyClass="rich-laguna-panel-no-header">
<p>
Here you can see <b>default client-side</b> tool-tip
</p>
<rich:toolTip>
<span style="white-space:nowrap">
This tool-tip content was <strong>pre-rendered</strong> to the page.<br/>
The look of this tool-tip is 100% defined by skin.
</span>
</rich:toolTip>
</rich:panel>
<rich:panel id="sample2" styleClass="tooltip-text" bodyClass="rich-laguna-panel-no-header">
<p>
This tool-tip will <b>follow mouse</b>. Also this tool-tip has a <b>delay 0.5 sec</b>,
so be patient!
</p>
<rich:toolTip followMouse="true" direction="top-right" showDelay="500" styleClass="tooltip">
<span style="white-space:nowrap">
This tool-tip content also <strong>pre-rendered</strong> to the page.<br/>
However, the look of this tool-tip is customized<br/>
by styleClass attribute.
</span>
</rich:toolTip>
</rich:panel>
<h:form>
<rich:panel id="sample3" styleClass="tooltip-text" bodyClass="rich-laguna-panel-no-header">
<p>
This tool-tip rendered on server <b>in separate request</b>.
</p>
<rich:toolTip direction="top-right" mode="ajax" styleClass="tooltip" layout="block">
<f:facet name="defaultContent">
<strong>Wait...</strong>
</f:facet>
<span style="white-space:nowrap">This tool-tip content was <strong>rendered on server</strong>
</span>
<h:panelGrid columns="2">
<h:outputText style="white-space:nowrap" value="tooltips requested:" />
<h:outputText value="#{toolTipData.tooltipCounter}" styleClass="tooltipData" />
</h:panelGrid>
</rich:toolTip>
</rich:panel>
</h:form>
<h:form>
<rich:panel id="sample4" styleClass="tooltip-text" bodyClass="rich-laguna-panel-no-header">
<p>
This tool-tip will be <b>activated on mouse click</b>. It also has a <b>bottom-left</b> position.
</p>
<rich:toolTip showEvent="onclick" direction="bottom-left" mode="ajax" styleClass="tooltip" layout="block">
<f:facet name="defaultContent">
<strong>Wait...</strong>
</f:facet>
<span style="white-space:nowrap">This tool-tip content was <strong>rendered on server</strong><br/></span>
<h:panelGrid columns="2">
<h:outputText style="white-space:nowrap" value="tooltips requested:" />
<h:outputText value="#{toolTipData.tooltipCounter}" styleClass="tooltipData" />
</h:panelGrid>
</rich:toolTip>
</rich:panel>
</h:form>
</h:panelGrid>
Calendar标签:
右边控件绑定been层中的属性都是Calendar的一系列属性。
<style type="text/css">
.ecol1 { vertical-align: top; padding-right : 25px }
.ecol2 { vertical-align: top; border-left: #ACBECE 1px solid; padding-left : 10px }
.rich-calendar-tool-btn{
font-family: Arial, Verdana;
}
</style>
<h:form>
<h:panelGrid id="panel" columns="2" columnClasses="ecol1, ecol2">
<a4j:outputPanel id="calendar" layout="block">
<rich:calendar value="#{calendarBean.selectedDate}"
locale="#{calendarBean.locale}"
popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px" cellHeight="22px" style="width:200px"/>
</a4j:outputPanel>
<h:panelGrid columns="2">
<h:outputText value="Popup Mode:" />
<h:selectBooleanCheckbox value="#{calendarBean.popup}">
<a4j:support event="onclick" reRender="calendar"/>
</h:selectBooleanCheckbox>
<h:outputText value="Apply Button:" />
<h:selectBooleanCheckbox value="#{calendarBean.showApply}">
<a4j:support event="onclick" reRender="calendar"/>
</h:selectBooleanCheckbox>
<h:outputText value="Select Locale" />
<h:selectOneRadio value="en/US" valueChangeListener="#{calendarBean.selectLocale}">
<a4j:support event="onclick" reRender="calendar"/>
<f:selectItem itemLabel="US" itemValue="en/US"/>
<f:selectItem itemLabel="DE" itemValue="de/DE"/>
<f:selectItem itemLabel="FR" itemValue="fr/FR"/>
<f:selectItem itemLabel="RU" itemValue="ru/RU"/>
</h:selectOneRadio>
<h:outputText value="Select Date Pattern:"/>
<h:selectOneMenu value="#{calendarBean.pattern}">
<a4j:support event="onchange" reRender="calendar"/>
<f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy HH:mm"/>
<f:selectItem itemLabel="dd/M/yy hh:mm a" itemValue="dd/M/yy hh:mm a"/>
<f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y"/>
<f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"/>
</h:selectOneMenu>
</h:panelGrid>
</h:panelGrid>
</h:form>
comboBox 标签:
该控件可以实现google搜索框的效果,唯一不同的地方就是右边有一个向下的箭头。
File Upload控件:
说明:在建立的页面中发现不到该标签。
Inplace Input标签:
SuggestionBox标签:
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:form id="suggestionbox_form">
<p>
Suggestion Box will suggest you states capitals names. Comma and space could be used as suggestions separators."
</p>
<h:inputText value="#{capitalsBean.capital}" id="text" />
<rich:suggestionbox id="suggestionBoxId" for="text" tokens=",["
rules="#{suggestionBox.rules}"
suggestionAction="#{capitalsBean.autocomplete}" var="result"
fetchValue="#{result.name}" rows="#{suggestionBox.intRows}"
first="#{suggestionBox.intFirst}"
minChars="#{suggestionBox.minchars}"
shadowOpacity="#{suggestionBox.shadowOpacity}"
border="#{suggestionBox.border}" width="#{suggestionBox.width}"
height="#{suggestionBox.height}"
shadowDepth="#{suggestionBox.shadowDepth}"
cellpadding="#{suggestionBox.cellpadding}"
nothingLabel="No capitals found" columnClasses="center">
<h:column>
<f:facet name="header">
<h:outputText value="123"></h:outputText>
</f:facet>
<h:graphicImage value="#{result.stateFlag}" />
</h:column>
<h:column>
<h:outputText value="#{result.name}" />
</h:column>
<h:column>
<h:outputText value="#{result.state}" style="font-style:italic"/>
</h:column>
</rich:suggestionbox>
<rich:spacer height="30px"/>
<h:panelGrid columns="2" border="0" >
<h:outputText value="Border" />
<rich:inputNumberSlider minValue="1" maxValue="5"
value="#{suggestionBox.border}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Width" />
<rich:inputNumberSlider minValue="150" maxValue="350" step="50"
value="#{suggestionBox.width}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Height" />
<rich:inputNumberSlider minValue="100" maxValue="300" step="50"
value="#{suggestionBox.height}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Shadow Depth" />
<rich:inputNumberSlider minValue="3" maxValue="6"
value="#{suggestionBox.shadowDepth}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Shadow Opacity" />
<rich:inputNumberSlider minValue="1" maxValue="9"
value="#{suggestionBox.shadowOpacity}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
<h:outputText value="Cellpadding" />
<rich:inputNumberSlider minValue="1" maxValue="20"
value="#{suggestionBox.cellpadding}">
<a4j:support event="onchange" reRender="suggestionBoxId" />
</rich:inputNumberSlider>
</h:panelGrid>
</h:form>
</ui:composition>
Tree标签:
Page Source:
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.col, .col2 {
width:50%;
vertical-align:top;
}
</style>
<h:form>
<h:panelGrid columns="2" width="100%" columnClasses="col1,col2">
<rich:tree style="width:300px" nodeSelectListener="#{simpleTreeBean.processSelection}"
reRender="selectedNode" ajaxSubmitSelection="true" switchType="client"
value="#{simpleTreeBean.treeNode}" var="item">
</rich:tree>
<h:outputText escape="false" value="Selected Node: #{simpleTreeBean.nodeTitle}" id="selectedNode" />
</h:panelGrid>
</h:form>
</ui:composition>
Been层:
package org.richfaces.demo.tree;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.richfaces.component.UITree;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;
public class SimpleTreeBean {
private TreeNode rootNode = null;
private String nodeTitle;
private static final String DATA_PATH = "/richfaces/tree/examples/simple-tree-data.properties";
private void addNodes(String path, TreeNode node, Properties properties) {
boolean end = false;
int counter = 1;
while (!end) {
String key = path != null ? path + '.' + counter : String.valueOf(counter);
String value = properties.getProperty(key);
if (value != null) {
TreeNodeImpl nodeImpl = new TreeNodeImpl();
nodeImpl.setData(value);
node.addChild(new Integer(counter), nodeImpl);
addNodes(key, nodeImpl, properties);
counter++;
} else {
end = true;
}
}
}
private void loadTree() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
InputStream dataStream = externalContext.getResourceAsStream(DATA_PATH);
try {
Properties properties = new Properties();
properties.load(dataStream);
rootNode = new TreeNodeImpl();
addNodes(null, rootNode, properties);
} catch (IOException e) {
throw new FacesException(e.getMessage(), e);
} finally {
if (dataStream != null) {
try {
dataStream.close();
} catch (IOException e) {
externalContext.log(e.getMessage(), e);
}
}
}
}
public TreeNode getTreeNode() {
if (rootNode == null) {
loadTree();
}
return rootNode;
}
public void processSelection(NodeSelectedEvent event) {
UITree tree = (UITree) event.getComponent();
nodeTitle = (String) tree.getRowData();
}
public String getNodeTitle() {
return nodeTitle;
}
public void setNodeTitle(String nodeTitle) {
this.nodeTitle = nodeTitle;
}
}
数据:
1=Daniel Defo
1.1=Robinson Crusoe
1.1.1=Start In Life
1.1.2=Slavery And Escape
1.1.3=Wrecked On A Desert Island
1.1.4=First Weeks On The Island
1.1.5=Builds A House - The Journal
1.1.6=Ill And Conscience-Stricken
1.1.7=Agricultural Experience
1.1.8=Surveys His Position
1.1.9=A Boat
1.1.10=Tames Goats
1.1.11=Finds Print Of Man's Foot On The Sand
1.1.12=A Cave Retreat
1.1.13=Wreck Of A Spanish Ship
1.1.14=A Dream Realised
1.1.15=Friday's Education
1.1.16=Rescue Of Prisoners From Cannibals
1.1.17=Visit Of Mutineers
1.1.18=The Ship Recovered
1.1.19=Return To England
1.1.20=Fight Between Friday And A Bear
2=Edgar Allan Poe
2.1=Plays
2.1.1=Politian
2.2=Short stories
2.2.1=The Assignation
2.2.2=Berenice
2.2.3=The Black Cat
2.2.4=The Cask of Amontillado
2.2.5=A Descent into the Maelstrom
2.3=Poetry
2.3.1=Alone
2.3.2=An Enigma
2.3.3=Annabel Lee
2.3.4=Bridal Ballad
3=Henry Wadsworth Longfellow
3.1=The Song of Hiawatha
3.1.1=Introduction
3.1.2=I. The Peace-Pipe
3.1.3=II. The Four Winds
3.1.4=III. Hiawatha's Childhood
3.1.5=IV. Hiawatha and Mudjekeewis
3.1.6=V. Hiawatha's Fasting
3.1.7=VI. Hiawatha's Friends
3.1.8=VII. Hiawatha's Sailing
3.1.9=VIII. Hiawatha's Fishing
3.1.10=IX. Hiawatha and the Pearl-Feather
3.1.11=X. Hiawatha's Wooing
3.1.12=XI. Hiawatha's Wedding-Feast
3.1.13=XII. The Son of the Evening Star
3.1.14=XIII. Blessing the Cornfields
3.1.15=XIV. Picture-Writing
3.1.16=XV. Hiawatha's Lamentation
3.1.17=XVI. Pau-Puk-Keewis
3.1.18=XVII. The Hunting of Pau-Puk-Keewis
3.1.19=XVIII. The Death of Kwasind
3.1.20=XIX. The Ghosts
3.1.21=XX. The Famine
3.1.22=XXI. The White Man's Foot
3.1.23=XXII. Hiawatha's Departure
3.2=Poetry
3.2.1=A Psalm Of Life
3.2.2=Birds Of Passage
3.2.3=Hiawatha's Childhood
3.2.4=Hymn To The Night
AJAX Support
Action Parameter标签:
解释:parameter标签的value属性会通过assingnto属性赋值给been层中的name。
Ajax Form标签:
当单击左边的按钮时页面看不到刷新效果,当点击右边的按钮时会有刷新效果。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style type="text/css">
.dr-pnl-b {
padding: 25px;
}
</style>
<h:panelGrid columns="2">
<rich:panel>
<f:facet name="header">
<h:outputText value="Form with ajaxSubmit equals true"/>
</f:facet>
<a4j:form ajaxSubmit="true" reRender="name">
<h:panelGrid>
<h:commandButton value="Set Local Name to John (Ajax)" action="#{userBean.nameItJohn}" />
<h:outputText id="name" value="Name:#{userBean.name}" />
</h:panelGrid>
</a4j:form>
</rich:panel>
<rich:panel>
<f:facet name="header">
<h:outputText value="Form with ajaxSubmit equals false"/>
</f:facet>
<a4j:form>
<h:panelGrid>
<h:commandButton value="Set Both Name to Mark (non-Ajax)" action="#{userBean.nameItMark}" />
<h:outputText id="name" value="Name:#{userBean.name}" />
</h:panelGrid>
</a4j:form>
</rich:panel>
</h:panelGrid>
</ui:composition>
JS Function标签:
说明:当鼠标放到三个名字上时在name后会显示相应的名字。
使用说明::jsFunction的name属性绑定的是JS方法名,该方法有一个参数,该参数是通过actionparam 标签的assignTo属性传给been层的。该标签的reRender属性指定要刷新的区域。该标签要用a4j:form标签包起来。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<table width="400">
<tbody>
<tr>
<td><span onmouseover="updateName('Alex')" onmouseout="updateName('')">Alex</span></td>
<td><span onmouseover="updateName('Jonh')" onmouseout="updateName('')">Jonh</span></td>
<td><span onmouseover="updateName('Roger')" onmouseout="updateName('')">Roger</span></td>
</tr>
<rich:spacer height="10" />
<tr>
<td colspan="3">Name: <b><h:outputText id="showname" value="#{userBean.name}" /></b></td>
</tr>
</tbody>
</table>
<a4j:form>
<a4j:jsFunction name="updateName" reRender="showname">
<a4j:actionparam name="param1" assignTo="#{userBean.name}" />
</a4j:jsFunction>
</a4j:form>
<br />
</ui:composition>
Poll标签:
说明:该标签相当于一个计时器,会以某频率刷新页面上的指定区域。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<a4j:region>
<h:form>
<a4j:poll id="poll" interval="500" enabled="#{pollBean.pollEnabled}"
reRender="poll,grid" />
</h:form>
</a4j:region>
<h:form>
<h:panelGrid columns="2" width="80%" id="grid">
<h:panelGrid columns="1">
<h:outputText value="Polling Inactive"
rendered="#{not pollBean.pollEnabled}"></h:outputText>
<h:outputText value="Polling Active"
rendered="#{pollBean.pollEnabled}"></h:outputText>
<a4j:commandButton style="width:120px" id="control"
value="#{pollBean.pollEnabled?'Stop':'Start'} Polling"
reRender="poll, grid">
<a4j:actionparam name="polling" value="#{!pollBean.pollEnabled}"
assignTo="#{pollBean.pollEnabled}" />
</a4j:commandButton>
</h:panelGrid>
<h:outputText id="serverDate" style="font-size:16px"
value="Server Date: #{pollBean.date}" />
</h:panelGrid>
</h:form>
</ui:composition>
Status:标签:
说明:该标签是一个在等待异步刷新过程中需要在页面中呈现的元素。
List Shuttle标签:
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jstl/core">
<style>
.pic {
margin-bottom: -4px;
margin-right: 2px;
}
</style>
<h:form>
<rich:toolBar id="toolBar" itemSeparator="line" height="28px">
<c:forEach items="#{toolBar.items}" var="item">
<h:panelGroup>
<h:graphicImage value="#{item.iconURI}" styleClass="pic" />
<h:outputLink value="#" style="color:#{a4jSkin.generalTextColor}; text-decoration:none;" >
<h:outputText value="#{item.label}" />
</h:outputLink>
</h:panelGroup>
</c:forEach>
</rich:toolBar>
<rich:spacer height="20" />
<rich:listShuttle sourceValue="#{toolBar.freeItems}"
targetValue="#{toolBar.items}" var="items" listHeight="300"
listWidth="300" sourceCaptionLabel="Available Items"
targetCaptionLabel="Currently Active Items"
converter="listShuttleconverter">
<rich:column width="18">
<h:graphicImage value="#{items.iconURI}"></h:graphicImage>
</rich:column>
<rich:column>
<h:outputText value="#{items.label}"></h:outputText>
</rich:column>
<a4j:support event="onlistchanged" reRender="toolBar" />
<a4j:support event="onorderchanged" reRender="toolBar" />
</rich:listShuttle>
</h:form>
</ui:composition>
Ordering List标签:
说明:value为List<T>类型的
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.cent{
text-align:center;
}
</style>
<rich:orderingList value="#{library.libraryAsList}" var="lib" listHeight="300" listWidth="350">
<rich:column width="180">
<f:facet name="header">
<h:outputText value="Song Name" />
</f:facet>
<h:outputText value="#{lib.title}"></h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Artist Name" />
</f:facet>
<h:outputText value="#{lib.album.artist.name}"></h:outputText>
</rich:column>
</rich:orderingList>
</ui:composition>
Pick List标签:
Message标签:
说明:该标签相当于客户端数据验证控件。
该控件要和验证控件一起使用,使用时一起做为某控件的子控件。并且在该控件内要有正确和错误时两种不同的信息。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style type="text/css">
.rich-message-marker img {
padding-right:7px;
}
.rich-message-label {
color:red;
}
</style>
<rich:panel>
<f:facet name="header">
<h:outputText value="Validation Form"/>
</f:facet>
<h:form>
<h:panelGrid columns="3">
<h:outputText value="Name:" />
<h:inputText label="Name" id="name" required="true" value="#{userBean.name}">
<f:validateLength minimum="3" />
</h:inputText>
<rich:message for="name">
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:message>
<h:outputText value="Job:" />
<h:inputText label="Job" id="job" required="true" value="#{userBean.job}">
<f:validateLength minimum="3" maximum="50" />
</h:inputText>
<rich:message for="job">
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:message>
<h:outputText value="Address:" />
<h:inputText label="Address" id="address" required="true" value="#{userBean.address}">
<f:validateLength minimum="10" />
</h:inputText>
<rich:message for="address">
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:message>
<h:outputText value="Zip:" />
<h:inputText label="Zip" id="zip" required="true" value="#{userBean.zip}">
<f:validateLength minimum="4" maximum="9" />
</h:inputText>
<rich:message for="zip">
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:message>
<f:facet name="footer">
<a4j:commandButton value="Validate" />
</f:facet>
</h:panelGrid>
</h:form>
</rich:panel>
</ui:composition>
Messages标签:
该标签可以理解为验证组控件,它将页面上所有的不合法信息打到页面上。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style type="text/css">
.rich-messages-marker img {padding-right:7px;}
.rich-message-label {color:red;}
.top {vertical-align:top;}
</style>
<rich:panel style="width:400px">
<f:facet name="header">
<h:outputText value="Validation Form"/>
</f:facet>
<h:form>
<rich:messages passedLabel="Data is allowed to be stored." layout="list">
<f:facet name="header">
<h:outputText value="Entered Data Status:"></h:outputText>
</f:facet>
<f:facet name="passedMarker">
<h:graphicImage value="/images/ajax/passed.gif" />
</f:facet>
<f:facet name="errorMarker">
<h:graphicImage value="/images/ajax/error.gif" />
</f:facet>
</rich:messages>
<h:panelGrid columns="2">
<h:outputText value="Name:" />
<h:inputText label="Name" id="name" required="true" value="#{userBean.name}">
<f:validateLength minimum="3" />
</h:inputText>
<h:outputText value="Job:" />
<h:inputText label="Job" id="job" required="true" value="#{userBean.job}">
<f:validateLength minimum="3" maximum="50" />
</h:inputText>
<h:outputText value="Address:" />
<h:inputText label="Address" id="address" required="true" value="#{userBean.address}">
<f:validateLength minimum="10" />
</h:inputText>
<h:outputText value="Zip:" />
<h:inputText label="Zip" id="zip" required="true" value="#{userBean.zip}">
<f:validateLength minimum="4" maximum="9" />
</h:inputText>
<f:facet name="footer">
<a4j:commandButton value="Validate" />
</f:facet>
</h:panelGrid>
</h:form>
</rich:panel>
</ui:composition>
jQuery标签:
说明:该标签可以为目标控件设置样式等。在该示例中当鼠标移动到某一数据行时该行背景会发生变化,离开后颜色又恢复。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style type="text/css">
.odd-row {
background-color: #ECF3FE;
}
.even-row {
background-color: #FCFFFE;
}
.active-row {
background-color: #FFEBDA;
}
</style>
<br/>
<rich:dataTable width="483" id="carList" rows="15"
value="#{dataTableScrollerBean.allCars}" var="category">
<f:facet name="header">
<rich:columnGroup>
<h:column><h:outputText value="Make" /></h:column>
<h:column><h:outputText value="Model" /></h:column>
<h:column><h:outputText value="Price" /></h:column>
<h:column><h:outputText value="Mileage" /></h:column>
</rich:columnGroup>
</f:facet>
<h:column>
<h:outputText value="#{category.make}" />
</h:column>
<h:column>
<h:outputText value="#{category.model}" />
</h:column>
<h:column>
<h:outputText value="#{category.price}" />
</h:column>
<h:column>
<h:outputText value="#{category.mileage}" />
</h:column>
</rich:dataTable>
<rich:jQuery selector="#carList tr:odd" query="addClass('odd-row')" />
<rich:jQuery selector="#carList tr:even" query="addClass('even-row')" />
<rich:jQuery selector="#carList tr"
query="mouseover(function(){jQuery(this).addClass('active-row')})"/>
<rich:jQuery selector="#carList tr"
query="mouseout(function(){jQuery(this).removeClass('active-row')})"/>
<br/>
</ui:composition>
DataTable及Column及Columns标签:
说明:一句话,它太强了,照着会超就行了~~~~~~~~~~~~~~~
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<rich:dataTable
onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
cellpadding="0" cellspacing="0"
width="700" border="0" var="record" value="#{report.expReport.records}">
<f:facet name="header">
<rich:columnGroup>
<rich:column rowspan="2">
<rich:spacer />
</rich:column>
<rich:column colspan="3">
<h:outputText value="Expenses" />
</rich:column>
<rich:column rowspan="2">
<h:outputText value="subtotals" />
</rich:column>
<rich:column breakBefore="true">
<h:outputText value="Meals" />
</rich:column>
<rich:column>
<h:outputText value="Hotels" />
</rich:column>
<rich:column>
<h:outputText value="Transport" />
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:column colspan="5">
<h:outputText value="#{record.city}" /></rich:column>
<rich:subTable
onRowMouseOver="this.style.backgroundColor='#F8F8F8'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
var="expense" value="#{record.items}">
<rich:column>
<h:outputText value="#{expense.day}"></h:outputText>
<f:facet name="footer">
<rich:spacer />
</f:facet>
</rich:column>
<rich:column>
<h:outputText value="#{expense.meals}"><f:convertNumber pattern="$####.00" /></h:outputText>
<f:facet name="footer">
<h:outputText value="#{record.totalMeals}"><f:convertNumber pattern="$####.00" /></h:outputText>
</f:facet>
</rich:column>
<rich:column>
<h:outputText value="#{expense.hotels}"><f:convertNumber pattern="$####.00" /></h:outputText>
<f:facet name="footer">
<h:outputText value="#{record.totalHotels}"><f:convertNumber pattern="$####.00" /></h:outputText>
</f:facet>
</rich:column>
<rich:column>
<h:outputText value="#{expense.transport}"><f:convertNumber pattern="$####.00" /></h:outputText>
<f:facet name="footer">
<h:outputText value="#{record.totalTransport}"><f:convertNumber pattern="$####.00" /></h:outputText>
</f:facet>
</rich:column>
<rich:column>
<rich:spacer></rich:spacer>
<f:facet name="footer">
<h:outputText value="#{record.total}"><f:convertNumber pattern="$####.00" /></h:outputText>
</f:facet>
</rich:column>
</rich:subTable>
<f:facet name="footer">
<rich:columnGroup>
<rich:column>Totals</rich:column>
<rich:column>
<h:outputText value="#{report.expReport.totalMeals}"><f:convertNumber pattern="$####.00" /></h:outputText>
</rich:column>
<rich:column>
<h:outputText value="#{report.expReport.totalHotels}"><f:convertNumber pattern="$####.00" /></h:outputText>
</rich:column>
<rich:column>
<h:outputText value="#{report.expReport.totalTransport}"><f:convertNumber pattern="$####.00" /></h:outputText>
</rich:column>
<rich:column>
<h:outputText value="#{report.expReport.grandTotal}"><f:convertNumber pattern="$####.00" /></h:outputText>
</rich:column>
</rich:columnGroup>
</f:facet>
</rich:dataTable>
</ui:composition>
Data Definition List标签:
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.label{
font-weight:bold;
}
</style>
<h:form>
<rich:dataList var="car" value="#{dataTableScrollerBean.allCars}" rows="10">
<h:outputText value="#{car.make} #{car.model}"/><br/>
<h:outputText value="Price:" styleClass="label"></h:outputText>
<h:outputText value="#{car.price} " />
<h:outputText value="Mileage:" styleClass="label"></h:outputText>
<h:outputText value="#{car.mileage} " />
<h:outputText value="VIN:" styleClass="label"></h:outputText>
<h:outputText value="#{car.vin}" />
</rich:dataList>
</h:form>
</ui:composition>
DataFilter Slider标签:
该标签用来对数据进行筛选,它有两种模式,一种模式是存储界面数据对象到session中,所以数据筛选时用户体验比较好,变化比较平缓,另一种模式是只发送先前和新的数据作为sliderEvent被传回到been层。
需要注意的是如果使用rich标签的***Listenr属性时,需要在been层为该属性写一个方法,这个方法要有一个参数,参数的类型就是***Event。如DataFilter Slider标签有sliderListener属性,在been层要有一个含有sliderEvent类型参数的方法于该属性绑定。
其中filterBy属性用来绑定需要筛选的数据,在本例中该属性是对dataTable的mileage字段进行筛选,所以绑定的是getMileage字段。
For属性指定对哪个控件中的数据进行筛选。
Forvalref属性需要绑定一个返回值为string类型的方法。
Onslide属性如果为true,说明以滑竿的形式呈现。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.rich-table-firstrow .rich-table-cell {
border-top-width: 0px;
}
</style>
<h:form id="form1">
<rich:dataFilterSlider sliderListener="#{dfsBean.doSlide}"
binding="#{inventoryList.dataFilterSlider}" for="carList"
forValRef="inventoryList.carInventory" filterBy="getMileage"
manualInput="true" onSlide="true" onChange="true" storeResults="true"
width="200px" startRange="10000" endRange="60000" increment="10000"
trailer="true" handleValue="60000"/>
<rich:spacer height="15" />
<h:dataTable id="carIndex" rows="10"
binding="#{inventoryList.carMakeIndexUIData}"
value="#{inventoryList.carMakeIndex}" var="category"
styleClass="list-table1" columnClasses="column-index"
rowClasses="list-row3">
<h:column>
<a4j:commandLink actionListener="#{inventoryList.filterCarList}"
reRender="carList">
<h:outputText value="#{category}" />
<f:attribute name="filterRule" value="showTable" />
</a4j:commandLink>
</h:column>
</h:dataTable>
<rich:spacer height="15" />
<rich:dataTable width="300" id="carList" rows="10"
value="#{inventoryList.carInventory}" var="category">
<f:facet name="header">
<rich:columnGroup>
<h:column>
<h:outputText styleClass="headerText" value="Make" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Model" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Price" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Mileage" />
</h:column>
</rich:columnGroup>
</f:facet>
<h:column>
<h:outputText value="#{category.make}" />
</h:column>
<h:column>
<h:outputText value="#{category.model}" />
</h:column>
<h:column>
<h:outputText value="#{category.price}" />
</h:column>
<h:column>
<h:outputText value="#{category.mileage}" />
</h:column>
</rich:dataTable>
<rich:spacer height="15" />
</h:form>
</ui:composition>
Data Grid标签:
该控件是一个可与其他控件配合使用的强大数据控件。
该控件从been获取一个数据列表List,在输出到界面时跟h:PanelGrid一样,相当于HTML中的table控件,它可以设置数据显示时分几列,在界面显示几条数据(在于rich:datascroller配合使用时指每一页显示的记录条数)。
Value属性用来绑定数据列表List
Columns属性指定每一页分几列显示
Elements属性指定显示几条数据
如果要为该控件添加分页功能,只需在该控件声明的内部下面添加<f:facet><rich:scroller></rich:scroller></f:facet>即可。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.label{
font-weight:bold;
}
</style>
<rich:panel>
<f:facet name="header">
<h:outputText value="Car Store"></h:outputText>
</f:facet>
<h:form>
<rich:dataGrid value="#{dataTableScrollerBean.allCars}" var="car" columns="3" elements="9">
<rich:panel style="width:200px">
<f:facet name="header">
<h:outputText value="#{car.make} #{car.model}"></h:outputText>
</f:facet>
<h:panelGrid columns="2">
<h:outputText value="Price:" styleClass="label"></h:outputText>
<h:outputText value="#{car.price}" />
<h:outputText value="Mileage:" styleClass="label"></h:outputText>
<h:outputText value="#{car.mileage}" />
<h:outputText value="VIN:" styleClass="label"></h:outputText>
<h:outputText value="#{car.vin}" />
<h:outputText value="Stock:" styleClass="label"></h:outputText>
<h:outputText value="#{car.stock}" />
</h:panelGrid>
</rich:panel>
<f:facet name="footer">
<rich:datascroller></rich:datascroller>
</f:facet>
</rich:dataGrid>
</h:form>
</rich:panel>
</ui:composition>
Datascroller控件:
该控件是一个专门的分页控件。它需要和dataTable等数据控件配合使用。
它的使用有两种方式,一种是在数据控件内部声明,那样则不需要用for指定目标数据控件。另一种是在数据控件外部声明,此时则需要使用for属性指定目标数据控件。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
.col {
width: 100px;
}
</style>
<h:form>
<rich:datascroller align="left" for="carList" maxPages="20"
page="#{dataTableScrollerBean.scrollerPage}" reRender="sc2" id="sc1" />
<rich:spacer height="30" />
<rich:dataTable width="483" id="carList" rows="10" columnClasses="col"
value="#{dataTableScrollerBean.allCars}" var="category">
<f:facet name="header">
<rich:columnGroup>
<h:column>
<h:outputText styleClass="headerText" value="Make" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Model" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Price" />
</h:column>
<h:column>
<h:outputText styleClass="headerText" value="Mileage" />
</h:column>
</rich:columnGroup>
</f:facet>
<h:column>
<h:outputText value="#{category.make}" />
</h:column>
<h:column>
<h:outputText value="#{category.model}" />
</h:column>
<h:column>
<h:outputText value="#{category.price}" />
</h:column>
<h:column>
<h:outputText value="#{category.mileage}" />
</h:column>
</rich:dataTable>
<rich:datascroller align="left" for="carList" maxPages="20"
page="#{dataTableScrollerBean.scrollerPage}" id="sc2" reRender="sc1" />
</h:form>
</ui:composition>
Scrollable Data Table标签:
该标签是一个含有滚动条的数据控件。
Row属性指定该控件内存放的最大记录条数,
sortMode属性指定排序方式
selection属性指定该控件选中的行。
frozenColCount属性指定可以选中行的数目。
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:form>
<rich:spacer height="30" />
<rich:scrollableDataTable rowKeyVar="rkv" frozenColCount="1" height="400px"
width="700px" id="carList" rows="40" columnClasses="col"
value="#{dataTableScrollerBean.allCars}" var="category" sortMode="single"
binding="#{dataTableScrollerBean.table}"
selection="#{dataTableScrollerBean.selection}">
<rich:column id="make">
<f:facet name="header"><h:outputText styleClass="headerText" value="Make" /></f:facet>
<h:outputText value="#{category.make}" />
</rich:column>
<rich:column id="model">
<f:facet name="header"><h:outputText styleClass="headerText" value="Model" /></f:facet>
<h:outputText value="#{category.model}" />
</rich:column>
<rich:column id="price">
<f:facet name="header"><h:outputText styleClass="headerText" value="Price" /></f:facet>
<h:outputText value="#{category.price}" />
</rich:column>
<rich:column id="mileage">
<f:facet name="header"><h:outputText styleClass="headerText" value="Mileage" /></f:facet>
<h:outputText value="#{category.mileage}" />
</rich:column>
<rich:column width="200px" id="vin">
<f:facet name="header"><h:outputText styleClass="headerText" value="VIN" /></f:facet>
<h:outputText value="#{category.vin}" />
</rich:column>
<rich:column id="stock">
<f:facet name="header"><h:outputText styleClass="headerText" value="Stock" /></f:facet>
<h:outputText value="#{category.stock}" />
</rich:column>
</rich:scrollableDataTable>
<rich:spacer height="20px"/>
<a4j:commandButton value="Show Current Selection" reRender="table"
action="#{dataTableScrollerBean.takeSelection}"
oncomplete="javascript:Richfaces.showModalPanel('panel');"/>
</h:form>
<rich:modalPanel id="panel" autosized="true">
<f:facet name="header">
<h:outputText value="Selected Rows"/>
</f:facet>
<f:facet name="controls">
<span style="cursor:pointer" onclick="javascript:Richfaces.hideModalPanel('panel')">X</span>
</f:facet>
<rich:dataTable value="#{dataTableScrollerBean.selectedCars}" var="sel" id="table">
<rich:column>
<f:facet name="header"><h:outputText value="Make" /></f:facet>
<h:outputText value="#{sel.make}" />
</rich:column>
<rich:column id="model">
<f:facet name="header"><h:outputText value="Model" /></f:facet>
<h:outputText value="#{sel.model}" />
</rich:column>
<rich:column id="price">
<f:facet name="header"><h:outputText value="Price" /></f:facet>
<h:outputText value="#{sel.price}" />
</rich:column>
<rich:column id="mileage">
<f:facet name="header"><h:outputText value="Mileage" /></f:facet>
<h:outputText value="#{sel.mileage}" />
</rich:column>
<rich:column id="stock">
<f:facet name="header"><h:outputText value="Stock" /></f:facet>
<h:outputText value="#{sel.stock}" />
</rich:column>
</rich:dataTable>
</rich:modalPanel>
</ui:composition>
Table Sorting:
它不是一个标签,但可以为rich:column标签添加sortBy属性从而达到排序的目的。
相关推荐
IK Expression是一个开源的...http://linliangyi2007.javaeye.com/blog/337069 GoogleCode开源项目 :http://code.google.com/p/ik-expression/ GoogleCode SVN下载:http://ik-expression.googlecode.com/svn/trunk/
转载自:http://blog.163.com/spf9190@126/blog/static/50207531201091545954587/ 这段时间在做一个短信项目,需要实现短信中插入表情的功能,本一位非常困难,经过一段时间的研究,发现还是比较簡単的,现在总结...
2. **Google Code (code.google.com)** - **简介**:虽然Google Code已不再接受新项目,但其中仍有许多开源.NET项目可供参考。 - **特点**:可以找到大量的.NET开源库和技术文档。 3. **CSDN社区 (community.csdn...
矢量边界,行政区域边界,精确到乡镇街道,可直接导入arcgis使用
毕业设计
毕业设计
经验贝叶斯EB的简单例子
智慧园区,作为现代城市发展的新形态,旨在通过高度集成的信息化系统,实现园区的智能化管理与服务。该方案提出,利用智能手环、定制APP、园区管理系统及物联网技术,将园区的各类设施与设备紧密相连,形成一个高效、便捷、安全的智能网络。从智慧社区到智慧酒店,从智慧景区到智慧康养,再到智慧生态,五大应用板块覆盖了园区的每一个角落,为居民、游客及工作人员提供了全方位、个性化的服务体验。例如,智能手环不仅能实现定位、支付、求助等功能,还能监测用户健康状况,让科技真正服务于生活。而智慧景区的建设,更是通过大数据分析、智能票务、电子围栏等先进技术,提升了游客的游玩体验,确保了景区的安全有序。 尤为值得一提的是,方案中的智慧康养服务,展现了科技对人文关怀的深刻体现。通过智慧手环与传感器,自动感知老人身体状态,及时通知家属或医疗机构,有效解决了“空巢老人”的照护难题。同时,智慧生态管理系统的应用,实现了对大气、水、植被等环境要素的实时监测与智能调控,为园区的绿色发展提供了有力保障。此外,方案还提出了建立全域旅游营销平台,整合区域旅游资源,推动旅游业与其他产业的深度融合,为区域经济的转型升级注入了新的活力。 总而言之,这份智慧园区建设方案以其前瞻性的理念、创新性的技术和人性化的服务设计,为我们展示了一个充满智慧与活力的未来园区图景。它不仅提升了园区的运营效率和服务质量,更让科技真正融入了人们的生活,带来了前所未有的便捷与舒适。对于正在规划或实施智慧园区建设的决策者而言,这份方案无疑提供了一份宝贵的参考与启示,激发了他们对于未来智慧生活的无限遐想与憧憬。
数学建模相关主题资源2
内容概要:本文围绕SQL在求职和实际工作中的应用展开,详细解析了SQL的重要性及其在不同行业中不可替代的地位。文章首先强调了SQL作为“一切数据工作的起点”,是数据分析、数据挖掘等领域必不可少的技能,并介绍了SQL与其他编程语言在就业市场的对比情况。随后重点探讨了SQL在面试过程中可能出现的挑战与应对策略,具体涉及到询问澄清问题、正确选择JOIN语句类型、恰当使用GROUP BY及相关过滤条件的区别、理解和运用窗口函数等方面,并给出了详细的实例和技巧提示。另外提醒面试者要注意重复值和空值等问题,倡导与面试官及时沟通。文中引用IEEE Spectrum编程语言排行榜证明了SQL不仅广泛应用于各行各业,在就业市场上也最受欢迎。 适用人群:从事或打算转入数据科学领域(包括但不限于数据分析师、数据科学家、数据工程师等职业方向),并对掌握和深入理解SQL有一定需求的专业人士,尤其是正准备涉及SQL相关技术面试的求职者。 使用场景及目标:帮助用户明确在面对复杂的SQL查询题目时能够更加灵活应对,提高解题效率的同时确保准确性;同时让用户意识到SQL不仅仅是简单的数据库查询工具,而是贯穿整个数据处理流程的基础能力之一,进而激发他们进一步探索的热情。 其他说明:SQL在性能方面优于Excel尤其适用于大规模数据操作;各知名企业仍将其视为标准数据操作手段。此外还提供了对初学者友好的建议,针对留学生普遍面临的难题如零散的学习资料、昂贵且效果不佳的付费教程以及难以跟上的纯英教学视频给出了改进的方向。
COMSOL仿真揭示石墨烯临界耦合光吸收特性:费米能级调控下的光学性能探究,COMSOL仿真揭示石墨烯临界耦合光吸收特性:费米能级调控下的光学性能探究,COMSOL 准 BIC控制石墨烯临界耦合光吸收。 COMSOL 光学仿真,石墨烯,光吸收,费米能级可调下图是仿真文件截图,所见即所得。 ,COMSOL; 准BIC; 石墨烯; 临界耦合光吸收; 光学仿真; 费米能级可调。,COMSOL仿真:石墨烯光吸收的BIC控制与费米能级调节
Labview与Proteus串口仿真下的温度采集与报警系统:Keil单片机程序及全套视频源码解析,Labview与Proteus串口仿真温度采集及上位机报警系统实战教程:设定阈值的Keil程序源码分享,labview 和proteus 联合串口仿真 温度采集 上位机报警 设定阈值单片机keil程序 整套视频仿真源码 ,关键词:LabVIEW;Proteus;串口仿真;温度采集;上位机报警;阈值设定;Keil程序;视频仿真源码。,LabVIEW与Proteus联合串口仿真:温度采集与报警系统,Keil程序与阈值设定全套视频源码
整车性能目标书:涵盖燃油车、混动车及纯电动车型的十六个性能模块目标定义模板与集成开发指南,整车性能目标书:涵盖燃油车、混动车及纯电动车型的十六个性能模块目标定义模板与集成开发指南,整车性能目标书,汽车性能目标书,十六个性能模块目标定义模板,包含燃油车、混动车型及纯电动车型。 对于整车性能的集成开发具有较高的参考价值 ,整车性能目标书;汽车性能目标书;性能模块目标定义模板;燃油车;混动车型;纯电动车型;集成开发;参考价值,《汽车性能模块化目标书:燃油车、混动车及纯电动车的集成开发参考》
熵值法stata代码(含stata代码+样本数据) 面板熵值法是一种在多指标综合评价中常用的数学方法,主要用于对不同的评价对象进行量化分析,以确定各个指标在综合评价中的权重。该方法结合了熵值理论和面板数据分析,能够有效地处理包含多个指标的复杂数据。
“电子电路”仿真资源(Multisim、Proteus、PCB等)
在 GEE(Google Earth Engine)中,XEE 包是一个用于处理和分析地理空间数据的工具。以下是对 GEE 中 XEE 包的具体介绍: 主要特性 地理数据处理:提供强大的函数和工具,用于处理遥感影像和其他地理空间数据。 高效计算:利用云计算能力,支持大规模数据集的快速处理。 可视化:内置可视化工具,方便用户查看和分析数据。 集成性:可以与其他 GEE API 和工具无缝集成,支持多种数据源。 适用场景 环境监测:用于监测森林砍伐、城市扩展、水体变化等环境问题。 农业分析:分析作物生长、土地利用变化等农业相关数据。 气候研究:研究气候变化对生态系统和人类活动的影响。
内容概要:本文介绍了C++编程中常见指针错误及其解决方案,并涵盖了模板元编程的基础知识和发展趋势,强调了高效流操作的最新进展——std::spanstream。文章通过一系列典型错误解释了指针的安全使用原则,强调指针初始化、内存管理和引用安全的重要性。随后介绍了模板元编程的核心特性,展示了编译期计算、类型萃取等高级编程技巧的应用场景。最后,阐述了C++23中引入的新特性std::spanstream的优势,对比传统流处理方法展现了更高的效率和灵活性。此外,还给出了针对求职者的C++技术栈学习建议,涵盖了语言基础、数据结构与算法及计算机科学基础领域内的多项学习资源与实战练习。 适合人群:正在学习C++编程的学生、从事C++开发的技术人员以及其他想要深入了解C++语言高级特性的开发者。 使用场景及目标:帮助读者掌握C++中的指针规则,预防潜在陷阱;介绍模板元编程的相关技术和优化方法;使读者理解新引入的标准库组件,提高程序性能;引导C++学习者按照有效的路径规划自己的技术栈发展路线。 阅读建议:对于指针部分的内容,应当结合实际代码样例反复实践,以便加深理解和记忆;在研究模板元编程时,要从简单的例子出发逐步建立复杂模型的理解能力,培养解决抽象问题的能力;而对于C++23带来的变化,则可以通过阅读官方文档并尝试最新标准特性来加深印象;针对求职准备,应结合个人兴趣和技术发展方向制定合理的学习计划,并注重积累高质量的实际项目经验。
JNA、JNI, Java两种不同调用DLL、SO动态库方式读写FM1208 CPU卡示例源码,包括初始化CPU卡、创建文件、修改文件密钥、读写文件数据等操作。支持Windows系统、支持龙芯Mips、LoongArch、海思麒麟鲲鹏飞腾Arm、海光兆芯x86_Amd64等架构平台的国产统信、麒麟等Linux系统编译运行,内有jna-4.5.0.jar包,vx13822155058 qq954486673
内容概要:本文全面介绍了Linux系统的各个方面,涵盖入门知识、基础操作、进阶技巧以及高级管理技术。首先概述了Linux的特点及其广泛的应用领域,并讲解了Linux环境的搭建方法(如使用虚拟机安装CentOS),随后深入剖析了一系列常用命令和快捷键,涉及文件系统管理、用户和权限设置、进程和磁盘管理等内容。此外,还讨论了服务管理的相关指令(如nohup、systemctl)以及日志记录和轮替的最佳实践。这不仅为初学者提供了一个完整的知识框架,也为中级和高级用户提供深入理解和优化系统的方法。 适合人群:适用于有意深入了解Linux系统的学生和专业技术人员,特别是需要掌握服务器运维技能的人群。 使用场景及目标:本文适合初次接触Linux的操作员了解基本概念;也适合作为培训教材,指导学生逐步掌握各项技能。对于有一定经验的技术人员而言,则可以帮助他们巩固基础知识,并探索更多的系统维护和优化可能性。 阅读建议:建议按照文章结构循序渐进地学习相关内容,尤其是结合实际练习操作来加深记忆和理解。遇到复杂的问题时可以通过查阅官方文档或在线资源获得更多帮助。
内容概要:本文档详细介绍了企业在规范运维部门绩效管理过程中所建立的一套绩效考核制度。首先阐述了绩效考核制度设立的目的为确保绩效目标得以衡量与追踪,并确保员工与公司共同成长与发展。其次规定范围覆盖公司所有在职员工,并详细列明了从总经理到一线员工在内的不同角色的职责范围。再则描述了完整的绩效工作流程,即从年初开始制定绩效管理活动计划,经过与每个员工制定具体的绩效目标,在绩效考核周期之内对员工的工作进展和问题解决状况进行持续的监督跟进,并且在每周期结束前完成员工绩效的评估和反馈工作,同时利用绩效评估结果对员工作出保留或异动的相关决定,最后进行绩效管理活动总结以为来年提供参考。此外还强调了整个过程中必要的相关文档保存,如员工绩效评估表。 适合人群:企业管理层,HR专业人士及对现代企业内部运营管理感兴趣的读者。 使用场景及目标:①管理层需要理解如何规范和有效实施企业内部绩效管理,以提高公司运营效率和员工满意度;②HR人士可以通过参考此文档来优化自己公司的绩效管理体系;③对企业和组织管理有兴趣的研究员亦可借鉴。 阅读建议:读者应重点关注各个层级管理者和员工在整个流程中的角色和责任,以期更好地理解