这里的typeBaseInfo方法实现的功能是通过上个级别的编号(ID),和这个级别的设置名字(如:市级设置)返回这个级别的所有的信息。并通过list返回。具体的代码如下: paper51.com /*****根据rulename(比如“省级设置“) ,以及上个级别的id 返回这个级别的List*****/ copyright paper51.com
public ListtypeBaseInfo(String id, String rulename) { paper51.com
Mapmap = new HashMap(); http://www.paper51.com Listrule = (List) new java.util.ArrayList (); 内容来自www.paper51.com Listlist = (List) new java.util.ArrayList (); 内容来自www.paper51.com map.put("id", id); copyright paper51.com if (rulename.equals("市级设置")){ http://www.paper51.com rule= (List) this.call(new Carrier(map, paper51.com BusinessConstants.UNITS_PUBLIC_BUSINESS,"ShowCity")); paper51.com IteratoritClass1 = rule.iterator(); http://www.paper51.com list= (List) new java.util.ArrayList (); http://www.paper51.com
SmartCitycity = null; 内容来自www.paper51.com while(itClass1.hasNext ()) { http://www.paper51.com UnitsPublicFormunitsPublicForm = new UnitsPublicForm(); http://www.paper51.com city= (SmartCity) itClass1.next (); paper51.com
unitsPublicForm.setMaxlength(city.getLength ()); http://www.paper51.com
unitsPublicForm.setRuleclass("第2级别"); http://www.paper51.com unitsPublicForm.setRulename(rulename); paper51.com unitsPublicForm.setRemark(city.getRemark ()); 内容来自www.paper51.com unitsPublicForm.setName(city.getCityName ()); 内容来自论文无忧网 www.paper51.com unitsPublicForm.setID(city.getCityNo ()); http://www.paper51.com unitsPublicForm.setNextName(city.getNextName ()); copyright paper51.com unitsPublicForm.setLastID(city.getLastclassNo ()); copyright paper51.com
unitsPublicForm.setLastName(city.getLastName ()); http://www.paper51.com list.add(unitsPublicForm); 内容来自论文无忧网 www.paper51.com } http://www.paper51.com }…… paper51.com 5.2.2 教务资源管理模块实现 http://www.paper51.com
内容来自论文无忧网 www.paper51.com 图5-6教务资源管理模块界面 http://www.paper51.com 下面是用户添加一条具体信息的代码: http://www.paper51.com
(1)Action类: 内容来自论文无忧网 www.paper51.com publicActionForward save(ActionMapping mapping, ActionForm form, 内容来自www.paper51.com HttpServletRequestrequest, HttpServletResponse response) copyright paper51.com throwsException { http://www.paper51.com UnitsKnowledgeFormknowledgeForm = (UnitsKnowledgeForm) form; 内容来自论文无忧网 www.paper51.com SmartKnowledgePointentity = new SmartKnowledgePoint(); 内容来自www.paper51.com
entity.setKnowledgeNo("00"+System.currentTimeMillis()); 内容来自论文无忧网 www.paper51.com entity.setKnowledgeName(knowledgeForm.getPoint()); copyright paper51.com SmartSectionse = new SmartSection(); 内容来自论文无忧网 www.paper51.com
se.setSectionNo(knowledgeForm.getSectionNo()); http://www.paper51.com
entity.setSectionNo(se); http://www.paper51.com Mapmap = new HashMap(); 内容来自www.paper51.com map.put("entity",entity); 内容来自论文无忧网 www.paper51.com this.call(newCarrier(map,BusinessConstants.UNITS_KNOWLEDGE_BUSINESS, http://www.paper51.com "SaveUnitsKnowledge"));//执行business里面的方法。 copyright paper51.com returnmapping.findForward("save");} 内容来自www.paper51.com (2)Business类: copyright paper51.com
public voidprocessSaveUnitsKnowledge(Carrier vo) { 内容来自www.paper51.com Mapparams = (Map) vo.getData(); copyright paper51.com SmartKnowledgePointentity = (SmartKnowledgePoint) params.get("entity"); 内容来自论文无忧网 www.paper51.com
if(params != null) { 内容来自www.paper51.com
((UnitsKnowledgeDAO)getDao()).save(entity); 内容来自www.paper51.com
} copyright paper51.com } 内容来自论文无忧网 www.paper51.com 这一段代码是把Action中的SmartKnowledgePoint实体取出来后进一步到UnitsKnowledgeDAO类中的save的方法中执行。 paper51.com (3)DAO类: 内容来自论文无忧网 www.paper51.com public voidsaveTopicEntity(Code code); copyright paper51.com
这一行的代码是通过配置文件可以执行到Impl的类的saveTopicEntity方法,并把参数code传过去。 paper51.com
(4)Impl类: paper51.com
public voidsaveTopicEntity(Code code) { 内容来自论文无忧网 www.paper51.com save(code); 内容来自www.paper51.com } 内容来自www.paper51.com 这一行的代码是得到DAO中传过来的实体code,然后调用继承的类中的方法save保存实体code。 copyright paper51.com 5.2.3 试题资源管理模块实现 http://www.paper51.com
copyright paper51.com 图5-7试题资源管理模块界面 paper51.com 下面是用户删除一条具体信息的代码: http://www.paper51.com (1)Action类: 内容来自论文无忧网 www.paper51.com
publicActionForward delete(ActionMapping mapping, ActionForm form, 内容来自论文无忧网 www.paper51.com HttpServletRequestrequest, HttpServletResponse response) http://www.paper51.com
throwsException { http://www.paper51.com
Stringstep = (String) request.getParameter("step"); 内容来自www.paper51.com Stringforward=""; paper51.com
if("one".equals(step)){ 内容来自www.paper51.com Mapparams = new HashMap(); 内容来自www.paper51.com Stringid = request.getParameter("id"); http://www.paper51.com request.getSession().setAttribute("ID",id); 内容来自论文无忧网 www.paper51.com params.put("ID",id); paper51.com UnitsTopicSetBusinesstopicSetBusiness = new UnitsTopicSetBusiness(); 内容来自www.paper51.com this paper51.com .call(newCarrier(params, http://www.paper51.com BusinessConstants.UNITS_TOPIC_BUSINESS, http://www.paper51.com "DeleteTopicById"));} paper51.com elseif("two".equals(step)){ 内容来自论文无忧网 www.paper51.com Mapparams = new HashMap(); 内容来自论文无忧网 www.paper51.com
StringID = request.getParameter("id"); 内容来自www.paper51.com Stringstr = "delete code where code_id in(" + ID + ")"; 内容来自论文无忧网 www.paper51.com
System.out.println(ID); 内容来自www.paper51.com params.put("ID",ID); 内容来自论文无忧网 www.paper51.com this copyright paper51.com
.call(newCarrier(params, http://www.paper51.com BusinessConstants.UNITS_TOPIC_BUSINESS, http://www.paper51.com "deleteTopicByIdCount")); 内容来自论文无忧网 www.paper51.com } 内容来自论文无忧网 www.paper51.com Mapparams = null; http://www.paper51.com Listresult = (List) this.call(new Carrier(params, http://www.paper51.com BusinessConstants.UNITS_TOPIC_BUSINESS,"ShowTopicAnswer")); 内容来自论文无忧网 www.paper51.com request.getSession().setAttribute("resultList",result); copyright paper51.com
returnmapping.findForward("unitsTopicAnswer"); paper51.com } paper51.com
这里通过request.getParameter("id")方法得到要删除的实体的ID,然后把这个ID返回到Business的方法中进行删除。 copyright paper51.com (2)Business类: http://www.paper51.com public voidprocessdeleteTopicByIdCount(Carrier vo) { 内容来自论文无忧网 www.paper51.com
Mapparams = (Map) vo.getData(); 内容来自www.paper51.com StringID = (String) params.get("ID"); 内容来自www.paper51.com
StringrecId[]=ID.split("'"); copyright paper51.com ListrecIdList=null; copyright paper51.com
for(inti=0;i<recId.length;i++){ http://www.paper51.com String id=recId[i]; 内容来自www.paper51.com String str="from Code whererecId='"+id+"'"; http://www.paper51.com List list=(List)((UnitsTopicSetDAO)this.getDao()).showTopicAnswer(str); paper51.com Iterator itClass =list.iterator(); http://www.paper51.com while(itClass.hasNext()){ paper51.com Code code = (Code)itClass.next(); 内容来自论文无忧网 www.paper51.com ((UnitsTopicSetDAO)this.getDao()).DeleteTopicById(code); paper51.com } } http://www.paper51.com } http://www.paper51.com
这一段代码是把封装的ID串解析后得到每个ID的值,然后根据每个ID的值删除每个实体。 paper51.com 这个封装的ID是在前台页面的js方法中实现的,具体代码如下: copyright paper51.com var a = functiondeleteBaseInfo(str) copyright paper51.com
{ paper51.com var a =document.getElementsByName(str); 内容来自www.paper51.com varn = a.length; 内容来自论文无忧网 www.paper51.com vartemp=""; 内容来自论文无忧网 www.paper51.com varflag=true; copyright paper51.com for(var i=0; i<n; i++){ 内容来自论文无忧网 www.paper51.com
if(a[i].checked){ 内容来自论文无忧网 www.paper51.com flag=false; 内容来自论文无忧网 www.paper51.com if (temp=="") { 内容来自www.paper51.com temp=a[i].value+"'"; 内容来自www.paper51.com }else http://www.paper51.com { 内容来自论文无忧网 www.paper51.com temp = temp +a[i].value+"'"; copyright paper51.com } 内容来自www.paper51.com
} 内容来自论文无忧网 www.paper51.com } paper51.com if(flag) copyright paper51.com {alert("对不起,你还没有选择!")} 内容来自www.paper51.com
else{ paper51.com if(confirm("确实要删除?")){ http://www.paper51.com window.location.href="<%=request.getContextPath()%>/unitsTopicDifficultyAction.do?action=delete&step=two&id="+temp; 内容来自论文无忧网 www.paper51.com }}return!flag; http://www.paper51.com
} 内容来自论文无忧网 www.paper51.com |