📄 rowactionselect.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>rowActionSelect.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">
<h:form styleClass="form" id="form1">
<H2>Performing Actions on Multiple Data Table Rows</H2>
This sample demonstrates the row select control of the data table which is used to perform actions simultaneously on multiple rows. When a data table uses row select, a column of check boxes is automatically created which allows the user to select multiple rows of a table. When a command-button is pressed the selected rows are determined and an action is performed on them.<BR>
<BR>
Each exercise shows a different way to determine which rows have been selected using the row select column. The data table in exercise 1 is populated by a JavaBean. The data tables in exercises 2 - 4 use Service Data Objects (SDO) connected to a Derby database to create the relational record lists. In each exercise you can delete rows in the table and in exercise 4 you can perform a simple update on the data. The code for these actions can be viewed by opening the Quick Edit view of the command-button you are interested in.<H4>Exercise 1 - Employees</H4>This data table uses a Boolean column in the data model to determine which check boxes are selected.<BLOCKQUOTE><P class="code">Example:<BR><h:column id="column22"><BR> <hx:inputRowSelect styleClass="inputRowSelect" id="rowSelect4" value="#{varemployees.selected}"><BR>
</hx:inputRowSelect><BR> <f:facet name="header"></f:facet><BR> </h:column></P></BLOCKQUOTE>
<P>
<h:dataTable id="table4" value="#{pc_RowActionSelect.selectedRow.employees}" var="varemployees" styleClass="dataTable" headerClass="headerClass" footerClass="footerClass" rowClasses="rowClass1, rowClass2" border="1" cellpadding="3" cellspacing="0" columnClasses="colClass1">
<h:column id="column22">
<%--Row Select column and its parameter --%>
<hx:inputRowSelect styleClass="inputRowSelect" id="rowSelect4" value="#{varemployees.selected}"></hx:inputRowSelect>
<f:facet name="header"></f:facet>
</h:column>
<h:column id="column23">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Employee ID" id="text39"></h:outputText>
</f:facet>
<h:outputText id="text40" value="#{varemployees.id}" styleClass="outputText">
</h:outputText>
</h:column>
<h:column id="column24">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Name" id="text41"></h:outputText>
</f:facet>
<h:outputText id="text42" value="#{varemployees.name}" styleClass="outputText">
</h:outputText>
</h:column>
<h:column id="column25">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Department" id="text43"></h:outputText>
</f:facet>
<h:outputText id="text44" value="#{varemployees.department}" styleClass="outputText">
</h:outputText>
</h:column>
</h:dataTable></P>
<hx:commandExButton type="submit" value="Delete Selected Records" styleClass="commandExButton"
id="buttonDelete1" action="#{pc_RowActionSelect.doButtonDelete1Action}"></hx:commandExButton><HR>
<H4>Exercise 2 - Inventory</H4>
This data table uses an array of integers to bind the check boxes to the backing bean. The resulting array contains the row index of all selected rows.<BLOCKQUOTE><P class="code">Example: <BR><h:column id="column9"><BR><hx:inputRowSelect styleClass="inputRowSelect" id="rowSelect1" value="{pc_RowActionSelect.selectedRow.intRows}"><BR> </hx:inputRowSelect><BR> <f:facet name="header"></f:facet><BR> </h:column></P></BLOCKQUOTE><P><h:dataTable id="table1" value="#{pc_RowActionSelect.selectRecords}" var="varselectRecords" styleClass="dataTable" headerClass="headerClass" footerClass="footerClass" rowClasses="rowClass1, rowClass2" columnClasses="columnClass1" border="1" cellpadding="3" cellspacing="0">
<h:column id="column9">
<%--Row Select column --%>
<hx:inputRowSelect styleClass="inputRowSelect" id="rowSelect1" value="#{pc_RowActionSelect.selectedRow.intRows}">
</hx:inputRowSelect>
<f:facet name="header"></f:facet>
</h:column>
<h:column id="column1">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Product ID" id="text1"></h:outputText>
</f:facet>
<h:outputText id="text2" value="#{varselectRecords.ID}" styleClass="outputText">
<f:convertNumber />
</h:outputText>
</h:column>
<h:column id="column2">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Type" id="text3"></h:outputText>
</f:facet>
<h:outputText id="text4" value="#{varselectRecords.CATEGORY}" styleClass="outputText">
</h:outputText>
</h:column>
<h:column id="column3">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Title" id="text5"></h:outputText>
</f:facet>
<h:outputText id="text6" value="#{varselectRecords.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="#{varselectRecords.DESCRIPTION}" styleClass="outputText">
</h:outputText>
</h:column>
<h:column id="column5">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Price" id="text9"></h:outputText>
</f:facet>
<h:outputText id="text10" value="#{varselectRecords.PRICE}" styleClass="outputText">
<f:convertNumber type="currency" />
</h:outputText>
</h:column>
<h:column id="column6">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Quantity" id="text11"></h:outputText>
</f:facet>
<h:outputText id="text12" value="#{varselectRecords.QUANTITY}" styleClass="outputText">
<f:convertNumber />
</h:outputText>
</h:column>
</h:dataTable></P>
<hx:commandExButton type="submit" value="Delete Selected Records" styleClass="commandExButton" id="button1" action="#{pc_RowActionSelect.doButtonDelete2Action}"></hx:commandExButton>
<br>
<BR>
<table>
<tbody>
<tr>
<td align="left">Id:</td>
<td style="width:5px"> </td>
<td align="left">Category:</td>
<td style="width:5px"> </td>
<td align="left">Title:</td>
<td style="width:5px"> </td>
<td align="left">Price:</td>
<td style="width:5px"> </td>
<td align="left">Quantity:</td>
<td style="width:5px"> </td>
<td align="left">Description:</td>
<td style="width:5px"> </td>
</tr>
<tr>
<td><h:inputText id="textId2"
value="#{pc_RowActionSelect.addInventory_2.ID}"
styleClass="inputText" size="5">
<hx:convertNumber />
</h:inputText></td>
<td style="width:5px"> </td>
<td><h:inputText id="textCategory1"
value="#{pc_RowActionSelect.addInventory_2.CATEGORY}"
styleClass="inputText" size="20">
</h:inputText></td>
<td style="width:5px"> </td>
<td><h:inputText id="textTitle1"
value="#{pc_RowActionSelect.addInventory_2.TITLE}"
styleClass="inputText" size="25">
</h:inputText></td>
<td style="width:5px"> </td>
<td><h:inputText id="textPrice1"
value="#{pc_RowActionSelect.addInventory_2.PRICE}"
styleClass="inputText" size="7">
<hx:convertNumber />
</h:inputText></td>
<td style="width:5px"> </td>
<td><h:inputText id="textQuantity1"
value="#{pc_RowActionSelect.addInventory_2.QUANTITY}"
styleClass="inputText" size="7">
<hx:convertNumber />
</h:inputText></td>
<td style="width:5px"> </td>
<td><h:inputText id="textDescription1"
value="#{pc_RowActionSelect.addInventory_2.DESCRIPTION}"
styleClass="inputText" size="50">
</h:inputText></td>
<td style="width:5px"> </td>
</tbody>
</table>
<h:messages styleClass="messages" id="messages2" style="color: red"></h:messages>
<br />
<hx:commandExButton id="buttonDoAddInventory_2UpdateAction1"
styleClass="commandExButton" type="submit" value="Add a Record"
action="#{pc_RowActionSelect.doAddInventory_2UpdateAction}">
</hx:commandExButton>
<BR>
<HR>
<H4>Exercise 3 - Customers</H4>This data table uses an array of Booleans to bind the check boxes to the backing bean. The resulting array contains an entry for every row of the table and is set to true if that row is selected.<BLOCKQUOTE>
<P class="code">Example:<BR>
<h:column id="column15"><BR>
<hx:inputRowSelect styleClass="inputRowSelect"
id="rowSelect2"
value="#{pc_RowActionSelect.selectedRow.boolRows}"><BR>
</hx:inputRowSelect><BR>
<f:facet name="header"></f:facet><BR>
</h:column></P>
</BLOCKQUOTE>
<P><h:dataTable id="table2"
value="#{pc_RowActionSelect.customers}" var="varcustomers"
styleClass="dataTable" headerClass="headerClass"
footerClass="footerClass" rowClasses="rowClass1, rowClass2"
columnClasses="columnClass1" border="1" cellpadding="3"
cellspacing="0">
<h:column id="column15">
<%--Row Select column --%>
<hx:inputRowSelect styleClass="inputRowSelect" id="rowSelect2"
value="#{pc_RowActionSelect.selectedRow.boolRows}"></hx:inputRowSelect>
<f:facet name="header"></f:facet>
</h:column>
<h:column id="column10">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Customer ID"
id="text17"></h:outputText>
</f:facet>
<h:outputText id="text18" value="#{varcustomers.ID}"
styleClass="outputText">
<f:convertNumber />
</h:outputText>
</h:column>
<h:column id="column11">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Name" id="text19"></h:outputText>
</f:facet>
<h:outputText id="text20" value="#{varcustomers.NAME}"
styleClass="outputText">
</h:outputText>
</h:column>
<h:column id="column12">
<f:facet name="header">
<h:outputText styleClass="outputText" value="Address"
id="text21"></h:outputText>
</f:facet>
<h:outputText id="text22" value="#{varcustomers.ADDRESS}"
styleClass="outputText">
</h:outputText>
</h:column>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -