當前位置: 首頁>>代碼示例>>Java>>正文


Java ActionMessages.size方法代碼示例

本文整理匯總了Java中org.apache.struts.action.ActionMessages.size方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionMessages.size方法的具體用法?Java ActionMessages.size怎麽用?Java ActionMessages.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.struts.action.ActionMessages的用法示例。


在下文中一共展示了ActionMessages.size方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doErrorsExist

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
 * Determine if there are errors for the component.
 * @return Whether errors exist.
 */
protected boolean doErrorsExist() throws JspException {

    boolean errorsExist = false;

    if (getErrorStyleId() != null ||
        getErrorStyle() != null ||
        getErrorStyleClass() != null) {
        String actualName = prepareName();
        if (actualName != null) {
            ActionMessages errors = TagUtils.getInstance()
                                            .getActionMessages(pageContext,
                                                               errorKey);
            errorsExist = (errors != null && errors.size(actualName) > 0);
        }
    }
    return errorsExist;

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:BaseHandlerTag.java

示例2: saveRoomFeature

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
 * 
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward saveRoomFeature(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) throws Exception {
	RoomFeatureEditForm roomFeatureEditForm = (RoomFeatureEditForm) form;
	ActionMessages errors = new ActionMessages();
	
	//Validate input prefs
       errors = roomFeatureEditForm.validate(mapping, request);
       if(errors.size()==0) {
		update(mapping, roomFeatureEditForm, request, response);
       }else {
       	saveErrors(request, errors);
       	editRoomFeature(mapping, form, request, response);
       	return mapping.findForward("showEdit");
       }
			
       roomFeatureEditForm.setDeptCode((String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom));
	if (roomFeatureEditForm.getId()!=null)
		request.setAttribute("hash", "A"+roomFeatureEditForm.getId());
	return mapping.findForward("showRoomFeatureList");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:33,代碼來源:RoomFeatureEditAction.java

示例3: saveRoomGroup

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
 * 
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward saveRoomGroup(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) throws Exception {
	RoomGroupEditForm roomGroupEditForm = (RoomGroupEditForm) form;
	ActionMessages errors = new ActionMessages();
	
	//Validate input prefs
       errors = roomGroupEditForm.validate(mapping, request);
       if(errors.size()==0) {
		update(mapping, roomGroupEditForm, request, response);
       } else {
       	saveErrors(request, errors);
		editRoomGroup(mapping, form, request, response);
		return mapping.findForward("showEdit");
       }
			
	if (roomGroupEditForm.getId()!=null)
		request.setAttribute("hash", "A"+roomGroupEditForm.getId());
	return mapping.findForward("showRoomGroupList");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:32,代碼來源:RoomGroupEditAction.java

示例4: execute

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/** 
 * Method execute
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 */
public ActionForward execute(
	ActionMapping mapping,
	ActionForm form,
	HttpServletRequest request,
	HttpServletResponse response) throws Exception {
	RoomFeatureEditForm roomFeatureEditForm = (RoomFeatureEditForm) form;
	
	MessageResources rsc = getResources(request);
	String doit = roomFeatureEditForm.getDoit();
	
	if (doit != null) {
		//add new
		if(doit.equals(rsc.getMessage("button.addNew"))) {
			ActionMessages errors = new ActionMessages();
			errors = roomFeatureEditForm.validate(mapping, request);
	        if(errors.size()==0) {
	        	save(mapping, roomFeatureEditForm, request, response);
				return mapping.findForward("showRoomFeatureList");
	        } else {
	        	saveErrors(request, errors);
	        }
		}
		
		//return to room list
		if(doit.equals(rsc.getMessage("button.returnToRoomFeatureList"))) {
			return mapping.findForward("showRoomFeatureList");
		}
	}
	
	//get depts owned by user
	LookupTables.setupDepartments(request, sessionContext, false);
	LookupTables.setupExamTypes(request, sessionContext.getUser(), DepartmentStatusType.Status.ExamView, DepartmentStatusType.Status.ExamTimetable);
	request.setAttribute("featureTypes", RoomFeatureTypeDAO.getInstance().findAll(Order.asc("label")));
	
       //set default department
	TreeSet<Department> departments = Department.getUserDepartments(sessionContext.getUser());
       if (departments.size() == 1) {
       	roomFeatureEditForm.setDeptCode(departments.first().getDeptCode());
       } else {
       	String deptCode = (String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom);
       	if (deptCode != null && !deptCode.isEmpty() && !deptCode.equals("All") && !deptCode.matches("Exam[0-9]*"))
       		roomFeatureEditForm.setDeptCode(deptCode);
	}
	
	if (roomFeatureEditForm.getDeptCode() == null || roomFeatureEditForm.getDeptCode().isEmpty() || roomFeatureEditForm.getDeptCode().matches("Exam[0-9]*") ||
			!sessionContext.hasPermission(roomFeatureEditForm.getDeptCode(), "Department", Right.DepartmentRoomFeatureAdd)) {
		sessionContext.checkPermission(Right.GlobalRoomFeatureAdd);
		roomFeatureEditForm.setGlobal(true);
	} else {
		sessionContext.checkPermission(roomFeatureEditForm.getDeptCode(), "Department", Right.DepartmentRoomFeatureAdd);
		roomFeatureEditForm.setGlobal(false);
	}
	
	roomFeatureEditForm.setSessionId(sessionContext.getUser().getCurrentAcademicSessionId());
	
	return mapping.findForward("showAdd");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:66,代碼來源:RoomFeatureAddAction.java

示例5: execute

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/** 
   * Method execute
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) throws Exception {
      
      // Check Access
  	sessionContext.checkPermission(Right.SettingsUser);
      
MessageResources rsc = getResources(request);
      ManagerSettingsForm frm = (ManagerSettingsForm) form;
      String op = frm.getOp();
 
      if(op==null) {
          op = request.getParameter("op");
          if(op==null) {
              frm.setOp("List");
           op = "List";
          }
      }
      
      // Reset Form
      if(op.equals(rsc.getMessage("button.cancelUpdateSetting"))) {
          frm.reset(mapping, request);
          frm.setOp("List");
      }

      // Edit - Load setting with allowed values for user to update
      if(op.equals("Edit")) {
          // Load Settings object
          Settings s = SettingsDAO.getInstance().get(Long.valueOf(request.getParameter("id")));

          // Set Form values
          frm.setOp("Edit");            
          frm.setAllowedValues(s.getAllowedValues());
          frm.setKey(s.getKey());
          frm.setName(s.getDescription());
          frm.setDefaultValue(s.getDefaultValue());
          frm.setValue(sessionContext.getUser().getProperty(s.getKey(), s.getDefaultValue()));

          return mapping.findForward("editManagerSettings");
      }
 
      // Save changes made by the user
      if(op.equals(rsc.getMessage("button.updateSetting"))) {
          ActionMessages errors = frm.validate(mapping, request);
          if(errors.size()>0) {
              saveErrors(request, errors);
              frm.setOp("Edit");
          } else {
          	sessionContext.getUser().setProperty(frm.getKey(), frm.getValue());
  	    }
      }

      // Read all existing settings and store in request
      getSettingsList(request);        
      return mapping.findForward("showManagerSettings");
  }
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:67,代碼來源:ManagerSettingsAction.java

示例6: execute

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/** 
 * Method execute
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 */
public ActionForward execute(
	ActionMapping mapping,
	ActionForm form,
	HttpServletRequest request,
	HttpServletResponse response) throws Exception {
	RoomGroupListForm roomGroupListForm = (RoomGroupListForm) form;
	
	sessionContext.checkPermission(Right.RoomGroups);
	
	ActionMessages errors = new ActionMessages();
	
	//get deptCode from request - for user with only one department
	String deptCode = (String)request.getAttribute("deptCode");
	if (deptCode != null) {
		roomGroupListForm.setDeptCodeX(deptCode);
	}
	
	if (sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom) != null && roomGroupListForm.getDeptCodeX() == null) {
		deptCode = (String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom);
		if (deptCode != null && ("All".equals(deptCode) || deptCode.matches("Exam[0-9]*")))
			roomGroupListForm.setDeptCodeX((String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom));
	}

	// Set Session Variable
	if (roomGroupListForm.getDeptCodeX() != null && !roomGroupListForm.getDeptCodeX().isEmpty())
		sessionContext.setAttribute(SessionAttribute.DepartmentCodeRoom, roomGroupListForm.getDeptCodeX());

	//set request attribute for department
	LookupTables.setupDepartments(request, sessionContext, true);
	LookupTables.setupExamTypes(request, sessionContext.getUser(), DepartmentStatusType.Status.ExamView, DepartmentStatusType.Status.ExamTimetable);
	
	// Validate input
	errors = roomGroupListForm.validate(mapping, request);

	// Validation fails
	if (errors.size() > 0) {
		saveErrors(request, errors);
		return mapping.findForward("showRoomGroupSearch");
	}

	buildGroupTable(request, roomGroupListForm);
	
	if ("Export PDF".equals(request.getParameter("op"))) {
		sessionContext.checkPermission(Right.RoomGroupsExportPdf);
		OutputStream out = ExportUtils.getPdfOutputStream(response, "roomGroups");
		printPdfGroupTable(out, sessionContext, roomGroupListForm);
		out.flush(); out.close();
		return null;
	}

	return mapping.findForward("showRoomGroupList");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:61,代碼來源:RoomGroupListAction.java

示例7: execute

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/** 
 * Method execute
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 */
public ActionForward execute(
	ActionMapping mapping,
	ActionForm form,
	HttpServletRequest request,
	HttpServletResponse response) throws Exception{
	RoomGroupEditForm roomGroupEditForm = (RoomGroupEditForm) form;
	
	MessageResources rsc = getResources(request);
	String doit = roomGroupEditForm.getDoit();
	
	if (doit != null) {
		//add new
		if(doit.equals(rsc.getMessage("button.addNew"))) {
			ActionMessages errors = new ActionMessages();
			errors = roomGroupEditForm.validate(mapping, request);
	        if(errors.size()==0) {
	        	save(mapping, roomGroupEditForm, request, response);
				return mapping.findForward("showRoomGroupList");
	        } else {
	        	saveErrors(request, errors);
	        }
		}
		
		//return to room list
		if(doit.equals(rsc.getMessage("button.returnToRoomGroupList"))) {
			return mapping.findForward("showRoomGroupList");
		}
	}
	
	//get depts owned by user
	LookupTables.setupDepartments(request, sessionContext, false);
	
       //set default department
	TreeSet<Department> departments = Department.getUserDepartments(sessionContext.getUser());
       if (departments.size() == 1) {
       	roomGroupEditForm.setDeptCode(departments.first().getDeptCode());
       } else {
       	String deptCode = (String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom);
       	if (deptCode != null && !deptCode.isEmpty() && !deptCode.equals("All") && !deptCode.matches("Exam[0-9]*"))
       		roomGroupEditForm.setDeptCode(deptCode);
	}
	
	if (roomGroupEditForm.getDeptCode() == null || roomGroupEditForm.getDeptCode().isEmpty() || roomGroupEditForm.getDeptCode().matches("Exam[0-9]*") ||
		!sessionContext.hasPermission(roomGroupEditForm.getDeptCode(), "Department", Right.DepartmentRoomGroupAdd)) {
		sessionContext.checkPermission(Right.GlobalRoomGroupAdd);
		roomGroupEditForm.setGlobal(true);
	} else {
		sessionContext.checkPermission(roomGroupEditForm.getDeptCode(), "Department", Right.DepartmentRoomGroupAdd);
		roomGroupEditForm.setGlobal(false);
	}
	
	roomGroupEditForm.setSessionId(sessionContext.getUser().getCurrentAcademicSessionId());
	
	return mapping.findForward("showAdd");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:64,代碼來源:RoomGroupAddAction.java

示例8: execute

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/** 
 * Method execute
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws Exception 
 */
public ActionForward execute(
	ActionMapping mapping,
	ActionForm form,
	HttpServletRequest request,
	HttpServletResponse response) throws Exception {
	NonUnivLocationForm nonUnivLocationForm = (NonUnivLocationForm) form;
	MessageResources rsc = getResources(request);
	ActionMessages errors = new ActionMessages();
	
	sessionContext.checkPermission(Right.AddNonUnivLocation);
	
	Set<Department> departments = Department.getUserDepartments(sessionContext.getUser());
	
	if (nonUnivLocationForm.getDoit() != null) {
		String doit = nonUnivLocationForm.getDoit();
		if (doit.equals(rsc.getMessage("button.returnToRoomList"))) {
			return mapping.findForward("showRoomList");
		}
		if (doit.equals(rsc.getMessage("button.addNew"))) {
		     // Validate input prefs
            errors = nonUnivLocationForm.validate(mapping, request);
            
            if (errors.isEmpty() && !sessionContext.hasPermission(nonUnivLocationForm.getDeptCode(), "Department", Right.AddNonUnivLocation)) {
            	errors.add("nonUniversityLocation", new ActionMessage("errors.generic", "Acess denied."));
            }
            
            // No errors
            if(errors.size()==0) {
            	update(request, nonUnivLocationForm);
				return mapping.findForward("showRoomList");
            }
            else {
            	setDepts(request, departments);
                saveErrors(request, errors);
				return mapping.findForward("showAdd");
            }
		}
	}
	
	setDepts(request, departments);
	
       nonUnivLocationForm.setDeptSize(departments.size());
       if (departments.size() == 1) {
       	Department d = departments.iterator().next();
       	nonUnivLocationForm.setDeptCode(d.getDeptCode());
       } else if (sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom) != null) {
		nonUnivLocationForm.setDeptCode((String) sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom));
	}
	
	return mapping.findForward("showAdd");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:61,代碼來源:AddNonUnivLocationAction.java

示例9: execute

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
 * Method execute
 * 
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws HibernateException
 */
public ActionForward execute(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response)
		throws Exception {
	RoomFeatureListForm roomFeatureListForm = (RoomFeatureListForm) form;

	sessionContext.checkPermission(Right.RoomFeatures);

	ActionMessages errors = new ActionMessages();
	
	//get deptCode from request - for user with only one department
	String deptCode = (String)request.getAttribute("deptCode");
	if (deptCode != null) {
		roomFeatureListForm.setDeptCodeX(deptCode);
	}

	if (sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom) != null && roomFeatureListForm.getDeptCodeX() == null) {
		deptCode = (String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom);
		if (deptCode != null && ("All".equals(deptCode) || deptCode.matches("Exam[0-9]*")))
			roomFeatureListForm.setDeptCodeX((String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom));
	}

	// Set Session Variable
	if (roomFeatureListForm.getDeptCodeX() != null && !roomFeatureListForm.getDeptCodeX().isEmpty())
		sessionContext.setAttribute(SessionAttribute.DepartmentCodeRoom, roomFeatureListForm.getDeptCodeX());
	
	// Validate input
	errors = roomFeatureListForm.validate(mapping, request);

	//set request attribute for department
	LookupTables.setupDepartments(request, sessionContext, true);
	LookupTables.setupExamTypes(request, sessionContext.getUser(), DepartmentStatusType.Status.ExamView, DepartmentStatusType.Status.ExamTimetable);

	// Validation fails
	if (errors.size() > 0) {
		saveErrors(request, errors);
		return mapping.findForward("showRoomFeatureSearch");
	}
	
	roomFeatureListForm.setGlobalRoomFeatures(RoomFeature.getAllGlobalRoomFeatures(sessionContext.getUser().getCurrentAcademicSessionId()));
	
	Set<DepartmentRoomFeature> departmentRoomFeatures = new TreeSet<DepartmentRoomFeature>();
	for (Department d: Department.getUserDepartments(sessionContext.getUser())) {
		if ("All".equals(roomFeatureListForm.getDeptCodeX()) || d.getDeptCode().equals(roomFeatureListForm.getDeptCodeX()))
			departmentRoomFeatures.addAll(RoomFeature.getAllDepartmentRoomFeatures(d));
	}
       if (roomFeatureListForm.getDeptCodeX() != null && !roomFeatureListForm.getDeptCodeX().isEmpty() && !"All".equals(roomFeatureListForm.getDeptCodeX()) && !roomFeatureListForm.getDeptCodeX().matches("Exam[0-9]*")) {
       	Department department = Department.findByDeptCode(roomFeatureListForm.getDeptCodeX(), sessionContext.getUser().getCurrentAcademicSessionId());
       	if (department != null && department.isExternalManager())
       		departmentRoomFeatures.addAll(RoomFeature.getAllDepartmentRoomFeatures(department));
       }
	roomFeatureListForm.setDepartmentRoomFeatures(departmentRoomFeatures);

	buildFeatureTable(request, roomFeatureListForm);
	
	if ("Export PDF".equals(request.getParameter("op"))) {
		sessionContext.checkPermission(Right.RoomFeaturesExportPdf);
		OutputStream out = ExportUtils.getPdfOutputStream(response, "roomFeatures");
		printPdfFeatureTable(out, sessionContext, roomFeatureListForm);
		out.flush(); out.close();
		return null;
	}

	return mapping.findForward("showRoomFeatureList");

}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:76,代碼來源:RoomFeatureListAction.java

示例10: execute

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	try {
	    
		DepartmentEditForm myForm = (DepartmentEditForm) form;
		MessageResources rsc = getResources(request);
	
		// Check Access
		sessionContext.checkPermission(Right.Departments);
		
		// Read operation to be performed
		String op = (myForm.getOp()!=null?myForm.getOp():request.getParameter("op"));
		
		request.setAttribute(Department.DEPT_ATTR_NAME, Department.findAllNonExternal(sessionContext.getUser().getCurrentAcademicSessionId()));
		
        // Edit
        if(rsc.getMessage("op.edit").equalsIgnoreCase(op)) {
            String id = request.getParameter("id");
            Department department = (new DepartmentDAO()).get(Long.valueOf(id));
            if (department!=null) {
            	sessionContext.checkPermission(department, Right.DepartmentEdit);
            	myForm.load(department);
            	return mapping.findForward("edit");
            }
        }
        
        // Add
        if(rsc.getMessage("button.addDepartment").equalsIgnoreCase(op)) {
           	myForm.reset(mapping, request);
           	myForm.setSessionId(sessionContext.getUser().getCurrentAcademicSessionId());
           	myForm.setInheritInstructorPreferences(true);
           	myForm.setAllowStudentScheduling(true);
       		sessionContext.checkPermission(Right.DepartmentAdd);
           	return mapping.findForward("add");
        }
        
        // Update/Save
        if (rsc.getMessage("button.updateDepartment").equalsIgnoreCase(op)
        		|| rsc.getMessage("button.saveDepartment").equalsIgnoreCase(op)) {
            // Validate input
            ActionMessages errors = myForm.validate(mapping, request);
            if(errors.size()>0) {
                saveErrors(request, errors);
                if (myForm.getId()!=null)
                	return mapping.findForward("edit");
                else
                	return mapping.findForward("add");
            } else {
            	if (myForm.getId() == null || myForm.getId().equals(0l))
            		sessionContext.checkPermission(Right.DepartmentAdd);
            	else
            		sessionContext.checkPermission(myForm.getId(), "Department", Right.DepartmentEdit);
            	myForm.save(sessionContext);
            }
        }
        
        if ("Add Status".equals(op)) {
        	myForm.addBlankDependentDepartment();
        	return mapping.findForward(myForm.getId() == null ? "add" : "edit");
        }

        if ("Delete".equals(op) && request.getParameter("deleteId") != null && !request.getParameter("deleteId").isEmpty()) {
        	myForm.deleteDependentDepartment(Integer.parseInt(request.getParameter("deleteId")));
        	return mapping.findForward(myForm.getId() == null ? "add" : "edit");
        }
        
        // Delete
        if(rsc.getMessage("button.deleteDepartment").equalsIgnoreCase(op)) {
        	doDelete(myForm);
        }
        
       	if (myForm.getId()!=null)
          		request.setAttribute(Constants.JUMP_TO_ATTR_NAME, myForm.getId().toString());
       	
        return mapping.findForward("back");
	} catch (Exception e) {
		Debug.error(e);
		throw e;
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:80,代碼來源:DepartmentEditAction.java

示例11: execute

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
 * Method execute
 * 
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws HibernateException
 */
public ActionForward execute(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response)
		throws Exception {
	
	sessionContext.checkPermission(Right.Rooms);
	
	RoomListForm roomListForm = (RoomListForm) form;
	roomListForm.save(request.getSession());
	ActionMessages errors = new ActionMessages();
	
	//get deptCode from request - for user with only one department
	String dept = (String)request.getAttribute("deptCode");
	if (dept != null) {
		roomListForm.setDeptCodeX(dept);
	}
	
	if (sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom) != null && roomListForm.getDeptCodeX() == null)
		roomListForm.setDeptCodeX((String)sessionContext.getAttribute(SessionAttribute.DepartmentCodeRoom));

	// Set Session Variable
	if (roomListForm.getDeptCodeX() != null && !roomListForm.getDeptCodeX().isEmpty()) {
		sessionContext.setAttribute(SessionAttribute.DepartmentCodeRoom, roomListForm.getDeptCodeX());
	}
	
	//set request attribute for department
	LookupTables.setupDepartments(request, sessionContext, true);
	LookupTables.setupExamTypes(request, sessionContext.getUser(), DepartmentStatusType.Status.ExamView, DepartmentStatusType.Status.ExamTimetable);

	// Validate input
	errors = roomListForm.validate(mapping, request);

	// Validation fails
	if (errors.size() > 0) {
		saveErrors(request, errors);
		return mapping.findForward("showRoomSearch");
	}
	
	lookupRooms(roomListForm, request.getParameter("op"));
	
	if (roomListForm.getRooms() == null || roomListForm.getRooms().isEmpty()) {
		errors.add("searchResult", new ActionMessage("errors.generic", "No room matching the above criteria was found."));
		request.setAttribute("colspan","7"); 
		saveErrors(request, errors);
		return mapping.findForward("showRoomSearch");
	}
	
	ExamType examType = null;
	if (roomListForm.getDeptCodeX() != null && roomListForm.getDeptCodeX().matches("Exam[0-9]*"))
		examType = ExamTypeDAO.getInstance().get(Long.valueOf(roomListForm.getDeptCodeX().substring(4)));
	
	if ("Export PDF".equals(request.getParameter("op"))) {
		OutputStream out = ExportUtils.getPdfOutputStream(response, "rooms");
		buildPdfWebTable(out, roomListForm, CommonValues.Yes.eq(UserProperty.RoomFeaturesInOneColumn.get(sessionContext.getUser())), examType);
		out.flush(); out.close();
		return null;
	}
	
	if ("Export CSV".equals(request.getParameter("op"))) {
		PrintWriter pw = ExportUtils.getCsvWriter(response, "rooms");
		buildCsvWebTable(pw, roomListForm, CommonValues.Yes.eq(UserProperty.RoomFeaturesInOneColumn.get(sessionContext.getUser())), examType);
		pw.flush(); pw.close();
		return null;
	}
	
	// build web table for university locations
	buildWebTable(request, roomListForm, CommonValues.Yes.eq(UserProperty.RoomFeaturesInOneColumn.get(sessionContext.getUser())), examType);
	
	return mapping.findForward("showRoomList");

}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:81,代碼來源:RoomListAction.java

示例12: execute

import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/** 
 * Method execute
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 */
public ActionForward execute(
		ActionMapping mapping, 
		ActionForm form,
		HttpServletRequest request, 
		HttpServletResponse response) throws Exception {
	
	// Check Access
	sessionContext.checkPermission(Right.SubjectAreas);
	
	SubjectAreaEditForm frm = (SubjectAreaEditForm) form;
	MessageResources rsc = getResources(request);
	ActionMessages errors=null;
	
	// Read operation to be performed
	String op = (frm.getOp()!=null
					? frm.getOp()
					: request.getParameter("op"));
	
       // Add
       if(op.equals(rsc.getMessage("button.addSubjectArea"))) {
       	sessionContext.checkPermission(Right.SubjectAreaAdd);
   		LookupTables.setupNonExternalDepts(request, sessionContext.getUser().getCurrentAcademicSessionId());
       	return mapping.findForward("addSubjectArea");
       }
       
       // Edit
       if(op.equals(rsc.getMessage("op.edit"))) {
           doLoad(request, frm);
   		LookupTables.setupNonExternalDepts(request, sessionContext.getUser().getCurrentAcademicSessionId());
       	return mapping.findForward("editSubjectArea");
       }
       
       // Update
       if (op.equals(rsc.getMessage("button.updateSubjectArea"))
       		|| op.equals(rsc.getMessage("button.saveSubjectArea")) ) {
           // Validate input
           errors = frm.validate(mapping, request);
           if(errors.size()==0) {
           	doUpdate(request, frm);
           }
       }
       
       // Delete
       if(op.equals(rsc.getMessage("button.deleteSubjectArea"))) {
           errors = frm.validate(mapping, request);
           if(errors.size()==0) {
           	doDelete(request, frm);
           }
       }
       
   	if (frm.getUniqueId()!=null)
      		request.setAttribute(Constants.JUMP_TO_ATTR_NAME, frm.getUniqueId().toString());
   	
   	if (errors!=null && errors.size()>0) {
        saveErrors(request, errors);
		LookupTables.setupNonExternalDepts(request, sessionContext.getUser().getCurrentAcademicSessionId());
        if (frm.getUniqueId()!=null)
        	return mapping.findForward("editSubjectArea");
        else
        	return mapping.findForward("addSubjectArea");
   	}
   	
       return mapping.findForward("back");
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:73,代碼來源:SubjectAreaEditAction.java


注:本文中的org.apache.struts.action.ActionMessages.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。