核心标签库课件_第1页
核心标签库课件_第2页
核心标签库课件_第3页
核心标签库课件_第4页
核心标签库课件_第5页
已阅读5页,还剩39页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第八章JSF标签第八章JSF标签回顾导航规则定义了如何在应用程序中从特定页面导航至另一个页面静态导航是单一的结果映射。在静态导航中,单击指定按钮总是选择固定的页面来呈现响应navigation-rule元素最重要的两个子元素是from-view-id和navigation-case。navigation-case元素最重要的两个子元素是from-outcome和to-view-id动态导航是多个结果映射要实现动态导航,按钮或链接必须有一个方法引用,以用于调用相应的方法,导航处理器根据方法返回的字符串来匹配导航规则2回顾导航规则定义了如何在应用程序中从特定页面导航至另一个页面目标熟悉HTML标签库熟悉核心标签库在应用程序中使用标签库熟练使用数据表格标签3目标熟悉HTML标签库3JSF标签库Taglib指令JSF核心标签库JSFHTML标签库<%@tagliburi="/jsf/core"prefix="f"%><%@tagliburi="/jsf/html"prefix="h"%>使用JSF标签<%@tagliburi="/jsf/core"

prefix="f"%><%@tagliburi="/jsf/html"prefix="h"%><f:view><h:form>...</h:form></f:view>4JSF标签库Taglib指令JSF核心标签库JSFHJSF核心标签标签说明view创建顶层视图subview创建视图的子视图facet向组件添加facetparam向组件添加参数attribute向组件添加属性actionListener在父组件上注册操作监听器valueChangeListener向父组件注册值变更监听器converter注册任意转换器convertDateTime注册日期时间转换器convertNumber注册数量转换器标签说明validateLength验证组件值的长度validateDoubleRange验证组件值的双精度范围validateLongRange验证组件值的长整型范围validator向组件添加验证器loadBundle加载资源包verbatim向页面中添加标签selectItem指定UISelectOne或UISelectMany组件的一个项目selectItems指定UISelectOne或UISelectMany组件的多个项目5JSF核心标签标签说明view创建顶层视图subview创标准的转换器和验证器编写一个填写付款信息的页面,付款信息包括付款金额、信用卡号、信用卡有效期,要求对输入的数据进行特定的转换和验证8899123456789876512/20056标准的转换器和验证器编写一个填写付款信息的页面,付款信息包括示例代码importjava.util.Date;publicclassPaymentBean{privatedoubleamount;privateStringcard="";

privateDatedate=newDate();publicvoidsetAmount(doublenewValue){amount=newValue;}publicdoublegetAmount(){returnamount;}publicvoidsetCard(StringnewValue){card=newValue;}publicStringgetCard(){returncard;}

publicvoidsetDate(DatenewValue){date=newValue;}publicDategetDate(){returndate;}}受管理的Bean<f:view><h:form><h1><h:outputTextvalue="请输入付款信息:"/></h1><h:panelGridcolumns="3"><h:outputTextvalue="金额:"/><h:inputTextid="amount"value="#{payment.amount}">

<f:convertNumberminFractionDigits="2"/><f:validateDoubleRangeminimum="10"maximum="10000"/></h:inputText>

<h:messagefor="amount"style="color:red"/><h:outputTextvalue="信用卡号:"/><h:inputTextid="card"value="#{payment.card}">

<f:validateLengthminimum="13"/></h:inputText>

<h:messagefor="card"style="color:red"/><h:outputTextvalue="信用卡有效期(月/年):"/><h:inputTextid="date"value="#{payment.date}">

<f:convertDateTimepattern="MM/yyyy"/></h:inputText>

<h:messagefor="date"style="color:red"/></h:panelGrid><h:commandButtonvalue="处理"action="process"/></h:form></f:view>index.jsp<f:view><h:form><h1><h:outputTextvalue="付款信息"/></h1><h:panelGridcolumns="2"><h:outputTextvalue="金额:"/><h:outputTextvalue="#{payment.amount}">

<f:convertNumbertype="currency"/></h:outputText><h:outputTextvalue="信用卡号:"/><h:outputTextvalue="#{payment.card}"/><h:outputTextvalue="信用卡有效日期:"/><h:outputTextvalue="#{payment.date}"><f:convertDateTimepattern="MM/yyyy"/></h:outputText></h:panelGrid><h:commandButtonvalue="返回"action="back"/></h:form></f:view>result.jsp演示:示例17示例代码importjava.util.Date;受管理的JSFHTML标签组件标签说明UIFormform表示

HTML表单元素UIInputInputText单行文本输入控件inputTextarea多行文本输入控件InputSecret密码输入控件inputHidden隐藏字段UIOutputoutputLabel显示文本outputLink链接到另一页面或某页面上的特定位置outputFormat显示格式化的信息outputText当行文本输入UICommandcommandButton表示一个按钮commandLink表示一个链接组件标签说明UISelectOneSelectOneListbox单选列表框selectOneMenu单选菜单selectOneRadio单选按钮集UISelectBooleanselectBooleanCheckbox单个复选框UISelectManyselectManyListbox复选框集selectManyCheckbox多行选择列表框selectManyMenu多选菜单UIPanelpanelGrid表示一个

HTML表格panelGroup组合一系列组件UIMessagemessage显示一个组件的最近使用的消息UIMessagesmessages显示所有消息UIGraphicgraphicImage显示一个图像UIDatadataTable功能丰富的表格控件UIColumncolumn表示表格中的列8JSFHTML标签组件标签说明UIFormform表示表单9表单9文本输入h:inputTexth:inputSecreth:inputTextarea<h:inputTextvalue="测试字符串"readonly="true"/><h:inputSecretvalue="#{form.passwd}"redisplay="true"/><h:inputTextareavalue="123456789012345"rows="3"cols="10"/><h:inputTextvalue="inputText"style="color:Yellow;background:Teal;"/>10文本输入h:inputText<h:inputTextva命令h:commandButtonh:commandLinkh:outputLink<h:commandButtonvalue="按钮"onclick="alert('buttonclicked')"

type="button"/><h:outputLinkvalue=""><h:graphicImagevalue="java-dot-net.jpg"/><h:outputTextvalue=""/></h:outputLink><h:commandLinkvalue="欢迎"

actionListener="#{form.useLinkValue}"action="#{form.followLink}"/>11命令h:commandButton<h:commandBut选择h:selectBooleanCheckboxh:selectManyCheckboxh:selectOneRadioh:selectOneListboxh:selectManyListboxh:selectOneMenuh:selectManyMenu12选择h:selectBooleanCheckbox12选择标签使用示例联系我<h:selectBooleanCheckboxvalue="#{form.contactMe}"/>privatebooleancontactMe;publicvoidsetContactMe(booleannewValue){contactMe=newValue;}publicbooleangetContactMe(){returncontactMe;}<h:selectManyCheckboxvalue="#{form.colors}"><f:selectItem

itemValue="Red"itemLabel="红色"/><f:selectItemitemValue="Blue"itemLabel="蓝色"/><f:selectItemitemValue="Yellow"itemLabel="黄色"/><f:selectItemitemValue="Green"itemLabel="绿色"/><f:selectItemitemValue="Orange"itemLabel="橘黄"/></h:selectManyCheckbox><h:selectOneRadiovalue="#{form.grade}"layout="pageDirection"><f:selectItemsvalue="#{form.grades}"/></h:selectOneRadio>privateSelectItem[]grades={newSelectItem(newInteger(1),"高中"),newSelectItem(newInteger(2),"专科"),newSelectItem(newInteger(3),"本科"),newSelectItem(newInteger(4),"硕士"),newSelectItem(newInteger(5),"博士")};publicSelectItem[]getGrades(){returngrades;}<h:selectOneListboxid="onelistbox"value="#{form.expert}"><f:selectItemitemValue="java"itemLabel="Java"/><f:selectItemitemValue="oracle"itemLabel="Oracle"/><f:selectItemitemValue="asp"itemLabel="ASP"/><f:selectItemitemValue="jsp"itemLabel="JSP"/></h:selectOneListbox><h:selectOneMenuid="onemenu"value="#{form.expert}"><f:selectItemitemValue="java"itemLabel="Java"/><f:selectItemitemValue="oracle"itemLabel="Oracle"/><f:selectItemitemValue="asp"itemLabel="ASP"/><f:selectItemitemValue="jsp"itemLabel="JSP"/></h:selectOneMenu>演示:示例213选择标签使用示例联系我privatebooleancon数据表格标签UIData组件表示h:dataTable标签,它支持将数据绑定到数据对象集合,遍历数据源中的每个记录表内的数据列由UIColumn组件表示,即h:column标签属性说明bgcolor

设置表格背景色border设置表格边框宽度cellpadding设置表格单元格周围的边距cellspacing设置表格单元格之间的间距first表格中所显示的第一行的索引frame指定表格四周的边框样式;有效值:none、above、below、hsides、vsides、lhs、rhs、box、borderstyleClass指定整个表格的CSS类rowClasses行的CSS类列表,用逗号分隔列表columnClasses列的CSS类列表,用逗号分隔列表headerClass

表格标题的CSS类footerClass用于表格页脚的CSS类rules单元格之间的行样式;有效值:groups、rows、columns、allvar数据表格所创建的变量名称,表示该值中的当前项目14数据表格标签UIData组件表示h:dataTable数据表格使用示例1在网页中输出一个简单的表格,显示一个职员的姓名和职位15数据表格使用示例1在网页中输出一个简单的表格,显示一个职员的publicclassEmployeeList{privateStringname;privateStringposition;publicEmployeeList(Stringname,Stringposition){=name;this.position=position;}publicvoidsetName(Stringname){=name;}publicvoidsetPosition(Stringposition){this.position=position;}publicStringgetName(){returnname;}publicStringgetPosition(){returnposition;}}EmployList.java示例代码publicclassData{

privatestaticfinalEmployeeList[]employeelist=newEmployeeList[]{newEmployeeList("高侠","软件工程师"),newEmployeeList("张小丽","培训师"),newEmployeeList("刘亚平","项目经理"),newEmployeeList("牛远","软件工程师")};

publicEmployeeList[]getEmployeelist(){returnemployeelist;}}受管理BeanData……<f:view><h:form><h:dataTable

bgcolor="lightblue"

value="#{Employeedata.employeelist}"var="employees"

border="5"cellpadding="5"cellspacing="2"><h:column><f:facetname="header"><h:outputTextid="headerText1"value="姓名"/></f:facet><h:outputTextvalue="#{}"/>

</h:column><h:column><f:facetname="header"><h:outputTextid="headerText2"value="职位"/>

</f:facet><h:outputTextvalue="#{employees.position}"/>

</h:column></h:dataTable></h:form></f:view>index.jsp演示:示例316publicclassEmployeeList{Emp数据表格使用示例2练习如何从数据库中提取数据,然后将查询结果显示在数据表格中。要求为数据表格设置样式17数据表格使用示例2练习如何从数据库中提取数据,然后将查询结果样式表.customers{border:thinsolidblack;}.customersHeader{text-align:center;font-style:italic;color:Snow;background:Teal;}.evenColumn{height:25px;text-align:center;background:MediumTurquoise;}.oddColumn{text-align:center;background:PowderBlue;}styleClass.css18样式表.customers{styleClass.css1受管理Bean该后台Bean负责同数据库建立连接,并查询数据publicclassCustomerBean{StringsDBDriver="com.microsoft.jdbc.sqlserver.SQLServerDriver";StringsConnStr="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=northwind";Connectionconnect=null;publicCustomerBean(){try{

Class.forName(sDBDriver);}catch(java.lang.ClassNotFoundExceptione){System.err.println(e.getMessage());}try{

connect=DriverManager.getConnection(sConnStr,"sa","");}catch(SQLExceptionex){System.err.println(ex.getMessage());}}CustomerBean.javapublicsynchronizedResultSetexecuteQuery(Stringsql){ResultSetrs=null;if(connect!=null){try{Statementstmt=connect.createStatement();rs=stmt.executeQuery(sql);}catch(SQLExceptionex){System.err.println(ex.getMessage());}}returnrs;}publicsynchronizedintexecuteUpdate(Stringsql){intrs=-1;if(connect!=null){try{Statementstmt=connect.createStatement();rs=stmt.executeUpdate(sql);}catch(SQLExceptionex){System.err.println(ex.getMessage());}}returnrs;}publicResultgetAll()throwsSQLException{try{CustomerBeanjc=newCustomerBean();Stringsql="select*fromCustomers";ResultSetrs=jc.executeQuery(sql);returnResultSupport.toResult(rs);}finally{closeConnection();}}

publicvoidcloseConnection(){if(connect!=null){try{connect.close();}catch(SQLExceptionex){System.err.println(ex.getMessage());}}}19受管理Bean该后台Bean负责同数据库建立连接,并查询数据视图页<html><head><linkhref="CSS/styles.css"rel="stylesheet"type="text/css"/><title>DisplayingDatabaseTables</title></head><body><f:view><h:form><h:dataTablevalue="#{customer.all}"var="customer"

styleClass="customers"headerClass="customersHeader"

columnClasses="evenColumn,oddColumn"><h:column><f:facetname="header"><h:outputTextvalue="CustomerID"/></f:facet><h:outputTextvalue="#{customer.CustomerID}"/></h:column><h:column><f:facetname="header"><h:outputTextvalue="Name"/></f:facet><h:outputTextvalue="#{customer.ContactName}"/></h:column>……</h:dataTable></h:form></f:view></body></html>index.jsp演示:示例420视图页<html><head>index.jsp演示:示例4总结2-1JSF提供两种标签库,即HTML标签库和核心标签库必须使用<taglib>指令可将JSF标签库导入应用程序中,才能在JSP页面中使用这两种标签库JSF核心标签库中共有18个标签。多数核心标签表示添加到组件的对象,包括属性、监听器、转换器、验证器等JSF标准HTML标签库中的标签表示了HTML表单控件和其他基本HTML元素21总结2-1JSF提供两种标签库,即HTML标签库和核总结2-2JSF标准HTML标签库可以分为下列类:表单、输入、输出、命令、选择、布局、数据表格、消息除了h:selectBooleanCheckbox以外,所有选择标签都使用多个f:selectItem标签或一个f:selectItems标签来指定它们的项目h:dataTable标签支持将数据绑定到数据对象集合数据表格中可以放置任何JSF组件22总结2-2JSF标准HTML标签库可以分为下列类:表第八章JSF标签第八章JSF标签回顾导航规则定义了如何在应用程序中从特定页面导航至另一个页面静态导航是单一的结果映射。在静态导航中,单击指定按钮总是选择固定的页面来呈现响应navigation-rule元素最重要的两个子元素是from-view-id和navigation-case。navigation-case元素最重要的两个子元素是from-outcome和to-view-id动态导航是多个结果映射要实现动态导航,按钮或链接必须有一个方法引用,以用于调用相应的方法,导航处理器根据方法返回的字符串来匹配导航规则24回顾导航规则定义了如何在应用程序中从特定页面导航至另一个页面目标熟悉HTML标签库熟悉核心标签库在应用程序中使用标签库熟练使用数据表格标签25目标熟悉HTML标签库3JSF标签库Taglib指令JSF核心标签库JSFHTML标签库<%@tagliburi="/jsf/core"prefix="f"%><%@tagliburi="/jsf/html"prefix="h"%>使用JSF标签<%@tagliburi="/jsf/core"

prefix="f"%><%@tagliburi="/jsf/html"prefix="h"%><f:view><h:form>...</h:form></f:view>26JSF标签库Taglib指令JSF核心标签库JSFHJSF核心标签标签说明view创建顶层视图subview创建视图的子视图facet向组件添加facetparam向组件添加参数attribute向组件添加属性actionListener在父组件上注册操作监听器valueChangeListener向父组件注册值变更监听器converter注册任意转换器convertDateTime注册日期时间转换器convertNumber注册数量转换器标签说明validateLength验证组件值的长度validateDoubleRange验证组件值的双精度范围validateLongRange验证组件值的长整型范围validator向组件添加验证器loadBundle加载资源包verbatim向页面中添加标签selectItem指定UISelectOne或UISelectMany组件的一个项目selectItems指定UISelectOne或UISelectMany组件的多个项目27JSF核心标签标签说明view创建顶层视图subview创标准的转换器和验证器编写一个填写付款信息的页面,付款信息包括付款金额、信用卡号、信用卡有效期,要求对输入的数据进行特定的转换和验证8899123456789876512/200528标准的转换器和验证器编写一个填写付款信息的页面,付款信息包括示例代码importjava.util.Date;publicclassPaymentBean{privatedoubleamount;privateStringcard="";

privateDatedate=newDate();publicvoidsetAmount(doublenewValue){amount=newValue;}publicdoublegetAmount(){returnamount;}publicvoidsetCard(StringnewValue){card=newValue;}publicStringgetCard(){returncard;}

publicvoidsetDate(DatenewValue){date=newValue;}publicDategetDate(){returndate;}}受管理的Bean<f:view><h:form><h1><h:outputTextvalue="请输入付款信息:"/></h1><h:panelGridcolumns="3"><h:outputTextvalue="金额:"/><h:inputTextid="amount"value="#{payment.amount}">

<f:convertNumberminFractionDigits="2"/><f:validateDoubleRangeminimum="10"maximum="10000"/></h:inputText>

<h:messagefor="amount"style="color:red"/><h:outputTextvalue="信用卡号:"/><h:inputTextid="card"value="#{payment.card}">

<f:validateLengthminimum="13"/></h:inputText>

<h:messagefor="card"style="color:red"/><h:outputTextvalue="信用卡有效期(月/年):"/><h:inputTextid="date"value="#{payment.date}">

<f:convertDateTimepattern="MM/yyyy"/></h:inputText>

<h:messagefor="date"style="color:red"/></h:panelGrid><h:commandButtonvalue="处理"action="process"/></h:form></f:view>index.jsp<f:view><h:form><h1><h:outputTextvalue="付款信息"/></h1><h:panelGridcolumns="2"><h:outputTextvalue="金额:"/><h:outputTextvalue="#{payment.amount}">

<f:convertNumbertype="currency"/></h:outputText><h:outputTextvalue="信用卡号:"/><h:outputTextvalue="#{payment.card}"/><h:outputTextvalue="信用卡有效日期:"/><h:outputTextvalue="#{payment.date}"><f:convertDateTimepattern="MM/yyyy"/></h:outputText></h:panelGrid><h:commandButtonvalue="返回"action="back"/></h:form></f:view>result.jsp演示:示例129示例代码importjava.util.Date;受管理的JSFHTML标签组件标签说明UIFormform表示

HTML表单元素UIInputInputText单行文本输入控件inputTextarea多行文本输入控件InputSecret密码输入控件inputHidden隐藏字段UIOutputoutputLabel显示文本outputLink链接到另一页面或某页面上的特定位置outputFormat显示格式化的信息outputText当行文本输入UICommandcommandButton表示一个按钮commandLink表示一个链接组件标签说明UISelectOneSelectOneListbox单选列表框selectOneMenu单选菜单selectOneRadio单选按钮集UISelectBooleanselectBooleanCheckbox单个复选框UISelectManyselectManyListbox复选框集selectManyCheckbox多行选择列表框selectManyMenu多选菜单UIPanelpanelGrid表示一个

HTML表格panelGroup组合一系列组件UIMessagemessage显示一个组件的最近使用的消息UIMessagesmessages显示所有消息UIGraphicgraphicImage显示一个图像UIDatadataTable功能丰富的表格控件UIColumncolumn表示表格中的列30JSFHTML标签组件标签说明UIFormform表示表单31表单9文本输入h:inputTexth:inputSecreth:inputTextarea<h:inputTextvalue="测试字符串"readonly="true"/><h:inputSecretvalue="#{form.passwd}"redisplay="true"/><h:inputTextareavalue="123456789012345"rows="3"cols="10"/><h:inputTextvalue="inputText"style="color:Yellow;background:Teal;"/>32文本输入h:inputText<h:inputTextva命令h:commandButtonh:commandLinkh:outputLink<h:commandButtonvalue="按钮"onclick="alert('buttonclicked')"

type="button"/><h:outputLinkvalue=""><h:graphicImagevalue="java-dot-net.jpg"/><h:outputTextvalue=""/></h:outputLink><h:commandLinkvalue="欢迎"

actionListener="#{form.useLinkValue}"action="#{form.followLink}"/>33命令h:commandButton<h:commandBut选择h:selectBooleanCheckboxh:selectManyCheckboxh:selectOneRadioh:selectOneListboxh:selectManyListboxh:selectOneMenuh:selectManyMenu34选择h:selectBooleanCheckbox12选择标签使用示例联系我<h:selectBooleanCheckboxvalue="#{form.contactMe}"/>privatebooleancontactMe;publicvoidsetContactMe(booleannewValue){contactMe=newValue;}publicbooleangetContactMe(){returncontactMe;}<h:selectManyCheckboxvalue="#{form.colors}"><f:selectItem

itemValue="Red"itemLabel="红色"/><f:selectItemitemValue="Blue"itemLabel="蓝色"/><f:selectItemitemValue="Yellow"itemLabel="黄色"/><f:selectItemitemValue="Green"itemLabel="绿色"/><f:selectItemitemValue="Orange"itemLabel="橘黄"/></h:selectManyCheckbox><h:selectOneRadiovalue="#{form.grade}"layout="pageDirection"><f:selectItemsvalue="#{form.grades}"/></h:selectOneRadio>privateSelectItem[]grades={newSelectItem(newInteger(1),"高中"),newSelectItem(newInteger(2),"专科"),newSelectItem(newInteger(3),"本科"),newSelectItem(newInteger(4),"硕士"),newSelectItem(newInteger(5),"博士")};publicSelectItem[]getGrades(){returngrades;}<h:selectOneListboxid="onelistbox"value="#{form.expert}"><f:selectItemitemValue="java"itemLabel="Java"/><f:selectItemitemValue="oracle"itemLabel="Oracle"/><f:selectItemitemValue="asp"itemLabel="ASP"/><f:selectItemitemValue="jsp"itemLabel="JSP"/></h:selectOneListbox><h:selectOneMenuid="onemenu"value="#{form.expert}"><f:selectItemitemValue="java"itemLabel="Java"/><f:selectItemitemValue="oracle"itemLabel="Oracle"/><f:selectItemitemValue="asp"itemLabel="ASP"/><f:selectItemitemValue="jsp"itemLabel="JSP"/></h:selectOneMenu>演示:示例235选择标签使用示例联系我privatebooleancon数据表格标签UIData组件表示h:dataTable标签,它支持将数据绑定到数据对象集合,遍历数据源中的每个记录表内的数据列由UIColumn组件表示,即h:column标签属性说明bgcolor

设置表格背景色border设置表格边框宽度cellpadding设置表格单元格周围的边距cellspacing设置表格单元格之间的间距first表格中所显示的第一行的索引frame指定表格四周的边框样式;有效值:none、above、below、hsides、vsides、lhs、rhs、box、borderstyleClass指定整个表格的CSS类rowClasses行的CSS类列表,用逗号分隔列表columnClasses列的CSS类列表,用逗号分隔列表headerClass

表格标题的CSS类footerClass用于表格页脚的CSS类rules单元格之间的行样式;有效值:groups、rows、columns、allvar数据表格所创建的变量名称,表示该值中的当前项目36数据表格标签UIData组件表示h:dataTable数据表格使用示例1在网页中输出一个简单的表格,显示一个职员的姓名和职位37数据表格使用示例1在网页中输出一个简单的表格,显示一个职员的publicclassEmployeeList{privateStringname;privateStringposition;publicEmployeeList(Stringname,Stringposition){=name;this.position=position;}publicvoidsetName(Stringname){=name;}publicvoidsetPosition(Stringposition){this.position=position;}publicStringgetName(){returnname;}publicStringgetPosition(){returnposition;}}EmployList.java示例代码publicclassData{

privatestaticfinalEmployeeList[]employeelist=newEmployeeList[]{newEmployeeList("高侠","软件工程师"),newEmployeeList("张小丽","培训师"),newEmployeeList("刘亚平","项目经理"),newEmployeeList("牛远","软件工程师")};

publicEmployeeList[]getEmployeelist(){returnemployeelist;}}受管理BeanData……<f:view><h:form><h:dataTable

bgcolor="lightblue"

value="#{Employeedata.employeelist}"var="employees"

border="5"cellpadding="5"cellspacing="2"><h:column><f:facetname="header"><h:outputTextid="headerText1"value="姓名"/></f:facet><h:outputTextvalue="#{}"/>

</h:column><h:column><f:facetname="header"><h:outputTextid="headerText2"value="职位"/>

</f:facet><h:outputTextvalue="#{employees.position}"/>

</h:column></h:dataTable></h:form></f:view>index.jsp演示:示例338publicclassEmployeeList{Emp数据表格使用示例2练习如何从数据库中提取数据,然后将查询结果显示在数据表格中。要求为数据表格设置样式39数据表格使用示例2练习如何从数据库中提取数据,然后将查询结果样式表.customers{border:thinsolidblack;}.customersHeader{text-align:center;font-style:italic;color:Snow;background:Teal;}.evenColumn{height:25px;text-align:center;background:MediumTurquoise;}.oddColumn{text-align:center;background:PowderBlue;}styleClass.css40样式表.customers{styleClass.css1受管理Bean该后台Bean负责同数据库建立连接,并查询数据publicclassCustomerBean{StringsDBDriver="com.microsoft.jdbc.sqlserver.SQLServerDriver";StringsConnStr="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=northwind";Connectionconnect=null;publicCustomerBean(){try{

Class.forName(sDBDriver);}catch(java.lang.ClassNotFoundExceptione){System.err.println(e.getMessage());}try{

connect=DriverManager.getConnection(sConnStr,"sa","");}catch(SQLExceptionex){System.err.println(ex.getMessage());}}CustomerBean.javapublicsynchronizedResultSetexecuteQuery(Stringsql){ResultSetrs=null;if(connect!=null){

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论