⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rowactionedit.jsp

📁 IBM RSA下的JSF开发示例
💻 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>rowActionEdit.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>Update records using Data Table Row Edit and Concurrency Control</H2>This sample demonstrates using   the row edit and concurrency controls of a data table.
The row edit control creates an Edit button in each row of a data table. When the edit button is clicked, a window opens  that allows the user to edit the contents of that row.
<H4>Employee List - Using a JavaBean</H4>
					<h:dataTable id="table2"
						value="#{pc_RowActionEdit.employee.employees}" var="varemployees"
						styleClass="dataTable" headerClass="headerClass"
						footerClass="footerClass" rowClasses="rowClass1, rowClass2"
						columnClasses="columnClass1" border="1" cellpadding="2"
						cellspacing="0">
						<h:column id="column13">
							<hx:commandExRowEdit styleClass="commandExRowEdit" id="rowEdit2">
								<hx:jspPanel id="jspPanel2">
									<TABLE>
										<TBODY>
											<TR>
												<TD align="left">Department</TD>
												<TD><h:inputText id="text30"
													value="#{varemployees.department}" styleClass="inputText">
												</h:inputText></TD>
											</TR>
											<TR>
												<TD align="left">Id</TD>
												<TD><h:inputText id="text31" value="#{varemployees.id}"
													styleClass="inputText">
												</h:inputText></TD>
											</TR>
											<TR>
												<TD align="left">Name</TD>
												<TD><h:inputText id="text32" value="#{varemployees.name}"
													styleClass="inputText">
												</h:inputText></TD>
											</TR>
										</TBODY>
									</TABLE>
								</hx:jspPanel>
							</hx:commandExRowEdit>
							<f:facet name="header"></f:facet>
						</h:column>
						<h:column id="column10">
							<f:facet name="header">
								<h:outputText styleClass="outputText" value="Employee ID"
									id="text23"></h:outputText>
							</f:facet>
							<h:outputText id="text25" value="#{varemployees.id}"
								styleClass="outputText">
							</h:outputText>
						</h:column>
						<h:column id="column11">
							<f:facet name="header">
								<h:outputText styleClass="outputText" value="Name" id="text26"></h:outputText>
							</f:facet>
							<h:outputText id="text27" value="#{varemployees.name}"
								styleClass="outputText">
							</h:outputText>
						</h:column>
						<h:column id="column12">
							<f:facet name="header">
								<h:outputText styleClass="outputText" value="Department"
									id="text28"></h:outputText>
							</f:facet>
							<h:outputText id="text29" value="#{varemployees.department}"
								styleClass="outputText">
							</h:outputText>
						</h:column>
					</h:dataTable>
					<BR>To add row edit to a data table:<BR>1. Select the data table in Page Designer and open its Properties view.<BR>2. On the Row Actions tab,   click &quot;Add an edit column&quot;.<BR>3. Drag  fields of the existing table     directly from the Page Designer or from the Page Data view into the new column. These are the fields that the user will be able to edit.<BR>
					<BR>You do not need to add a Save or Cancel button to this column because they will be automatically created.<HR>
			<H4>Student Grade Book - Using SDO and Concurrency Control</H4>
			Concurrency control is used to prevent multiple users from editing   a data row at the same time. A collision detection column in the data model increments each time an  update is performed on a row. When a user attempts to update a row, the system checks the collision detection column to see if it has changed  between the time it was displayed on the page and the time the user attempted to update the data. If so, the users edit will not be allowed. In this example, the collision detection column is shown     under the heading &quot;Update Key&quot; to demonstrate its usage, in a normal application you would not show this.
			<P><h:dataTable id="table1" value="#{pc_RowActionEdit.viewGrades}" var="varviewGrades" styleClass="dataTable" headerClass="headerClass" footerClass="footerClass" rowClasses="rowClass1, rowClass2" columnClasses="columnClass1" border="1" cellpadding="2" cellspacing="0">
				<h:column id="column8">
					<hx:commandExRowEdit styleClass="commandExRowEdit" id="rowEdit1" action="#{pc_RowActionEdit.doRowEdit1Action}">
						<hx:jspPanel id="jspPanel1">
							<TABLE>
								<TBODY>
									<TR>
										<TD align="left">Name</TD>
										<TD><h:inputText id="text16" value="#{varviewGrades.STUDENT_NAME}" styleClass="inputText">
										</h:inputText></TD>
									</TR>
									<TR>
										<TD align="left">Math</TD>
										<TD><h:inputText id="text17" value="#{varviewGrades.MATH}" styleClass="inputText">
											<f:convertNumber />
										</h:inputText></TD>
									</TR>
									<TR>
										<TD align="left">Science</TD>
										<TD><h:inputText id="text18" value="#{varviewGrades.SCIENCE}" styleClass="inputText">
											<f:convertNumber />
										</h:inputText></TD>
									</TR>
									<TR>
										<TD align="left">History</TD>
										<TD><h:inputText id="text19" value="#{varviewGrades.HISTORY}" styleClass="inputText">
											<f:convertNumber />
										</h:inputText></TD>
									</TR>
									<TR>
										<TD align="left">Writing</TD>
										<TD><h:inputText id="text20" value="#{varviewGrades.WRITING}" styleClass="inputText">
											<f:convertNumber />
										</h:inputText></TD>
									</TR>
									<TR>
										<TD align="left">Art</TD>
										<TD><h:inputText id="text21" value="#{varviewGrades.ART}" styleClass="inputText">
											<f:convertNumber />
										</h:inputText></TD>
									</TR>
									<TR>
										<TD align="left"></TD>
										<TD><h:inputHidden id="text34" value="#{varviewGrades.UPDATE_KEY}">
											<f:convertNumber />
										</h:inputHidden></TD>
									</TR>


								</TBODY>
							</TABLE>
						</hx:jspPanel>
					</hx:commandExRowEdit>
					<f:facet name="header"></f:facet>
				</h:column>
				<h:column id="column1">
					<f:facet name="header">
						<h:outputText styleClass="outputText" value="Student ID" id="text1"></h:outputText>
					</f:facet>
					<h:outputText id="text2" value="#{varviewGrades.STUDENT_ID}" styleClass="outputText">
						<f:convertNumber />
					</h:outputText>
				</h:column>
				<h:column id="column2">
					<f:facet name="header">
						<h:outputText styleClass="outputText" value="Name" id="text3"></h:outputText>
					</f:facet>
					<h:outputText id="text4" value="#{varviewGrades.STUDENT_NAME}" styleClass="outputText">
					</h:outputText>
				</h:column>
				<h:column id="column3">
					<f:facet name="header">
						<h:outputText styleClass="outputText" value="Math" id="text5"></h:outputText>
					</f:facet>
					<h:outputText id="text6" value="#{varviewGrades.MATH}" styleClass="outputText">
						<f:convertNumber />
					</h:outputText>
				</h:column>
				<h:column id="column4">
					<f:facet name="header">
						<h:outputText styleClass="outputText" value="Science" id="text7"></h:outputText>
					</f:facet>
					<h:outputText id="text8" value="#{varviewGrades.SCIENCE}" styleClass="outputText">
						<f:convertNumber />
					</h:outputText>
				</h:column>
				<h:column id="column5">
					<f:facet name="header">
						<h:outputText styleClass="outputText" value="History" id="text9"></h:outputText>
					</f:facet>
					<h:outputText id="text10" value="#{varviewGrades.HISTORY}" styleClass="outputText">
						<f:convertNumber />
					</h:outputText>
				</h:column>
				<h:column id="column6">
					<f:facet name="header">
						<h:outputText styleClass="outputText" value="Writing" id="text11"></h:outputText>
					</f:facet>
					<h:outputText id="text12" value="#{varviewGrades.WRITING}" styleClass="outputText">
						<f:convertNumber />
					</h:outputText>
				</h:column>
				<h:column id="column7">
					<f:facet name="header">
						<h:outputText styleClass="outputText" value="Art" id="text13"></h:outputText>
					</f:facet>
					<h:outputText id="text14" value="#{varviewGrades.ART}" styleClass="outputText">
						<f:convertNumber />
					</h:outputText>
				</h:column>
				<h:column id="column9">
					<f:facet name="header">
						<h:outputText styleClass="outputText" value="Update Key" id="text15"></h:outputText>
					</f:facet>
					<h:outputText id="text22" value="#{varviewGrades.UPDATE_KEY}" styleClass="outputText">
						<f:convertNumber />
					</h:outputText>
				</h:column>
			</h:dataTable></P>
			<h:messages styleClass="errorMessage" id="messages1"></h:messages>
			<h:commandLink styleClass="commandLink" id="link3">
				<h:outputText id="text35" styleClass="outputText" value="Refresh Page"></h:outputText>
			</h:commandLink>
			<BR>
			<BR>To cause a collision to take place:<BR>
			1. Open this page in a second browser window.<BR>
			2. Edit one of the records on the second page.<BR>
			3. Return to the first page and attempt to edit the same record. <BR>
					<BR>This will cause a collision detection error message to be displayed below the data table.<H4>How It works:</H4>To add concurrency control to new relational record list:<BR>1. In the Advanced Tasks page of the creation wizard, select &quot;Concurrency Control&quot;.<BR>2. Select a non-null Integer column from your database to be the collision detection column.<BR>3. Add a hidden input field to your page and bind its Value attribute to the collision detection column (UPDATE_KEY) in the database.
					<BR>
					<BR>You may also add concurrency control to an existing relational record list by right-clicking on it in the Page Data View and selecting Configure.  At the last step click the &quot;Set concurrency control&quot; link, it opens the  Concurrency window      and allows you to select the collision detection column.<BR><BLOCKQUOTE>
			<P class="code">Example:<BR>&lt;hx:commandExRowEdit styleClass=&quot;commandExRowEdit&quot; id=&quot;rowEdit1&quot; action=&quot;#{pc_RowActionEdit.doRowEdit1Action}&quot;&gt;<BR>
					&lt;hx:jspPanel id=&quot;jspPanel1&quot;&gt;<BR>
					&lt;TABLE&gt;&lt;TBODY&gt;<BR>
					&lt;TR&gt;&lt;TD align=&quot;left&quot;&gt;Name&lt;/TD&gt;<BR>
					&lt;TD&gt;&lt;h:inputText id=&quot;text16&quot; value=&quot;#{varviewGrades.STUDENT_NAME}&quot; styleClass=&quot;inputText&quot;&gt;<BR>
					&lt;/h:inputText&gt;&lt;/TD&gt;&lt;/TR&gt;<BR>
					............................................................................................<BR>
					&lt;TR&gt;&lt;TD align=&quot;left&quot;&gt;&lt;/TD&gt;<BR>
					&lt;TD&gt;&lt;h:inputHidden id=&quot;text34&quot; value=&quot;#{varviewGrades.UPDATE_KEY}&quot;&gt;<BR>
					&lt;f:convertNumber /&gt;<BR>
					&lt;/h:inputHidden&gt;&lt;/TD&gt;&lt;/TR&gt;<BR>&lt;/TBODY&gt;&lt;/TABLE&gt;<BR>
					&lt;/hx:jspPanel&gt;<BR>
					&lt;/hx:commandExRowEdit&gt;
					</P>
			</BLOCKQUOTE>
			<H4>Files
			of Interest:</H4>
			<UL>
				<LI><B>WebContent/rowActions/rowActionEdit.jsp</B> - (This Page) Where the JSF
				source code to create these tables and set the value to display the
				details table is located.</LI>
				<LI><B>src/pagecode.rowActions.rowActionEdit.java</B> - Where
				the row edit logic is performed.(This can also be viewed from the
				Quick Edit View.)</LI>
				<LI><B>src/com.ibm.samples.rowActionSelect.EmployeeBean.java -</B>The
				bean where Employee information is stored.</LI>
				<LI><B>src/com.ibm.samples.rowActionSelect.RowEditBean.java </B>- The
				bean the holds the Employee Beans.</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/rowActions/RowActionEdit.java" --%><%-- /jsf:pagecode --%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -