`
myriad_sunny
  • 浏览: 6262 次
  • 性别: Icon_minigender_2
  • 来自: 郑州
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

关于jsf中全选

阅读更多
<%@ page contentType="text/html;charset=GB2312"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.find {
font-family: "宋体";
color: #FFFFFF;
}
.STYLE1 {color: #000000
font-size: 16px
}
.STYLE4 {font-size: 14px}
.STYLE5 {font-size: 12px}
.STYLE6 {font-size: 12px; color: #FFFFFF; }
.body{font-size:12px;cloor:#FFFFFF;}

body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}

body     { font-family: Arial; }          
.tablebg { background-color: #ffffff; }           
.header  { font-weight: bold; }          
.footer  { font-weight: bold; }           
.text    { text-align: left; }           
.number  { text-align: right; } 
.graybg  { background-color: #CCCCCC; }          
.whitebg { background-color: #CCCCCC; }
-->
</style>
</head>

<body>
<f:view>
<table width="95%" height="590" border="1" cellpadding="0"
cellspacing="0" bordercolor="#999999">
<!--DWLayoutTable-->
<tr>
<td width="600" height="90" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="602" height="39">
&nbsp;

</td>
</tr>
<tr>
<td height="20" align="left" valign="middle" bgcolor="#333333">
<span class="STYLE1">会员管理~会员审核</span>
</td>
</tr>
<tr>
<td height="31">
&nbsp;

</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="360" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0"
bordercolor="#ECE9D8" bgcolor="#999999">
<!--DWLayoutTable-->
<tr>
<td height="57" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="600" height="26" valign="bottom">
<p>
查询信息
</p>
</td>
</tr>
<td height="31" align="left" valign="top">
<h:form id="selectUNMemberForm">
   请输入会员名字:
<h:inputText id="memberName"
value="#{memberForm.member.memberName}" />
<h:commandButton type="submit" value="搜索"
action="#{memberForm.unPassMember}" />
<h:message for="memberName"></h:message>
</h:form>
</td>
</table>
</td>
</tr>
<tr>
<td width="600" height="434" align="left" valign="top">
<h:form id="unpass_list">
<table width="602" border="1" cellspacing="0"
bgcolor="#FFFFFF">
<h:dataTable id="listTable" cellpadding="5" cellspacing="1"
value="#{memberForm.unPassModel}" var="unPass" rows="4"
styleClass="tablebg" headerClass="header"
footerClass="footer"
columnClasses="text,number,number,number"
rowClasses="graybg,whitebg" border="0">
<h:column>
<f:facet name="header">
<h:outputText value=""></h:outputText>
</f:facet>
<h:selectBooleanCheckbox id="isSelect"
value="#{unPass.memberStatus}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="会员名称" style="font-size:14px;"></h:outputText>
</f:facet>
<h:outputText value="#{unPass.memberName}"
style="font-size:12px;"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="真实姓名" style="font-size:14px;"></h:outputText>
</f:facet>
<h:outputText value="#{unPass.realName}"
style="font-size:12px;"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="性别" style="font-size:14px;"></h:outputText>
</f:facet>
<h:outputText value="#{unPass.memberSex}"
style="font-size:12px;"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="email" style="font-size:14px;"></h:outputText>
</f:facet>
<h:outputText value="#{unPass.email}"
style="font-size:12px;"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="联系方式" style="font-size:14px;"></h:outputText>
</f:facet>
<h:outputText value="#{unPass.phone}"
style="font-size:12px;"></h:outputText>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="是否通过" style="font-size:14px;"></h:outputText>
</f:facet>
<h:commandLink action="#{memberForm.passMember}">
<h:outputText value="#{unPass.isPass}"
style="font-size:12px;"></h:outputText>
<t:updateActionListener value="#{unPass.memberName}"
property="#{memberForm.member.memberName}"></t:updateActionListener>
</h:commandLink>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<h:commandButton value="删除" action="#{memberForm.delete}"
onclick='return confirm("你确定要删除吗?")'>
<t:updateActionListener value="#{unPass.memberName}"
property="#{memberForm.member.memberName}"></t:updateActionListener>
</h:commandButton>
</h:column>
</h:dataTable>
<div align="center">
<h:panelGrid>
<h:outputLabel value="全选" for="SelectAll"></h:outputLabel>
<h:selectBooleanCheckbox id="SelectAll"
onclick="setCheckedStatus();" />
<h:commandButton value="删除所选"
action="#{memberForm.patchDelete}" />
<h:commandButton value="审核所选"
action="#{memberForm.patchUpdate}" />
</h:panelGrid>
</div>
<t:dataScroller id="scroll_1" for="listTable"
pageCountVar="pageCount" pageIndexVar="pageIndex"
styleClass="scroller" paginator="true" paginatorMaxPages="5"
paginatorTableClass="paginator"
paginatorActiveColumnStyle="font-weight:bold;"
immediate="true">
<div align="center">
<f:facet name="first">
<h:outputText value="首页"
style="color:#ffffff;font-size:14px"></h:outputText>
</f:facet>

<f:facet name="previous">
<h:outputText value="上一页"
style="color:#ffffff;font-size:14px"></h:outputText>
</f:facet>

<f:facet name="next">
<h:outputText value="下一页"
style="color:#ffffff;font-size:14px"></h:outputText>
</f:facet>

<f:facet name="last">
<h:outputText value="尾页"
style="color:#ffffff;font-size:14px"></h:outputText>
</f:facet>
</div>
</t:dataScroller>

</table>
</h:form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</f:view>
</body>
</html>
<script type="text/javascript">
/**
* 通过全选按钮选择表格中的全部数据
*/
function setCheckedStatus(){

var TableData = document.getElementById("unpass_list:listTable");
var CheckAll = document.getElementById("unpass_list:SelectAll");
// 判断浏览器类型,如果是IE则使用table表格获取,否则通过ID获取
if(navigator.userAgent.indexOf("MSIE")>0){
if(TableData != null && CheckAll != null){
for(i=1;i<TableData.rows.length;i++){
TableData.rows(i).cells(0).children.item(0).checked = CheckAll.checked;
}
}
}else{
if(TableData != null && CheckAll != null){
for(i=0;i<TableData.rows.length -1;i++){
document.getElementById("unpass_list:listTable:"+i+":isSelect").checked = CheckAll.checked;
}
}
}
}
</script>

这上面中的javascript为全选,其中的批量删除为:

public class MemberForm extends BasePage {

private Member member = new Member();

private String rePassword;

private MemberManager memberManager;

private String memberID;

private List memberList = new ArrayList();

private List unPassList = new ArrayList();

DataModel memberModel = null;

private int pageCount;

public DataModel getUnPassModel() {
if (memberModel == null) {
memberModel = new ListDataModel();
memberModel.setWrappedData(this.getUnPassList());
}

return memberModel;
}

  /**
* 批量删除数据
*
* @return String patchDelete 代表批量删除后要导航到的页面 这里我们就让他返回成功页面
*/
public String patchDelete() {
DataModel mdm = (ListDataModel) getUIData().getValue();
List<Member> list = (List) mdm.getWrappedData();
// 选择选中的用户进行批量删除
for (Member m : list) {
if (m.isMemberStatus()) {
memberManager.removeMember(m.getMemberName());
}
}
return "patchDel";
}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics