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


Java ActionMapping類代碼示例

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


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

示例1: exportExcel

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
    * Exports tool results into excel.
    * 
    * @throws IOException
    */
   private ActionForward exportExcel(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException {

initializeScratchieService();
String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
Scratchie scratchie = (Scratchie) sessionMap.get(ScratchieConstants.ATTR_SCRATCHIE);

LinkedHashMap<String, ExcelCell[][]> dataToExport = service.exportExcel(scratchie.getContentId());

String fileName = "scratchie_export.xlsx";
fileName = FileUtil.encodeFilenameForDownload(request, fileName);

response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);

// set cookie that will tell JS script that export has been finished
String downloadTokenValue = WebUtil.readStrParam(request, "downloadTokenValue");
Cookie fileDownloadTokenCookie = new Cookie("fileDownloadToken", downloadTokenValue);
fileDownloadTokenCookie.setPath("/");
response.addCookie(fileDownloadTokenCookie);

// Code to generate file and write file contents to response
ServletOutputStream out = response.getOutputStream();
ExcelUtil.createExcel(out, dataToExport, null, false);

return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:MonitoringAction.java

示例2: deleteLearnerFile

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
public ActionForward deleteLearnerFile(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
HttpSession ss = SessionManager.getSession();


UserDTO currentUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
Long detailID = WebUtil.readLongParam(request, "detailId");

if (submitFilesService == null) {
    submitFilesService = getSubmitFilesService();
}
FileDetailsDTO fileDetail = submitFilesService.getFileDetails(detailID, request.getLocale());

if (fileDetail.getOwner().getUserID().equals(currentUser.getUserID()) && (StringUtils.isBlank(fileDetail.getMarks()))) {

    submitFilesService.removeLearnerFile(detailID,null);

} else {
  response.sendError(HttpServletResponse.SC_FORBIDDEN, "You are not allowed to delete this item");
}
return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:LearnerAction.java

示例3: unspecified

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
@Override
   public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
// set up mdlForumService
if (dokumaranService == null) {
    dokumaranService = DokumaranServiceProxy.getDokumaranService(this.getServlet().getServletContext());
}

AdminForm adminForm = (AdminForm) form;

DokumaranConfigItem etherpadUrl = dokumaranService.getConfigItem(DokumaranConfigItem.KEY_ETHERPAD_URL);
if (etherpadUrl != null) {
    adminForm.setEtherpadUrl(etherpadUrl.getConfigValue());
}

DokumaranConfigItem apiKey = dokumaranService.getConfigItem(DokumaranConfigItem.KEY_API_KEY);
if (apiKey != null) {
    adminForm.setApiKey(apiKey.getConfigValue());
}

request.setAttribute("error", false);
return mapping.findForward("config");
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:AdminAction.java

示例4: addLessonDependency

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
    * Adds given lesson to dependecies and displays updated list in thickbox.
    *
    * @throws IOException
    *
    * @throws InvalidParameterException
    */
   public ActionForward addLessonDependency(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException {
Long lessonId = WebUtil.readLongParam(request, CentralConstants.PARAM_LESSON_ID, false);
if (!getSecurityService().isLessonOwner(lessonId, getUser().getUserID(), "add lesson dependency", false)) {
    response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not the owner of the lesson");
    return null;
}

Long addedPrecedingLessonId = WebUtil.readLongParam(request, LessonConditionsAction.PARAM_PRECEDING_LESSON_ID,
	false);
Lesson lesson = getLessonService().getLesson(lessonId);
Lesson addedPrecedingLesson = getLessonService().getLesson(addedPrecedingLessonId);
if (addedPrecedingLesson == null) {
    throw new IllegalArgumentException("Preceding lesson with ID: " + lessonId + " does not exist.");
}

lesson.getPrecedingLessons().add(addedPrecedingLesson);

// after operation, display contents again
return getIndexLessonConditions(mapping, form, request, response);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:LessonConditionsAction.java

示例5: execute

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
public ActionForward execute (
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
	throws IOException, ServletException {

	SchemEditForm sef = (SchemEditForm) form;
	ActionErrors errors = initializeFromContext (mapping, request);
	if (!errors.isEmpty()) {
		saveErrors (request, errors);
		return (mapping.findForward("error.page"));
	}
	
	String errorMsg;
	recordsDir = getRecordsDir();
	if (recordsDir == null) {
		errorMsg = "attribute \"recordsDir\" not found";
		prtln(errorMsg);
		throw new ServletException(errorMsg);
	}
	sef.setRecordsDir(recordsDir);
	
	return super.execute (mapping, form, request, response);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:26,代碼來源:StandAloneSchemEditAction.java

示例6: handleDeleteElement

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
* Wrap handleDeleteElement so we can update suggestion service helper in the case
* that the standards field has been deleted.
*/
protected ActionForward handleDeleteElement(ActionMapping mapping,
                                            ActionForm form,
                                            HttpServletRequest request,
                                            SchemEditValidator validator)
	 throws ServletException {
	prtln ("handleDeleteElement()");
	SchemEditForm sef = (SchemEditForm) form;
	ActionErrors errors = new ActionErrors();
	ActionForward forward = super.handleDeleteElement(mapping, form, request, validator);
	if (sef.getSuggestionServiceHelper() != null) {
		try {
			this.initSuggestionServiceHelper(sef);
		} catch (Exception e) {
			prtlnErr ("suggestionServiceHelper error: " + e.getMessage());
		}
	}
	return forward;
 }
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:23,代碼來源:DCSSchemEditAction.java

示例7: initPage

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
    * Display same entire authoring page content from HttpSession variable.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    * @throws ServletException
    */
   private ActionForward initPage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws ServletException {
String sessionMapID = WebUtil.readStrParam(request, PeerreviewConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
PeerreviewForm existForm = (PeerreviewForm) sessionMap.get(PeerreviewConstants.ATTR_PEERREVIEW_FORM);

PeerreviewForm peerreviewForm = (PeerreviewForm) form;
try {
    PropertyUtils.copyProperties(peerreviewForm, existForm);
} catch (Exception e) {
    throw new ServletException(e);
}

ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request);
request.setAttribute(AttributeNames.ATTR_MODE, mode.toString());

return mapping.findForward(PeerreviewConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:AuthoringAction.java

示例8: validate

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
 * Validate the properties that have been set from this HTTP request,
 * and return an <code>ActionErrors</code> object that encapsulates any
 * validation errors that have been found.  If no errors are found, return
 * <code>null</code> or an <code>ActionErrors</code> object with no
 * recorded error messages.
 *
 * @param mapping The mapping used to select this instance
 * @param request The servlet request we are processing
 * @return  <code>ActionErrors</code> object that encapsulates any  validation errors

 */
public ActionErrors validate(ActionMapping mapping,
                             HttpServletRequest request) {

    ServletContext application = getServlet().getServletContext();
    ActionErrors errors = new ActionErrors();

    String validationKey = getValidationKey(mapping, request);

    Validator validator = Resources.initValidator(validationKey,
                         this,
                         application, request,
                         errors, page);

    try {
        validatorResults = validator.validate();
    } catch (ValidatorException e) {
        log.error(e.getMessage(), e);
    }

    return errors;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:ValidatorForm.java

示例9: handleEditCommand

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
 *  NOT YET DOCUMENTED
 *
 * @param  mapping   NOT YET DOCUMENTED
 * @param  form      NOT YET DOCUMENTED
 * @param  request   NOT YET DOCUMENTED
 * @param  response  NOT YET DOCUMENTED
 * @return           NOT YET DOCUMENTED
 */
protected ActionForward handleEditCommand(
                                          ActionMapping mapping,
                                          ActionForm form,
                                          HttpServletRequest request,
                                          HttpServletResponse response)
										  throws Exception {

											  
	SuggestCommentForm scf = (SuggestCommentForm) form;
	
	if (scf.getItemID() == null || scf.getItemID().length() == 0 ) {			
		prtln("can't edit without a id ... bailing");
		return handleStaleData(mapping, form, request);
	}
	
	
	return mapping.findForward("form");
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:28,代碼來源:SuggestCommentAction.java

示例10: handleCancelCommand

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
 *  NOT YET DOCUMENTED
 *
 * @param  mapping   NOT YET DOCUMENTED
 * @param  form      NOT YET DOCUMENTED
 * @param  request   NOT YET DOCUMENTED
 * @param  response  NOT YET DOCUMENTED
 * @return           NOT YET DOCUMENTED
 */
protected ActionForward handleCancelCommand(
                                            ActionMapping mapping,
                                            ActionForm form,
                                            HttpServletRequest request,
                                            HttpServletResponse response) {

	SuggestCommentForm scf = (SuggestCommentForm) form;
	ActionErrors errors = new ActionErrors();

	scf.clear();
	scf.setItemID("");
	
	errors.add(ActionMessages.GLOBAL_MESSAGE,
		new ActionMessage("comment.cancel"));
	saveMessages(request, errors);
	return mapping.findForward("home");
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:27,代碼來源:SuggestCommentAction.java

示例11: doFinish

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
private ActionForward doFinish(ActionMapping mapping, HttpServletRequest request, Long sessionId) {
IPeerreviewService service = getPeerreviewService();
// get sessionId from HttpServletRequest
String nextActivityUrl = null;
try {
    HttpSession ss = SessionManager.getSession();
    UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
    Long userID = new Long(user.getUserID().longValue());

    nextActivityUrl = service.finishToolSession(sessionId, userID);
    request.setAttribute(PeerreviewConstants.ATTR_NEXT_ACTIVITY_URL, nextActivityUrl);
} catch (PeerreviewApplicationException e) {
    LearningAction.log.error("Failed get next activity url:" + e.getMessage());
}

return mapping.findForward("finish");
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:LearningAction.java

示例12: findForward

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
    * Get back relative <code>ActionForward</code> from request.
    *
    * @param type
    * @param mapping
    * @return
    */
   private ActionForward findForward(short type, ActionMapping mapping) {
ActionForward forward;
switch (type) {
    case CommonCartridgeConstants.RESOURCE_TYPE_BASIC_LTI:
	forward = mapping.findForward("basiclti");
	break;
    case CommonCartridgeConstants.RESOURCE_TYPE_COMMON_CARTRIDGE:
	forward = mapping.findForward("commoncartridge");
	break;
    default:
	forward = null;
	break;
}
return forward;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:AuthoringAction.java

示例13: unspecified

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
@Override
   public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
// set up mdlForumService
if (pixlrService == null) {
    pixlrService = PixlrServiceProxy.getPixlrService(this.getServlet().getServletContext());
}

AdminForm adminForm = (AdminForm) form;

PixlrConfigItem pixlrKey = pixlrService.getConfigItem(PixlrConfigItem.KEY_LANGUAGE_CSV);
if (pixlrKey != null) {
    adminForm.setLanguagesCSV(pixlrKey.getConfigValue());
}

request.setAttribute("error", false);
return mapping.findForward("config");
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:AdminAction.java

示例14: execute

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
 * Original Struts Action's method.
 * Retrieve current Tile context and call TilesAction execute method.
 * Do not overload this method!
 *
 * @param mapping The ActionMapping used to select this instance.
 * @param form The optional ActionForm bean for this request (if any).
 * @param request The HTTP request we are processing.
 * @param response The HTTP response we are creating.
 *
 * @exception Exception if the application business logic throws
 *  an exception
 * @since Struts 1.1
 */
public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
        
    // Try to retrieve tile context
    ComponentContext context = ComponentContext.getContext(request);
    if (context == null) {
        throw new ServletException(
            "Can't find Tile context for '"
                + this.getClass().getName()
                + "'. TilesAction subclasses must be called from a Tile");
    }
    
    return this.execute(context, mapping, form, request, response);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:TilesAction.java

示例15: autoSaveAnswers

import org.apache.struts.action.ActionMapping; //導入依賴的package包/類
/**
    * auto saves responses
    * @throws NoSuchMethodException 
    * @throws InvocationTargetException 
    * @throws IllegalAccessException 
    */
   private ActionForward autoSaveAnswers(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
IAssessmentService service = getAssessmentService();
String sessionMapID = WebUtil.readStrParam(request, AssessmentConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
int pageNumber = (Integer) sessionMap.get(AssessmentConstants.ATTR_PAGE_NUMBER);

//get user answers from request and store them into sessionMap
storeUserAnswersIntoSessionMap(request, pageNumber);
//store results from sessionMap into DB
storeUserAnswersIntoDatabase(sessionMap, true);

return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:LearningAction.java


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