?? reportcategoryaction.java
字號(hào):
package com.yuanchung.sales.struts.report.action;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.yuanchung.sales.model.report.Report;
import com.yuanchung.sales.model.report.ReportCategory;
import com.yuanchung.sales.service.resport.ReportMgr;
/**
* 報(bào)表類別Action
* @author gzq
*
*/
public class ReportCategoryAction extends DispatchAction {
private static final Log log = LogFactory.getLog(ReportCategoryAction.class);
private ReportMgr reportMgr;
public void setReportMgr(ReportMgr reportMgr) {
this.reportMgr = reportMgr;
}
public ActionForward toReportCategoryTree(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("toReportCategoryTree");
}
public ActionForward toReportMain(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("toReportMain");
}
public ActionForward getReportCategory(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List<ReportCategory> lstRC = reportMgr.getReportCategory();
StringBuilder sb = new StringBuilder("[");
if(lstRC != null && lstRC.size() > 0){
Iterator it = lstRC.iterator();
boolean hasReportCategory = false;
while(it.hasNext()){
ReportCategory rc = (ReportCategory)it.next();
sb.append("{id:'");
//yctech連上category的ID作為樹形節(jié)點(diǎn)的ID
sb.append("yctech");
sb.append(rc.getId());
sb.append("',text:'");
sb.append(rc.getName());
sb.append("',cls:'folder'");
List<Report> lstRT = reportMgr.findReportByReportCategoryId(rc.getId());
if(lstRT != null && lstRT.size() > 0){
Iterator itRT = lstRT.iterator();
sb.append(",children:[");
boolean hasReport = false;
while(itRT.hasNext()){
Report rt = (Report)itRT.next();
sb.append("{id:'report");
sb.append(rt.getId());
sb.append("',text:'");
sb.append(rt.getName());
sb.append("',defaultCondition:");
sb.append(rt.getDefaultCondition());
sb.append(",cls:'file',leaf:true},");
hasReport = true;
}
if(hasReport){
sb.deleteCharAt(sb.length() - 1);
}
sb.append("]");
}else{
sb.append(",leaf:true");
}
hasReportCategory = true;
sb.append("},");
}
if(hasReportCategory){
sb.deleteCharAt(sb.length() - 1);
}
}
sb.append("]");
response.getWriter().write(sb.toString());
return null;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -