Java Code Examples for org.apache.struts.action.ActionRedirect#addParameter()

The following examples show how to use org.apache.struts.action.ActionRedirect#addParameter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComUserFormEditAction.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
private ActionRedirect createWorkflowForwardRedirect(HttpServletRequest req, ActionMapping mapping, int formId, int workflowId){
    ActionForward destination = mapping.findForward("workflow_view");
    String path = destination.getPath().replace("{WORKFLOW_ID}", Integer.toString(workflowId));
    ActionRedirect redirect = new ActionRedirect(path);
    
    redirect.addParameter("forwardParams", req.getSession().getAttribute(WorkflowParametersHelper.WORKFLOW_FORWARD_PARAMS).toString()
            + ";elementValue=" + Integer.toString(formId));
    return redirect;
}
 
Example 2
Source File: MessageListNavAction.java    From jivejdon with Apache License 2.0 5 votes vote down vote up
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	MessageListForm messageListForm = (MessageListForm) FormBeanUtil.lookupActionForm(request, "messageListForm"); // same
	// as struts-config-message.xml
	if (messageListForm == null) {
		logger.error(" MessageListNavAction error : messageListForm is null");
		return mapping.findForward("failure");
	}

	String messageId = request.getParameter("message");
	String forumIds = request.getParameter("forum");
	if ((messageId == null) || (!UtilValidate.isInteger(messageId)) || (forumIds == null)) {
		logger.error(" MessageListNavAction error : message  or forum is null");
		return mapping.findForward("failure");
	}
	ForumService forumService = (ForumService) WebAppUtil.getService("forumService", this
			.servlet.getServletContext());
	Forum forum = forumService.getForum(new Long(forumIds));
	if (forum == null) {
		logger.error(" MessageListNavAction error : not found forum =" + forumIds);
		return mapping.findForward("failure");
	}

	Long lastMessageId = forum.getForumState().getLatestPost().getMessageId();
	Long threadId = forum.getForumState().getLatestPost().getForumThread().getThreadId();
	if (lastMessageId.longValue() >= (new Long(messageId)).longValue()) {
		ActionRedirect redirect = new ActionRedirect(mapping.findForward("success"));
		redirect.addParameter("thread", threadId);
		redirect.addParameter("messageId", messageId);
		return redirect;
	} else {
		request.setAttribute("forumId", new Long(forumIds));
		request.setAttribute("messageId", new Long(messageId));
		return mapping.findForward("navf");
	}

}
 
Example 3
Source File: MessageListNav2Action.java    From jivejdon with Apache License 2.0 4 votes vote down vote up
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest
		request, HttpServletResponse response) throws Exception {
	MessageListForm messageListForm = (MessageListForm) FormBeanUtil.lookupActionForm(request,
			"messageListForm"); // same
	// as struts-config-message.xml
	if (messageListForm == null) {
		logger.error(" MessageListNavAction error : messageListForm is null");
		return mapping.findForward("failure");
	}

	String pMessageId = request.getParameter("pMessage");
	String messageId = request.getParameter("message");
	if ((pMessageId == null) || (!UtilValidate.isInteger(pMessageId)) || messageId == null) {
		logger.error(" MessageListNavAction error : pMessageId or messageId is null");
		return mapping.findForward("failure");
	}

	ForumMessageService forumMessageService = (ForumMessageService) WebAppUtil.getService
			("forumMessageService", this.servlet.getServletContext());

	ForumMessage forumMessageParent = forumMessageService.getMessage(Long.parseLong
			(pMessageId));
	if (forumMessageParent == null) {
		logger.error(" not locate pMessageId = " + pMessageId);
		return mapping.findForward("failure");
	}

	ForumThread thread = forumMessageParent.getForumThread();
	long threadId = thread.getThreadId();
	//AddReplyMessageZ will update state
	Long lastMessageId = thread.getState().getLatestPost().getMessageId();
	if (lastMessageId.longValue() >= (new Long(messageId)).longValue()) {
		int start = locateTheMessage(new Long(threadId), lastMessageId, new Long(messageId),
				messageListForm.getCount());
		ActionRedirect redirect = new ActionRedirect(mapping.findForward("success"));
		redirect.addParameter("thread", threadId);
		redirect.addParameter("start", start);
		redirect.addParameter("messageId", messageId);
		redirect.addParameter("nocache", "true");
		redirect.addParameter("ver", java.util.UUID.randomUUID().toString());
		redirect.setAnchor(messageId);
		return redirect;
	} else {//forward to /forum/navf2.jsp to waiting a minute until all ok
		request.setAttribute("pMessageId", new Long(pMessageId));
		request.setAttribute("messageId", new Long(messageId));
		return mapping.findForward("navf2");
	}
}