Java Code Examples for org.apache.struts.action.ActionMapping.findForward()

The following are Jave code examples for showing how to use findForward() of the org.apache.struts.action.ActionMapping class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: LearningAction.java   View Source Code Vote up 6 votes
/**
    * Opens the notebook page for reflections
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

LearningForm lrnForm = (LearningForm) form;

// set the finished flag
WikiUser wikiUser = this.getCurrentUser(lrnForm.getToolSessionID());
WikiDTO wikiDTO = new WikiDTO(wikiUser.getWikiSession().getWiki());

request.setAttribute("wikiDTO", wikiDTO);

NotebookEntry notebookEntry = wikiService.getEntry(wikiUser.getWikiSession().getSessionId(),
	CoreNotebookConstants.NOTEBOOK_TOOL, WikiConstants.TOOL_SIGNATURE, wikiUser.getUserId().intValue());

if (notebookEntry != null) {
    lrnForm.setEntryText(notebookEntry.getEntry());
}

LearningWebUtil.putActivityPositionInRequestByToolSessionId(lrnForm.getToolSessionID(), request,
	getServlet().getServletContext());

return mapping.findForward("notebook");
   }
 
Example 2
Project: lams   File: MonitoringAction.java   View Source Code Vote up 6 votes
private ActionForward statistic(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

initializeScratchieService();
String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());

Scratchie scratchie = (Scratchie) sessionMap.get(ScratchieConstants.ATTR_SCRATCHIE);
if ( scratchie != null ) {
    LeaderResultsDTO leaderDto = service.getLeaderResultsDTOForLeaders(scratchie.getContentId());
    sessionMap.put("leaderDto", leaderDto);
}
return mapping.findForward(ScratchieConstants.SUCCESS);
   }
 
Example 3
Project: unitimes   File: RoomGroupEditAction.java   View Source Code Vote up 6 votes
/**
 * 
 * @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");
}
 
Example 4
Project: joai-project   File: OdlSearchAction.java   View Source Code Vote up 6 votes
/**
 *  Processes the specified HTTP request and creates the corresponding HTTP response by forwarding to a JSP
 *  that will create it. Returns an {@link org.apache.struts.action.ActionForward} instance that maps to the
 *  Struts forwarding name "simple.query," which must be configured in struts-config.xml to forward to the
 *  JSP page that will handle the request.
 *
 * @param  mapping               The ActionMapping used to select this instance
 * @param  request               The HTTP request we are processing
 * @param  response              The HTTP response we are creating
 * @param  form                  The ActionForm for the given page
 * @return                       The ActionForward instance describing where and how control should be
 *      forwarded
 * @exception  IOException       if an input/output error occurs
 * @exception  ServletException  if a servlet exception occurs
 */
public ActionForward execute(
                             ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
	 throws IOException, ServletException {
	/*
	 *  Design note:
	 *  Only one instance of this class gets created for the app and shared by
	 *  all threads. To be thread-safe, use only local variables, not instance
	 *  variables (the JVM will handle these properly using the stack). Pass
	 *  all variables via method signatures rather than instance vars.
	 */
	OdlSearchForm osf = (OdlSearchForm) form;

	// Set up params for paging:
	if (request.getParameter("s") != null) {
		try {

		} catch (Throwable e) {}
	}

	return mapping.findForward("remote.query");
}
 
Example 5
Project: lams   File: AdminAction.java   View Source Code Vote up 6 votes
public ActionForward saveContent(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
AdminForm adminForm = (AdminForm) form;

if (adminForm.getLanguagesCSV() != null && !adminForm.getLanguagesCSV().equals("")) {
    // set up mdlForumService
    if (pixlrService == null) {
	pixlrService = PixlrServiceProxy.getPixlrService(this.getServlet().getServletContext());
    }

    PixlrConfigItem pixlrKey = pixlrService.getConfigItem(PixlrConfigItem.KEY_LANGUAGE_CSV);
    pixlrKey.setConfigValue(adminForm.getLanguagesCSV());
    pixlrService.saveOrUpdatePixlrConfigItem(pixlrKey);

    request.setAttribute("savedSuccess", true);
    return mapping.findForward("config");
} else {
    request.setAttribute("error", true);
    return mapping.findForward("config");
}
   }
 
Example 6
Project: lams   File: McAction.java   View Source Code Vote up 6 votes
public ActionForward newCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException {
String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapId);
request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId);

String candidateIndex = request.getParameter("candidateIndex");
request.setAttribute("candidateIndex", candidateIndex);

List<McOptionDTO> optionDtos = McAction.repopulateOptionDTOs(request, true);

//newAddedCandidateBox
McQuestionDTO questionDto = (McQuestionDTO) sessionMap.get(McAppConstants.QUESTION_DTO);
questionDto.setOptionDtos(optionDtos);
sessionMap.put(McAppConstants.QUESTION_DTO, questionDto);

return (mapping.findForward("candidateAnswersList"));
   }
 
Example 7
Project: unitimes   File: InstructionalOfferingListAction.java   View Source Code Vote up 5 votes
public ActionForward execute(
	ActionMapping mapping,
	ActionForm form,
	HttpServletRequest request,
	HttpServletResponse response) throws HibernateException {

	return mapping.findForward("showInstructionalOfferingList");
	
}
 
Example 8
Project: lams   File: MonitoringAction.java   View Source Code Vote up 5 votes
/**
    * View topic subject, content and attachement.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward viewTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

Long msgUid = new Long(WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID));

forumService = getForumService();
Message topic = forumService.getMessage(msgUid);

request.setAttribute(ForumConstants.AUTHORING_TOPIC, MessageDTO.getMessageDTO(topic));
return mapping.findForward("success");
   }
 
Example 9
Project: lams   File: MonitoringAction.java   View Source Code Vote up 5 votes
@Override
   public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

setupService();

Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID));

String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);

Gmap gmap = gmapService.getGmapByContentId(toolContentID);

if (gmap == null) {
    // TODO error page.
}

GmapDTO gmapDT0 = new GmapDTO(gmap);

// Adding the markers lists to a map with tool sessions as the key


if (gmapDT0.getSessionDTOs() != null) {
    for (GmapSessionDTO sessionDTO : gmapDT0.getSessionDTOs()) {
	Long toolSessionID = sessionDTO.getSessionID();
	sessionDTO.setMarkerDTOs(gmapService.getGmapMarkersBySessionId(toolSessionID));
    }
}

// get the gmap API key from the config table and add it to the session
GmapConfigItem gmapKey = gmapService.getConfigItem(GmapConfigItem.KEY_GMAP_KEY);
if (gmapKey != null && gmapKey.getConfigValue() != null) {
    request.setAttribute(GmapConstants.ATTR_GMAP_KEY, gmapKey.getConfigValue());
}

boolean isGroupedActivity = gmapService.isGroupedActivity(toolContentID);
request.setAttribute("isGroupedActivity", isGroupedActivity);
request.setAttribute("gmapDTO", gmapDT0);
request.setAttribute("contentFolderID", contentFolderID);
return mapping.findForward("success");
   }
 
Example 10
Project: lams   File: NotebookAction.java   View Source Code Vote up 5 votes
/**
    * View all notebook entries
    */
   public ActionForward viewAll(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException {

// initialize service object
ICoreNotebookService notebookService = getNotebookService();

DynaActionForm notebookForm = (DynaActionForm) actionForm;

// getting requested object according to coming parameters
Integer learnerID = LearningWebUtil.getUserId();

// lessonID
Long lessonID = (Long) notebookForm.get("currentLessonID");
if (lessonID == null || lessonID == 0) {
    lessonID = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID);
}

// get all notebook entries for the learner

TreeMap<Long, List<NotebookEntry>> entries = notebookService.getEntryByLesson(learnerID,
	CoreNotebookConstants.SCRATCH_PAD);

request.getSession().setAttribute("entries", entries.values());
request.setAttribute("lessonID", lessonID);

return mapping.findForward(NotebookAction.VIEW_ALL);

   }
 
Example 11
Project: lams   File: AuthoringChatConditionAction.java   View Source Code Vote up 5 votes
/**
    * This method will get necessary information from taskList item form and save or update into
    * <code>HttpSession</code> ChatItemList. Notice, this save is not persist them into database, just save
    * <code>HttpSession</code> temporarily. Only they will be persist when the entire authoring page is being
    * persisted.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    * @throws ServletException
    */
   private ActionForward saveOrUpdateCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

ChatConditionForm conditionForm = (ChatConditionForm) form;
ActionErrors errors = validateChatCondition(conditionForm, request);

if (!errors.isEmpty()) {
    this.addErrors(request, errors);
    return mapping.findForward("addcondition");
}

try {
    extractFormToChatCondition(request, conditionForm);
} catch (Exception e) {
    // any upload exception will display as normal error message rather then throw exception directly
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage(ChatConstants.ERROR_MSG_CONDITION, e.getMessage()));
    if (!errors.isEmpty()) {
	this.addErrors(request, errors);
	return mapping.findForward("addcondition");
    }
}
// set session map ID so that itemlist.jsp can get sessionMAP
request.setAttribute(ChatConstants.ATTR_SESSION_MAP_ID, conditionForm.getSessionMapID());
// return null to close this window
return mapping.findForward(ChatConstants.SUCCESS);
   }
 
Example 12
Project: lams   File: LearningAction.java   View Source Code Vote up 5 votes
/**
     * Display empty reflection form.
     * 
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     */
    private ActionForward newReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request,
	    HttpServletResponse response) {

	//get session value
	String sessionMapID = WebUtil.readStrParam(request, SpreadsheetConstants.ATTR_SESSION_MAP_ID);

	ReflectionForm refForm = (ReflectionForm) form;
	HttpSession ss = SessionManager.getSession();
	UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);

	refForm.setUserID(user.getUserID());
	refForm.setSessionMapID(sessionMapID);

//		 get the existing reflection entry
	ISpreadsheetService submitFilesService = getSpreadsheetService();

	SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);
	Long toolSessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
	NotebookEntry entry = submitFilesService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL,
		SpreadsheetConstants.TOOL_SIGNATURE, user.getUserID());

	if (entry != null) {
	    refForm.setEntryText(entry.getEntry());
	}

	return mapping.findForward(SpreadsheetConstants.SUCCESS);
    }
 
Example 13
Project: lams   File: AuthoringAction.java   View Source Code Vote up 5 votes
private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) {
// get back sessionMAP
String sessionMapID = WebUtil.readStrParam(request, ImageGalleryConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);

int imageIdx = NumberUtils.stringToInt(request.getParameter(ImageGalleryConstants.PARAM_IMAGE_INDEX), -1);
if (imageIdx != -1) {
    SortedSet<ImageGalleryItem> taskListList = getImageList(sessionMap);
    List<ImageGalleryItem> rList = new ArrayList<ImageGalleryItem>(taskListList);
    // get current and the target item, and switch their sequnece
    ImageGalleryItem image = rList.get(imageIdx);
    ImageGalleryItem repImage;
    if (up) {
	repImage = rList.get(--imageIdx);
    } else {
	repImage = rList.get(++imageIdx);
    }
    int upSeqId = repImage.getSequenceId();
    repImage.setSequenceId(image.getSequenceId());
    image.setSequenceId(upSeqId);

    // put back list, it will be sorted again
    taskListList.clear();
    taskListList.addAll(rList);
}

request.setAttribute(ImageGalleryConstants.ATTR_SESSION_MAP_ID, sessionMapID);
return mapping.findForward(ImageGalleryConstants.SUCCESS);
   }
 
Example 14
Project: joai-project   File: RepositoryAction.java   View Source Code Vote up 5 votes
/**
 *  Handles the OAI ListSets request. From the spec, this request has the following properties: <p>
 *
 *  Arguments<br>
 *  resumptionToken - an exclusive argument with a value that is the flow control token returned by a
 *  previous ListSets request that issued an incomplete list<p>
 *
 *  Error and Exception Conditions<br>
 *  badArgument - The request includes illegal arguments or is missing required arguments.<br>
 *  badResumptionToken - The value of the resumptionToken argument is invalid or expired. <br>
 *  noSetHierarchy - The repository does not support sets.<br>
 *
 *
 * @param  request   The HTTP request.
 * @param  mapping   The Struts ActionMapping used for forwarding.
 * @param  num_args  The number of arguments other than the OAI verb or rt.
 * @param  rm        The model used to fetch OAI data.
 * @param  rf        The bean used to handle the response.
 * @return           The page to forward to that will render the response, or null if handled here.
 */
protected ActionForward doListSets(
                                   HttpServletRequest request,
                                   ActionMapping mapping,
                                   int num_args,
                                   RepositoryManager rm,
                                   RepositoryForm rf) {
	//prtln("doListSets()");

	if (request.getParameter(OAIArgs.RESUMPTION_TOKEN) == null &&
		num_args >= 1)
		rf.addOaiError(OAICodes.BAD_ARGUMENT,
			"The " + OAIArgs.LIST_SETS +
			" request may only include the argument '" +
			OAIArgs.RESUMPTION_TOKEN + "'");

	if (!rm.getHasOaiSetsConfigured())
		rf.addOaiError(OAICodes.NO_SET_HIERARCHY,
			"This repository does not currently have any sets defined");

	// All info is extracted directly from the rm so no set up here...

	if (rf.hasErrors()) {
		logRequest(request, OAIArgs.LIST_SETS, rf.getErrors());
		return (mapping.findForward("oaipmh.error"));
	}
	else {
		logRequest(request, OAIArgs.LIST_SETS);
		return (mapping.findForward("oaipmh." + OAIArgs.LIST_SETS));
	}
}
 
Example 15
Project: lams   File: GradebookMonitoringAction.java   View Source Code Vote up 5 votes
@Override
   public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {
try {
    Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
    if (GradebookMonitoringAction.log.isDebugEnabled()) {
	GradebookMonitoringAction.log.debug("Getting gradebook for lesson " + lessonId);
    }
    UserDTO user = getUser();
    if (user == null) {
	GradebookMonitoringAction.log.error("User missing from session. ");
	return mapping.findForward("error");
    }
    if (!getSecurityService().isLessonMonitor(lessonId, user.getUserID(), "get lesson gradebook", false)) {
	response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson");
	return null;
    }

    Lesson lesson = getLessonService().getLesson(lessonId);
    boolean marksReleased = (lesson.getMarksReleased() != null) && lesson.getMarksReleased();
    LessonDetailsDTO lessonDetatilsDTO = lesson.getLessonDetails();
    request.setAttribute("lessonDetails", lessonDetatilsDTO);
    request.setAttribute("marksReleased", marksReleased);
    
    List<String[]> weights = getGradebookService().getWeights(lesson.getLearningDesign());
    if ( weights.size() > 0 ) {
	request.setAttribute("weights", weights);
    }
    
    request.setAttribute("isInTabs", WebUtil.readBooleanParam(request, "isInTabs", false));

    return mapping.findForward("monitorgradebook");
} catch (Exception e) {
    GradebookMonitoringAction.log.error("Failed to load lesson gradebook", e);
    return mapping.findForward("error");
}
   }
 
Example 16
Project: lams   File: AuthoringAction.java   View Source Code Vote up 4 votes
public ActionForward createPedagogicalPlannerItem(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
TaskListPedagogicalPlannerForm plannerForm = (TaskListPedagogicalPlannerForm) form;
plannerForm.setTaskListItem(plannerForm.getTaskListItemCount().intValue(), "");
return mapping.findForward("success");
   }
 
Example 17
Project: lams   File: MonitoringAction.java   View Source Code Vote up 4 votes
/**
    * Edit a special user's mark.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   private ActionForward editMark(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
MarkForm markForm = (MarkForm) form;
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(markForm.getSessionMapID());
String updateMode = (String) sessionMap.get(ForumConstants.PARAM_UPDATE_MODE);
// view forum mode
if (StringUtils.isBlank(updateMode)) {
    sessionMap.put(ForumConstants.PARAM_UPDATE_MODE, ForumConstants.MARK_UPDATE_FROM_FORUM);
    sessionMap.put(ForumConstants.ATTR_ROOT_TOPIC_UID, markForm.getTopicID());
}

// get Message and User from database
forumService = getForumService();
Message msg = forumService.getMessage(markForm.getTopicID());
ForumUser user = msg.getCreatedBy();

// echo back to web page
if (msg.getReport() != null) {
    if (msg.getReport().getMark() != null) {
	markForm.setMark(NumberUtil.formatLocalisedNumber(msg.getReport().getMark(), request.getLocale(), 2));
    } else {
	markForm.setMark("");
    }
    markForm.setComment(msg.getReport().getComment());
}

// each back to web page
request.setAttribute(ForumConstants.ATTR_TOPIC, MessageDTO.getMessageDTO(msg));
request.setAttribute(ForumConstants.ATTR_USER, user);

// Should we show the reflection or not? We shouldn't show it when the View Forum screen is accessed
// from the Monitoring Summary screen, but we should when accessed from the Learner Progress screen.
// Need to constantly past this value on, rather than hiding just the once, as the View Forum
// screen has a refresh button. Need to pass it through the view topic screen and dependent screens
// as it has a link from the view topic screen back to View Forum screen.
boolean hideReflection = WebUtil.readBooleanParam(request, ForumConstants.ATTR_HIDE_REFLECTION, false);
sessionMap.put(ForumConstants.ATTR_HIDE_REFLECTION, hideReflection);

return mapping.findForward("success");
   }
 
Example 18
Project: lams   File: AuthoringAction.java   View Source Code Vote up 4 votes
/**
    * This method will persist all inforamtion in this authoring page, include
    * all dokumaran item, information etc.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    * @throws ServletException
    */
   private ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {
DokumaranForm dokumaranForm = (DokumaranForm) form;

// get back sessionMAP
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(dokumaranForm.getSessionMapID());
ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request);
Dokumaran dokumaran = dokumaranForm.getDokumaran();
IDokumaranService service = getDokumaranService();

// **********************************Get Dokumaran PO*********************
Dokumaran dokumaranPO = service.getDokumaranByContentId(dokumaran.getContentId());
if (dokumaranPO == null) {
    // new Dokumaran, create it
    dokumaranPO = dokumaran;
    dokumaranPO.setCreated(new Timestamp(new Date().getTime()));
    dokumaranPO.setUpdated(new Timestamp(new Date().getTime()));
    
} else {
    Long uid = dokumaranPO.getUid();
    PropertyUtils.copyProperties(dokumaranPO, dokumaran);

    // copyProperties() above may result in "collection assigned to two objects in a session" exception
    // Below we remove reference to one of Assessment objects,
    // so maybe there will be just one object in session when save is done
    // If this fails, we may have to evict the object from session using DAO
    dokumaranForm.setDokumaran(null);
    dokumaran = null;
    // get back UID
    dokumaranPO.setUid(uid);

    // if it's a teacher - change define later status
    if (mode.isTeacher()) {
	dokumaranPO.setDefineLater(false);
    }
    dokumaranPO.setUpdated(new Timestamp(new Date().getTime()));
}

// *******************************Handle user*******************
// try to get form system session
HttpSession ss = SessionManager.getSession();
// get back login user DTO
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
DokumaranUser dokumaranUser = service.getUserByIDAndContent(new Long(user.getUserID().intValue()),
	dokumaranPO.getContentId());
if (dokumaranUser == null) {
    dokumaranUser = new DokumaranUser(user, dokumaranPO);
}

dokumaranPO.setCreatedBy(dokumaranUser);

// ***************************** finally persist dokumaranPO again
service.saveOrUpdateDokumaran(dokumaranPO);

dokumaranForm.setDokumaran(dokumaranPO);

request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE);
request.setAttribute(AttributeNames.ATTR_MODE, mode.toString());

return mapping.findForward(DokumaranConstants.SUCCESS);
   }
 
Example 19
Project: lams   File: DisplayOptionsActivityAction.java   View Source Code Vote up 4 votes
/**
    * Gets an options activity from the request (attribute) and forwards to the display JSP.
    */
   @SuppressWarnings("unchecked")
   @Override
   public ActionForward execute(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
    HttpServletResponse response) {
OptionsActivityForm form = (OptionsActivityForm) actionForm;
ActivityMapping actionMappings = LearningWebUtil.getActivityMapping(this.getServlet().getServletContext());

ICoreLearnerService learnerService = getLearnerService();
LearnerProgress learnerProgress = LearningWebUtil.getLearnerProgress(request, learnerService);
Activity activity = LearningWebUtil.getActivityFromRequest(request, learnerService);
if (!(activity instanceof OptionsActivity)) {
    LamsAction.log.error(LamsAction.className + ": activity not OptionsActivity " + activity.getActivityId());
    return mapping.findForward(ActivityMapping.ERROR);
}

OptionsActivity optionsActivity = (OptionsActivity) activity;

form.setActivityID(activity.getActivityId());

List<ActivityURL> activityURLs = new ArrayList<ActivityURL>();
Set<Activity> subActivities = optionsActivity.getActivities();
Iterator<Activity> i = subActivities.iterator();
int completedCount = 0;
while (i.hasNext()) {
    ActivityURL activityURL = LearningWebUtil.getActivityURL(actionMappings, learnerProgress, i.next(), false,
	    false);
    if (activityURL.isComplete()) {
	completedCount++;
    }
    activityURLs.add(activityURL);
}
form.setActivityURLs(activityURLs);

if (optionsActivity.getMinNumberOfOptionsNotNull().intValue() <= completedCount) {
    form.setFinished(true);
}

if (completedCount >= optionsActivity.getMaxNumberOfOptionsNotNull().intValue()) {
    form.setMaxActivitiesReached(true);
}

form.setMinimum(optionsActivity.getMinNumberOfOptionsNotNull().intValue());
form.setMaximum(optionsActivity.getMaxNumberOfOptionsNotNull().intValue());
form.setDescription(optionsActivity.getDescription());
form.setTitle(optionsActivity.getTitle());
form.setLessonID(learnerProgress.getLesson().getLessonId());
form.setProgressID(learnerProgress.getLearnerProgressId());

this.saveToken(request);

LearningWebUtil.putActivityPositionInRequest(form.getActivityID(), request, getServlet().getServletContext());

// lessonId needed for the progress bar
request.setAttribute(AttributeNames.PARAM_LESSON_ID, learnerProgress.getLesson().getLessonId());
		
String forward = "displayOptions";
return mapping.findForward(forward);
   }
 
Example 20
Project: unitimes   File: UnassignedExamsAction.java   View Source Code Vote up 4 votes
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	ExamReportForm myForm = (ExamReportForm) form;

       // Check Access
	sessionContext.checkPermission(Right.NotAssignedExaminations);
       
       String op = (myForm.getOp()!=null?myForm.getOp():request.getParameter("op"));

       if ("Export CSV".equals(op) || "Export PDF".equals(op) || "Apply".equals(op)) {
           myForm.save(sessionContext);
       } else if ("Refresh".equals(op)) {
           myForm.reset(mapping, request);
       }
       
       myForm.load(sessionContext);
       
       Session session = SessionDAO.getInstance().get(sessionContext.getUser().getCurrentAcademicSessionId());
       RoomAvailability.setAvailabilityWarning(request, session, myForm.getExamType(), true, false);
       
       ExamSolverProxy solver = WebSolver.getExamSolver(request.getSession());
       Collection<ExamInfo> unassignedExams = null;
       if (myForm.getSubjectArea()!=null && myForm.getSubjectArea()!=0  && myForm.getExamType() != null) {
           if (solver!=null && solver.getExamTypeId().equals(myForm.getExamType()))
               unassignedExams = solver.getUnassignedExams(myForm.getSubjectArea());
           else
               unassignedExams = Exam.findUnassignedExams(sessionContext.getUser().getCurrentAcademicSessionId(), myForm.getSubjectArea(),myForm.getExamType());
       }
       
       WebTable.setOrder(sessionContext,"unassignedExams.ord",request.getParameter("ord"),1);
       
       WebTable table = getTable(true, false, myForm, unassignedExams);
       
       if ("Export PDF".equals(op) && table!=null) {
       	ExportUtils.exportPDF(
       			getTable(false, true, myForm, unassignedExams),
       			WebTable.getOrder(sessionContext,"unassignedExams.ord"),
       			response, "unassigned");
       	return null;
       }

       if ("Export CSV".equals(op) && table!=null) {
       	ExportUtils.exportCSV(
       			getTable(false, false, myForm, unassignedExams),
       			WebTable.getOrder(sessionContext,"unassignedExams.ord"),
       			response, "unassigned");
       	return null;
       }

       
       if (table!=null)
           myForm.setTable(table.printTable(WebTable.getOrder(sessionContext,"unassignedExams.ord")), 9, unassignedExams.size());

       if (request.getParameter("backId")!=null)
           request.setAttribute("hash", request.getParameter("backId"));
       
       LookupTables.setupExamTypes(request, sessionContext.getUser(), DepartmentStatusType.Status.ExamTimetable);
       
       return mapping.findForward("showReport");
}