JSF3 All.jsf EA977

时间:2011-12-28 12:19来源:http://www.saifuchina.com 作者:晒后如何快速美白 点击:
%@ taglib uri=http://java.sun.com/jsf/html prefix=h % %@ taglib uri=http://java.sun.com/jsf/core prefix=f % %@ taglib uri=https://ajax4jsf.dev.java.net/ajax prefix=a4j % %@ taglib uri=http://richfaces.ajax4jsf.org/rich prefix=rich % html hea
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j" %>
<%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich" %>
<html>
<head>
<title></title>
</head>
<body>
<f:view>
<rich:dataTable var="person" value="#{persons.persons}">
<f:facet name="header">
<rich:columnGroup>
<rich:column rowspan="2">
<rich:spacer />
</rich:column>
<rich:column colspan="9">
<h:outputText value="Persons" />
</rich:column>
<rich:column breakBefore="true">
<h:outputText value="ID" />
</rich:column>
<rich:column>
<h:outputText value="Sex" />
</rich:column>
<rich:column>
<h:outputText value="FirstName" />
</rich:column>
<rich:column colspan="3">
<h:outputText value="LastName" />
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:column colspan="1">
<rich:spacer />
</rich:column>
<rich:column>
<h:outputText value="#{person.id}" />
</rich:column>
<rich:column>
<h:outputText value="#{person.**}" />
</rich:column>
<rich:column>
<h:outputText value="#{person.first_name}" />
</rich:column>
<rich:column >
<h:outputText value="#{person.last_name}" />
</rich:column>
</rich:dataTable>
<h:form>
<p>
<h:outputLabel for="inputID">
<h:outputText value="Enter a PersonID" />
</h:outputLabel>
<h:inputText value="0" id="inputID" required="true">
<f:validateLongRange minimum="0" maximum="100"/>
</h:inputText>
</p>
<p>
<h:outputLabel for="inputSex">
<h:outputText value="Enter a Person SexName" />
</h:outputLabel>
<h:inputText id="inputSex"/>
</p>
<p>
<h:outputLabel for="inputFName">
<h:outputText value="Enter a Person FirstName" />
</h:outputLabel>
<h:inputText id="inputFName"/>
</p>
<p>
<h:outputLabel for="inputLName">
<h:outputText value="Enter a Person LastName" />
</h:outputLabel>
<h:inputText id="inputLName"/>
</p>
<h:commandButton value="Apply" type="submit"/>
<h:commandButton value="Clear" type="submit"/>
</h:form>
<h:form>
<style>
.label{
font-weight:bold;
}
</style>
<rich:dataList var="test1" value="#{persons.persons}" rows="10">
<h:outputText value="#{test1.first_name} #{test1.last_name}"/><br/>
<h:outputText value=" ID" styleClass="label"/>
<h:outputText value=" #{test1.id}" />
<h:outputText value=" Sex" styleClass="label"/>
<h:outputText value=" #{test1.**}" />
<h:outputText value=" FirstName" styleClass="label"/>
<h:outputText value=" #{test1.first_name}" />
<h:outputText value=" LastName" styleClass="label"/>
<h:outputText value=" #{test1.last_name}" />
</rich:dataList>
</h:form>
<a4j:region>
<h:form>
<rich:panel>
<a4j:commandButton id="setAlex" value="setName to Alex" reRender="rep" actionListener="#{person.process}">
<a4j:actionparam name="username" value="Alex" assignTo="#{person.first_name}" />
</a4j:commandButton>
<a4j:commandButton id="setJohn" value="setName to John" reRender="rep" actionListener="#{person.process}">
<a4j:actionparam name="username" value="John" assignTo="#{person.first_name}" />
</a4j:commandButton>
<rich:spacer width="20" />
<rich:panel>
<h:outputText id="rep" value="Selected Name: #{person.first_name}" />
</rich:panel>
</rich:panel>
</h:form>
</a4j:region>
<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 action="#{person.nameJohn}" value="set Name to John(Ajax)" />
<h:outputText id="name" value="Name #{person.first_name}" />
</h:panelGrid>
</a4j:form>
</rich:panel>
<rich:panel>
<f:facet name="header">
<h:outputText value="Form with ajaxSubmit equals True" />
</f:facet>
<a4j:form ajaxSubmit="false" reRender="name">
<h:panelGrid >
<h:commandButton action="#{person.nameWang}" value="set Name to Wang(Ajax)" />
<h:outputText id="name" value="Name #{person.first_name}" />
</h:panelGrid>
</a4j:form>
</rich:panel>
</h:panelGrid>
<rich:separator height="1" />
<a4j:outputPanel ajaxRendered="false">
<h:messages style="color:red" />
</a4j:outputPanel>
<h:panelGrid columns="2" width="100%">
<h:form id="form1">
<h:panelGrid columns="2">
<h:outputText value="Name" />
<h:inputText value="#{person.name}">
<a4j:support event="onkeyup" reRender="outname" />
</h:inputText>
<h:outputText value="Job:" />
<h:inputText required="true" id="job2" value="#{person.job}" />
</h:panelGrid>
</h:form>
<h:form id="form2">
<h:panelGrid columns="2">
<h:outputText value="Name" />
<a4j:region>
<h:inputText value="#{person.name}">
<a4j:support event="onkeyup" reRender="outname" />
</h:inputText>
</a4j:region>
<h:outputText value="Job" />
<h:inputText required="true" id="job1" value="#{person.job}" />
</h:panelGrid>
</h:form>
</h:panelGrid>
<h:outputText id="outname" style="font-weight:bold" value="Typed Name: #{person.name}" />
<rich:separator style="padding-top:10px" height="1" />
<rich:separator height="1" />
<h:panelGrid columns="2" width="100%">
<a4j:region selfRendered="true">
<h:panelGroup>
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Name" />
<h:inputText value="#{person.name}">
<a4j:support event="onkeyup" reRender="out3,outname2" />
</h:inputText>
</h:panelGrid>
</h:form>
<h:panelGroup id="out3">
This text will disappear during the partial update of this panel.
The text appears again only after the whole page refresh or a partial
update from the region with selfRendered="false" (default value).
</h:panelGroup>
</h:panelGroup>
</a4j:region>
<a4j:region selfRendered="false">
<h:panelGroup>
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Name" />
<h:inputText value="#{person.name}">
<a4j:support event="onkeyup" reRender="out4,outname2" />
</h:inputText>
</h:panelGrid>
</h:form>
<h:panelGroup id="out4">
<h:outputText value="The text of the similar panel will
not disappear because it is printed with h:outputText" />
</h:panelGroup>
</h:panelGroup>
</a4j:region>
</h:panelGrid>
<h:outputText id="outname2" style="font-weight:bold"
value="Typed Name: #{person.name}" />
<rich:separator style="padding-top:10px" height="1" />
</f:view>
</body>
</html>
(责任编辑:http://www.saifuchina.com)
------分隔线----------------------------