续分页 jsf组件dataTable

注册:

<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>
register
</title>
</head>
<body bgcolor="#ffffff">
<f:view>
    <h:form>
      <h:outputText value="#{regBean.message}">
      </h:outputText>
      <h:panelGrid columns="3">
        <h:outputLabel>
          <h:outputText value="用户名:"/>
         </h:outputLabel>
         <h:inputText id="username" value="#{regBean.username}" required="true">
         </h:inputText>
         <h:message for="username"/>
          <h:outputLabel>
          <h:outputText value="密    码:"/>
         </h:outputLabel>
         <h:inputText id="password" value="#{regBean.userpassword}" required="true">
         </h:inputText>
         <h:message for="password"/>
          <h:outputLabel>
          <h:outputText value="密码确认:"/>
         </h:outputLabel>
         <h:inputText id="password2" value="#{regBean.password2}" required="true">
         </h:inputText>
         <h:message for="password2"/>
         <h:commandButton value="注册" action="#{regBean.doRegister}"/>
         <h:commandButton value="重置" type="reset"/>
       </h:panelGrid>
    </h:form>
</f:view>
</body>
</html>

登陆:

<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>
login
</title>
</head>
<body bgcolor="#ffffff">
    <f:view>
      <h:form>
        <h:outputText value="#{LoginBean.message}"/>
        <h:panelGrid    columns="3">
          <h:outputLabel value="用户名:"/>
          <h:inputText    id="username" value="#{LoginBean.loginname}" required="true"/>
          <h:message for="username"/>
          <h:outputLabel value="密 码:"/>
          <h:inputText    id="pwd" value="#{LoginBean.userpassword}" required="true"/>
          <h:message for="pwd"/>
          <h:commandButton value="登录" action="#{LoginBean.doLogin}">
          </h:commandButton>
          <h:commandButton value="重置" type="reset">
          </h:commandButton>
          <h:outputLink value="register.faces">
            <f:verbatim> 用户注册 </f:verbatim>
          </h:outputLink>
        </h:panelGrid>
      </h:form>
    </f:view>
</body>
</html>

退出:

<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>
logout
</title>
</head>
<body bgcolor="#ffffff">
<f:view>
    <h:form>
<h:commandButton value="退出登录" action="#{LoginBean.doLogout}">
</h:commandButton>
<h:outputLink value="">
</h:outputLink>
    </h:form>
</f:view>
</body>
</html>

删除:

<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>
removeuser
</title>
</head>
<body bgcolor="#ffffff">
<f:view>
    <h:form>
      <h:inputHidden value="#{removeuserBean.userid}">
      </h:inputHidden>
      <h:panelGrid columns="2">
        <h:outputLabel value="确认要删除#{removeuserBean.username}的用户吗?">
        </h:outputLabel>
        <h:commandButton value="删除" action="#{removeuserBean.doRemoveuser}">
        </h:commandButton>
      </h:panelGrid>
    </h:form>
</f:view>
</body>
</html>

修改:

<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>
userdetail
</title>
</head>
<body bgcolor="#ffffff">
<f:view>
    <h:form>
      <h:panelGrid columns="3">
        <h:inputHidden value="#{updateuserBean.userid}">
        </h:inputHidden>
          <h:outputLabel value="用户名称:">
        </h:outputLabel>
        <h:inputText    id="username" value="#{updateuserBean.username}">
        </h:inputText>
        <h:message for="username">
        </h:message>
          <h:outputLabel value="用户密码:">
        </h:outputLabel>
        <h:inputText    id="userpwd" value="#{updateuserBean.userpassword}">
        </h:inputText>
        <h:message for="userpwd">
        </h:message>
        <h:commandButton value="修改" action="#{updateuserBean.doChangeuser}">
        </h:commandButton>
      </h:panelGrid>
    </h:form>
</f:view>
</body>
</html>

 JSF2.xdatatable分页控件与左侧菜单最简单应用   JSF2.x,功能强大,使用方便。全世界使用JSF的人越来越多。而且也有很多很好的控件给发出来了,如:richfaces、primefaces、myfaces等,就日前来讲primefaces功能很强大,控件很多,但有一点不好就是不支持IE6,特别是下拉列表,p:dialog等,其它的分页p:datatable实际使用起来总有不如意的地方。richfaces还支持可视化开发,可惜就是控件开发进度相比其它的慢了很多。下面帖我的控件的使用方法:   下载地址:http://download.csdn.net/detail/ptianfeng/4802713 一、分页具体使用方法如下(不多说,直接给你些颜色看看): 1. xhtml文件:    <html xmlns:ems="http://www.ems.com.cn" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:dataTable id="tableId" value="#{userlogMBean.defaultDataModel}" var="var" rows="10"> <h:column> <f:facet name="header"> <h:outputText value="" /> </f:facet> <h:outputText value="#{var.sqlid}" /> </h:column> </h:dataTable> <ems:page id="pageId" for="tableId" maxPage="5" /> 2. 相应的Managedbean: [java] view plaincopy /** * EMS 11185 限时未达邮费奉还 * @author 螃蟹 */ @SuppressWarnings(value = "serial") @ManagedBean(name = "userlogMBean") @ViewScoped() public class UserlogMBean extends PageListBaseBean implements Serializable { public PagedListDataModel getDefaultDataModel() { if (defaultDataModel == null) { defaultDataModel = new PagedListDataModel(pageSize) { public DataPage fetchPage(int startRow, int pageSize) { ArrayList<UserlogVo> dataList = new ArrayList<UserlogVo>(); List<Userlog> list = dao.getObjectList(jpql, pageSize, startRow); if (list != null) { for (Userlog u : list) { UserlogVo vo = new UserlogVo(); vo.setSqlid(u.getSqlid()); vo.setCode(u.getCode()); vo.setDate(u.getDate()); vo.setStation(u.getStation()); vo.setUserid(u.getUserid()); vo.setText(u.getText()); dataList.add(vo); } } int size = dao.getCountOption(jpql); DataPage dataPage = new DataPage(size, startRow, dataList); return dataPage; } }; } return defaultDataModel; } } 提示:关于PageListBaseBean更多的信息,可以参阅我在百度的blog(百度改版后,让我很QF,所以转到CSDN来了): http://hi.baidu.com/kittopang/item/19af4e37c6ede2fae6bb7a11   至此,分页已经实现。下面是使用截图:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值