📄 datatablesort.jsp
字号:
<%-- tpl:insert page="/template/jsfTemplate.jtpl" --%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="../theme/Master.css" rel="stylesheet" type="text/css">
<LINK href="../theme/new.css" rel="stylesheet">
<LINK rel="stylesheet" type="text/css" href="../theme/stylesheet.css" title="Style">
<%-- tpl:put name="headarea" --%>
<title>datatablesort.jsp</title>
<%-- /tpl:put --%>
<LINK rel="stylesheet" type="text/css" href="/JSFandSDO/theme/stylesheet.css" title="Style">
</HEAD>
<f:view>
<BODY>
<TABLE class="title" cellpadding="0">
<TBODY>
<TR>
<TD class="noBorder" background="../images/gradient.jpg"
align="CENTER"><IMG border="0" src="../images/title.jpg"></TD>
</TR>
<TR>
<TD class="noBorder" align="RIGHT"><A href="/JSFandSDO">Return to Main Menu</A></TD>
</TR>
</TBODY>
</TABLE>
<%-- tpl:put name="bodyarea" --%>
<hx:scriptCollector id="scriptCollector1" preRender="#{pc_Datatablesort.onPageLoadBegin}">
<h:form styleClass="form" id="form1">
<H2>Sorting information in a Data table</H2>This sample contains a data table with sortable columns.<BR>
<P><h:dataTable id="table1" value="#{pc_Datatablesort.datatablesort}" var="vardatatablesort" styleClass="dataTable" headerClass="headerClass" footerClass="footerClass" rowClasses="rowClass1, rowClass2" columnClasses="columnClass1" border="1" cellpadding="2" cellspacing="0">
<h:column id="column1">
<f:facet name="header">
<h:commandLink styleClass="commandLink" id="link5" action="#{pc_Datatablesort.doLink1Action}">
<h:outputText styleClass="outputText" value="Id" id="text1"></h:outputText>
<f:param name="CAT" value="ID"></f:param>
</h:commandLink>
</f:facet>
<h:outputText id="text2" value="#{vardatatablesort.ID}" styleClass="outputText">
<f:convertNumber />
</h:outputText>
</h:column>
<h:column id="column2">
<f:facet name="header">
<h:commandLink styleClass="commandLink" id="link4" action="#{pc_Datatablesort.doLink1Action}">
<h:outputText styleClass="outputText" value="Category" id="text3"></h:outputText>
<f:param name="CAT" value="CATEGORY"></f:param>
</h:commandLink>
</f:facet>
<h:outputText id="text4" value="#{vardatatablesort.CATEGORY}" styleClass="outputText">
</h:outputText>
</h:column>
<h:column id="column3">
<f:facet name="header">
<h:commandLink styleClass="commandLink" id="link3" action="#{pc_Datatablesort.doLink1Action}">
<h:outputText styleClass="outputText" value="Title" id="text5"></h:outputText>
<f:param name="CAT" value="TITLE"></f:param>
</h:commandLink>
</f:facet>
<h:outputText id="text6" value="#{vardatatablesort.TITLE}" styleClass="outputText">
</h:outputText>
</h:column>
<h:column id="column4">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Description" id="text7"></h:outputText>
</f:facet>
<h:outputText id="text8" value="#{vardatatablesort.DESCRIPTION}" styleClass="outputText">
</h:outputText>
</h:column>
<h:column id="column5">
<f:facet name="header">
<h:commandLink styleClass="commandLink" id="link2" action="#{pc_Datatablesort.doLink1Action}">
<h:outputText styleClass="outputText" value="Price" id="text9"></h:outputText>
<f:param name="CAT" value="PRICE"></f:param>
</h:commandLink>
</f:facet>
<h:outputText id="text10" value="#{vardatatablesort.PRICE}" styleClass="outputText">
<f:convertNumber type="currency" />
</h:outputText>
</h:column>
<h:column id="column6">
<f:facet name="header">
<h:commandLink styleClass="commandLink" id="link1" action="#{pc_Datatablesort.doLink1Action}">
<h:outputText styleClass="outputText" value="Quantity" id="text11"></h:outputText>
<f:param name="CAT" value="QUANTITY"></f:param>
</h:commandLink>
</f:facet>
<h:outputText id="text12" value="#{vardatatablesort.QUANTITY}" styleClass="outputText">
<f:convertNumber />
</h:outputText>
</h:column>
</h:dataTable></P>
<h:inputHidden id="text13" value="#{requestScope.direction}"></h:inputHidden>
<H4>How it works:</H4>To perform the sort command-hyperlinks were created for each of the column headings, by:<BR>1. Open the Source Editor view for the page and finding the column you want to add the command-hyperlink to.<BR>2. Drag a command-hyper link into the column heading tag.<BR>3. Return to the Page Designer and open the link's Properties view.<BR>4. Go to the Parameter tab and select "Add Parameter" and enter the value for your parameter. In this example we assign it the name of our column heading. <BLOCKQUOTE>Example:<BR><h:column id="column1"><BR> <f:facet name="header"><BR> <h:commandLink styleClass="commandLink" id="link5" action="#{pc_Datatablesort.doLink1Action}"><BR> <h:outputText styleClass="outputText" value="Id" id="text1"></h:outputText><BR> <f:param name="CAT" value="ID"></f:param><BR> </h:commandLink><BR> </f:facet><BR> <h:outputText id="text2" value="#{vardatatablesort.ID}" styleClass="outputText"><BR> <f:convertNumber /></h:outputText><BR> </h:column></BLOCKQUOTE>When a column heading is selected by a user it passes its parameter to the action method and is used to determine which column needs to be sorted. <BR>
<BR>You must implement an action method to modify the metadata used to perform the SDO query and add additional Order By statements to it. View the action method for the command-hyperlinks to see how this is done.To reuse the same action for each command-hyperlink you can drag the action from the Page Data View onto each command-hyperlink which you want to perform that action.<BR>
<BR>In this example we store the order of the sort (ascending/descending) in a hidden field and a request scope variable. When a column heading is clicked its value is used to determine the order the data is returned.<BR>
<BR>If you want to statically sort a data table:<BR>1. Right-click the SDO object in the Page Data view used to access the database and click Configure.<BR>2. At the last step click the "Order results" link to open the "Orders" window.<BR>3. In the Available Columns list, select the column(s) you want to order the results by.
<H4>Files of Interest:</H4>
<UL>
<LI><B>WebContent/datatablesort/datatablesort.jsp</B> - (This Page) Where the JSF tags are located.</LI>
<LI><B>src/pagecode.datatablesort.Datatablesort.java</B> - Where action method for the sort is taking place.</LI>
</UL>
</h:form>
</hx:scriptCollector>
<%-- /tpl:put --%>
<TABLE class="title" cellpadding="0">
<TBODY>
<TR>
<TD class="noBorder" align="RIGHT"><A href="/JSFandSDO">Return to Main Menu</A></TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</f:view>
</HTML><%-- /tpl:insert --%>
<%-- jsf:pagecode language="java" location="/src/pagecode/datatablesort/Datatablesort.java" --%><%-- /jsf:pagecode --%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -