请大侠帮忙,我的代码为什么不提交,谢谢
|
fzhq1970
2008-02-21
/*
* FormNewCustomerSum.java
*
* Created on 2008年2月18日, 下午5:20
* 新增客户报表表单
*/
package com.ccb.ha.ebank.form;
import com.ccb.ha.common.entity.OrgInfo;
import com.ccb.ha.common.report.ReportType;
import com.ccb.ha.ebank.entity.ChannelPara;
import com.ccb.ha.ebank.entity.NewCustomerSum;
import com.ccb.ha.ebank.report.NewCustomerSumReport;
import com.ccb.ha.ebank.service.INewCustomerService;
import com.ccb.ha.exception.BusinessException;
import com.ccb.ha.util.jsf.JSFContext;
import com.ccb.ha.util.session.MustDeletedFile;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
* @author 冯志强
*/
public class FormNewCustomerSum {
public static final int MAXLEVEL = 4;
private static Log log = LogFactory.getLog(FormNewCustomerSum.class);
private static String separator = System.getProperty("file.separator");
//当前正在展示的机构级别,用于判断是否可以上钻和下钻
private int currentLevel = 0;
/** Creates a new instance of FormNewCustomerSum */
public FormNewCustomerSum() {
}
/**
* 保存属性 newCustomerService 的值。新增客户服务
*/
private INewCustomerService newCustomerService;
/**
* 属性 newCustomerService 的获取方法。
* @return 属性 newCustomerService 的值。
*/
public INewCustomerService getNewCustomerService() {
return this.newCustomerService;
}
/**
* 属性 newCustomerService 的设置方法。
* @param newCustomerService 属性 newCustomerService 的 新值。
*/
public void setNewCustomerService(INewCustomerService newCustomerService) {
this.newCustomerService = newCustomerService;
}
/**
* 保存属性 orgInfo 的值。 当前用户所在机构信息
*/
private OrgInfo orgInfo;
/**
* 属性 orgInfo 的获取方法。
* @return 属性 orgInfo 的值。
*/
public OrgInfo getOrgInfo() {
return this.orgInfo;
}
/**
* 属性 orgInfo 的设置方法。
* @param orgInfo 属性 orgInfo 的新值。
*/
public void setOrgInfo(OrgInfo orgInfo) {
this.orgInfo = orgInfo;
if(this.orgInfo != null){
this.orgid = this.orgInfo.getId();
this.currentLevel = this.orgInfo.getOjb();
}else{
this.orgid = "";
this.currentLevel = 0;
}
}
/**
* 保存属性 orgid 的值。需要展示的机构代码
*/
private String orgid;
/**
* 属性 orgid 的获取方法。
* @return 属性 orgid 的值。
*/
public String getOrgid() {
return this.orgid;
}
/**
* 属性 orgid 的设置方法。
* @param orgid 属性 orgid 的新值。
*/
public void setOrgid(String orgid) {
this.orgid = orgid;
}
/**
* 保存属性 begin 的值。统计开始时间
*/
private Date begin = new Date();
/**
* 属性 begin 的获取方法。
* @return 属性 begin 的值。
*/
public Date getBegin() {
return this.begin;
}
/**
* 属性 begin 的设置方法。
* @param begin 属性 begin 的新值。
*/
public void setBegin(Date begin) {
this.begin = begin;
}
/**
* 保存属性 end 的值。统计结束时间
*/
private Date end = new Date();
/**
* 属性 end 的获取方法。
* @return 属性 end 的值。
*/
public Date getEnd() {
return this.end;
}
/**
* 属性 end 的设置方法。
* @param end 属性 end 的新值。
*/
public void setEnd(Date end) {
this.end = end;
}
/**
* 保存属性 channel 的值。统计的分类渠道,默认全部渠道
*/
private String channel = "0";
/**
* 属性 channel 的获取方法。
* @return 属性 channel 的值。
*/
public String getChannel() {
return this.channel;
}
/**
* 属性 channel 的设置方法。
* @param channel 属性 channel 的新值。
*/
public void setChannel(String channel) {
this.channel = channel;
}
/**
* 保存属性 sums 的值。统计结果
*/
private List<NewCustomerSum> sums = new ArrayList<NewCustomerSum>();
/**
* 属性 sums 的获取方法。
* @return 属性 sums 的值。
*/
public List<NewCustomerSum> getSums() {
return this.sums;
}
/**
* 属性 sums 的设置方法。
* @param sums 属性 sums 的新值。
*/
public void setSums(List<NewCustomerSum> sums) {
this.sums = sums;
}
/**
* 保存属性 fileName 的值。报表文件名称
*/
private String fileName;
/**
* 属性 fileName 的获取方法。
* @return 属性 fileName 的值。
*/
public String getFileName() {
return JSFContext.getRequest().getContextPath() + "/report/" +
this.fileName;
}
/**
*功能:生成报表
*参数:
*返回:null
*说明:
*/
public String makeReport(){
try {
Date d1 = this.begin;
Date d2 = this.end;
this.sums = this.newCustomerService.loadNewCustomersSum(
d1,d2,this.orgid,Integer.parseInt(this.channel));
//文件的绝对路径
String realPath = JSFContext.getContext().getRealPath("/");
//模板文件的绝对路径
String modal = realPath + "reportmodal" +
separator + "xzkhqktjb.xls";
if(log.isDebugEnabled()){
log.debug("报表模板为:"+modal);
}
//建立临时报表文件
long l = new Date().getTime() ;
this.fileName =
"Report" + JSFContext.getSession(true).getId() + l +
"." + ReportType.EXCEL.getExtName();
//生成报表
String reportName = realPath + "report" + separator + this.fileName;
NewCustomerSumReport report = new NewCustomerSumReport();
report.makeReportWithModal(this.sums,reportName,modal);
//准备用户退出时删除临时报表文件
MustDeletedFile file = new MustDeletedFile(reportName);
JSFContext.setSessionAttribute(reportName,file);
}catch(BusinessException be){
log.error(be.getMessage());
JSFContext.addMessage(null,"报表处理失败",be.getMessage());
}
return null;
}
/**
* 属性 channels 的获取方法。
* @return 属性 channels 的值。
*/
public List<SelectItem> getChannels() {
List<SelectItem> result = new ArrayList<SelectItem>();
List<ChannelPara> cs = this.newCustomerService.loadAllChannels();
for(int i=0;i<cs.size();i++){
SelectItem s = new SelectItem();
ChannelPara c = cs.get(i);
s.setDescription(c.getChannelName());
s.setLabel(c.getChannelName());
s.setValue(c.getId().toString());
result.add(s);
}
return result;
}
/**
*功能:判断当前是否有报表可以下载
*参数:
*返回:
*说明:
*/
public boolean getCanDownload(){
if((this.fileName == null)||(this.fileName.equals(""))) return false;
return true;
}
/**
*功能:判断是否可以上钻
*参数:
*返回:
*说明:
*/
public boolean isCanUp(){
//上钻的条件是当前展示机构等级小于当前用户的机构等级
return this.currentLevel < this.orgInfo.getOjb();
}
/**
*功能:判断是否可以下钻
*参数:
*返回:
*说明:
*/
public boolean isCanDown(){
return this.currentLevel < MAXLEVEL;
}
/**
* 属性 currentLevel 的获取方法。
* @return 属性 currentLevel 的值。
*/
public int getCurrentLevel() {
return this.currentLevel;
}
/**
* 属性 currentLevel 的设置方法。
* @param currentLevel 属性 currentLevel 的新值。
*/
public void setCurrentLevel(int currentLevel) {
this.currentLevel = currentLevel;
}
/**
*功能:监听上钻下钻单击事件
*参数:
*返回:
*说明:
*/
public void upDownListener(ActionEvent event){
String level = JSFContext.getParameter("currentLevel");
this.currentLevel = Integer.parseInt(level);
this.orgid = JSFContext.getParameter("newOrg");
}
}
<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<f:verbatim>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/calendar1.js"></script>
<script language="javascript">
function doSetOrg(selectedOrg){
if(selectedOrg != ""){
var obj = document.getElementById("viewCenter:userManageForm:orgId");
if(obj.value != selectedOrg){
obj.value = selectedOrg;
obj = document.getElementById("viewCenter:userManageForm");
obj.submit();
}
}
}
</script>
</f:verbatim>
<h:form id="reportManageForm" accept="post">
<h:panelGrid columns="1" align="center">
<h:messages errorStyle="color:red" infoStyle="color:blue"
fatalStyle="color:red" showDetail="true" globalOnly="true"/>
</h:panelGrid>
<h:panelGrid columns="1" align="center" width="95%">
<h:outputText value="新增客户统计" styleClass="smallcaption"/>
</h:panelGrid>
<h:panelGrid columns="1" align="center" width="95%" cellpadding="0" cellspacing="0">
<t:panelGrid columns="2" align="left,right" styleClass="smalltitle" width="100%">
<t:panelGroup >
<h:outputText value="统计开始日期:"/>
<t:inputCalendar renderPopupButtonAsImage="true" popupTodayString="今天:"
popupWeekString="周次"
value="#{formNewCustomerSum.begin}"
id="begin" renderAsPopup="true"
popupDateFormat="yyyy-MM-dd"
/>
<h:outputText value="统计结束日期:"/>
<t:inputCalendar renderPopupButtonAsImage="true" popupTodayString="今天:"
popupWeekString="周次"
value="#{formNewCustomerSum.end}"
id="end" renderAsPopup="true"
popupDateFormat="yyyy-MM-dd"
/>
<h:outputText value="统计渠道:"/>
<t:selectOneMenu value="#{formNewCustomerSum.channel}">
<f:selectItem itemValue="0" itemLabel="全部渠道"/>
<f:selectItems value="#{formNewCustomerSum.channels}"/>
</t:selectOneMenu>
<t:commandButton styleClass="button" value="生成报表"
action="#{formNewCustomerSum.makeReport}">
</t:commandButton>
<h:outputLink rendered="#{formNewCustomerSum.canDownload}"
value="#{formNewCustomerSum.fileName}">
<t:outputText value="另存为EXCEL文件"/>
</h:outputLink>
</t:panelGroup>
</t:panelGrid>
<t:dataTable align="center" style="vertical-align:top" width="100%"
cellpadding="0" cellspacing="0" styleClass="content_table"
rowClasses="evenColumn,oddColumn" headerClass="header"
value="#{formNewCustomerSum.sums}"
rowIndexVar="index"
var="sum" rules="rows,cols">
<t:column>
<f:facet name="header">
<h:outputText value="签约机构"/>
</f:facet>
<h:outputText value="#{sum.orgId}"
style="align:center;word-break: break-all"/>
</t:column>
<t:column>
<f:facet name="header">
<h:outputText value="机构名称"/>
</f:facet>
<h:outputText value="#{sum.orgName}" style="center" />
<t:commandLink rendered="#{(formNewCustomerSum.canDown) &&(formNewCustomerSum.orgid != sum.orgId)}"
actionListener="#{formNewCustomerSum.upDownListener}">
<t:graphicImage url="/images/down.gif" />
</t:commandLink>
我希望在这个地方单击这个图标是,执行upDownListener,但是系统总是不提交,请大哥执教,非常感谢
</t:column>
<t:column>
<f:facet name="header">
<h:outputText value="期初客户数"/>
</f:facet>
<h:outputText value="#{sum.baseCount}"
style="align:center;word-break: break-all"/>
</t:column>
<t:column>
<f:facet name="header">
<h:outputText value="本期新增数"/>
</f:facet>
<h:outputText value="#{sum.incCount}"
style="align:left;word-break: break-all"/>
</t:column>
<t:column>
<f:facet name="header">
<h:outputText value="本期销户数"/>
</f:facet>
<h:outputText value="#{sum.decCount}"
style="align:left;word-break: break-all"/>
</t:column>
<t:column>
<f:facet name="header">
<h:outputText value="本期末户数"/>
</f:facet>
<h:outputText value="#{sum.lastCount}"
style="align:left;word-break: break-all"/>
</t:column>
</t:dataTable>
</h:panelGrid>
<t:inputHidden id="orgid" value="#{formNewCustomerSum.orgid}"/>
</h:form>
|
|
|
littlesuns
2008-02-25
commandLink不会提交表单,tomhawk似乎也没有用Ajax来实现actionListener,so,必须在点击的时候手动提交, like javascript, 大概浏览了一下,代码是在是太多了....-_-|||
|

