Package javax.portlet

Examples of javax.portlet.ActionResponse


     * @param event an ActionFormEvent
     */
    public void validatePIN(ActionFormEvent event) {
        log.debug("Entering validatePIN");
        ActionRequest request = event.getActionRequest();
        ActionResponse response = event.getActionResponse();
        PortletSession session = request.getPortletSession(false);
        if (session == null) {
            log.error("Invalid session.");
            setNextState(request, STEP2_JSP);
            return ;
        }

        String pinNumber = request.getParameter("pinNumber");
        String pinNumberVerify = request.getParameter("pinNumberVerify");
        String username = (String)session.getAttribute("username");

        String error_message = null;
        error_message = validatePINNumber(pinNumber, pinNumberVerify);
        if (error_message != null) {
            log.error(error_message);
            response.setRenderParameter("error_message", error_message);
            setNextState(request, STEP2_JSP);
            return ;
        }

        error_message = setStatusReset(username, pinNumber);
        if (error_message != null) {
            response.setRenderParameter("error_message", error_message);
        }

        log.debug("Exit validatePIN");
        setNextState(request, STEP3_JSP);
    }
View Full Code Here


     * @param event an <code>ActionFormEvent</code>
     */
    public void activateAccount(ActionFormEvent event) {
        log.debug("Entering activateAccount");
        PortletRequest req = event.getActionRequest();
        ActionResponse res = event.getActionResponse();
        PortletSession sess = req.getPortletSession();

        Boolean pinValidated = (Boolean) sess.getAttribute(PIN_VALIDATED);
        TextBean errorMessage = event.getTextBean("errorMessage");
        errorMessage.setStyle("error");

        if ( ! isPINValidated(pinValidated) ) {
            sess.setAttribute(PIN_VALIDATED, Boolean.FALSE);
            errorMessage.setValue("Error. You must enter PIN number.");
            setNextState(req, PIN_PROMPT_JSP);
            return ;
        }

        AccountRequest accountRequest =
            (AccountRequest)sess.getAttribute(PROCESSING_REQUEST);
        if (accountRequest == null) {
            errorMessage.setValue("There was an error processing your request. Please click the link in the email you received again to start the process over, or contact the portal administrator if you continue to see this message.");
            sess.removeAttribute(PROCESSING_REQUEST);
            sess.setAttribute(PIN_VALIDATED, Boolean.FALSE);
            setNextState(req, ERROR_JSP);
            return ;
        }

        String password1 = req.getParameter("password1");
        String password2 = req.getParameter("password2");
        try {
            checkPassword(password1, password2, accountRequest);
        } catch (Exception e) {
            log.info(e.getMessage());
            errorMessage.setValue(e.getMessage());
            setNextState(req, PASSWORD_PROMPT_JSP);
            return ;
        }

        // activation proc
        Map params = new HashMap();
        params.put("password", password1);
        AccountRequestResult result =
            accountService.updateAccount(accountRequest,
                                         AccountRequest.Status.ACTIVATED,
                                         params);
        if (result.isError()) {
            errorMessage.setValue( result.getMessage() );
            setNextState(req, ERROR_JSP);
            return ;
        }

        errorMessage.setValue(null);
        sess.removeAttribute(PROCESSING_REQUEST);
        sess.removeAttribute(PIN_VALIDATED);

        res.setRenderParameter("username", accountRequest.getUsername());

        setNextState(req, ACTIVATION_COMPLETE_JSP);
        log.debug("Exit activateAccount");
    }
View Full Code Here


    public void changePassword(ActionFormEvent event) throws PortletException {
        log.debug("Entering changePassword");
        ActionRequest req = event.getActionRequest();
        ActionResponse res = event.getActionResponse();

        String username = req.getParameter("username");
        String currentPassword = req.getParameter("password0");
        String newPassword     = req.getParameter("password1");
        String newPasswordVerify = req.getParameter("password2");

        if ( isBlank(username) ) {
            res.setRenderParameter("errorMessage",
                "Username must not be blank");
            return ;
        }
        if ( isBlank(currentPassword) ) {
            res.setRenderParameter("errorMessage",
                "Current Password must not be blank");
            return ;
        }
        if (isBlank(newPassword) || isBlank(newPasswordVerify)) {
            res.setRenderParameter("errorMessage",
                "Password must not be blank.");
            return ;
        }
        if (! newPassword.equals(newPasswordVerify) ) {
            res.setRenderParameter("errorMessage",
                "Passwords do not match. Check the new password.");
            return ;
        }
        String message = null;
        if ((message = validator.validatePassword(newPassword)) != null) {
            res.setRenderParameter("errorMessage", message);
            return ;
        }

        AccountRequest accountRequest =
            accountService.getAccountRequestByUsername(username);
        if (accountRequest == null) {
            res.setRenderParameter("errorMessage",
                "No account found for " + username);
            return ;
        }
        if ((message = validator.passwordCheckByAccountInfo(
            accountRequest.getAttributes(), newPassword)) != null ) {
            res.setRenderParameter("errorMessage", message);
            return ;
        }

        String nextState = CHANGE_PASSWORD_JSP;
        try {
            accountService.changePassword(accountRequest, currentPassword,
                                          newPassword);
            nextState = CHANGE_PASSWORD_COMPLETE_JSP;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            res.setRenderParameter("errorMessage",
                "Couldn't change the password.");
        }

        setNextState(req, nextState);
        log.debug("Exit changePassword");
View Full Code Here

      url = actionURL.toString();
      url = url.replaceAll("\\&amp\\;", "&");
    }
    else
    { // action - write the viewId to navigational state
      ActionResponse actionResponse = (ActionResponse) getResponse();

      // set request params into navigational states
      Enumeration<String> list = queryStr.getParameterNames();
      while (list.hasMoreElements())
      {
        String param = list.nextElement();
        if (param.equals(Bridge.PORTLET_MODE_PARAMETER))
        {
          try
          {
            actionResponse.setPortletMode(new PortletMode(queryStr.getParameter(param)));
          }
          catch (Exception e)
          {
            //TODO: Ignoring is probably dangerous here as it means that we are
            //      EITHER using exceptions for flow control (which is extreemly
            //      inefficient) or we should log a message saying what the issue
            //      is.  According to the Javadocs an exception is thrown here if the
            //      portlet mode is not allowed or if sendRedirect has already been
            //      called.  In either case we should log an information type message
            //      here.
            ; // do nothing -- just ignore
          }
        }
        else if (param.equals(Bridge.PORTLET_WINDOWSTATE_PARAMETER))
        {
          try
          {
            actionResponse.setWindowState(new WindowState(queryStr.getParameter(param)));
          }
          catch (Exception e)
          {
            ; // do nothing -- just ignore
          }
        }
        else if (param.equals(Bridge.PORTLET_SECURE_PARAMETER))
        {
          ; // ignore -- do nothing as can't encode into an actionResponse
        }
        else
        {
          actionResponse.setRenderParameter(param, queryStr.getParameter(param));
        }
      }
    }
    // Because we want to support translating a redirect that occurs
    // during a render as an in place navigation AND we can't reverse
View Full Code Here

      return actionURLStr;
    }
    else
    { // action - write the viewId to navigational state
      ActionResponse actionResponse = (ActionResponse) getResponse();

      actionResponse.setRenderParameter(ACTION_ID_PARAMETER_NAME, viewId);

      // set other request params (if any) into navigational states
      if (queryStr != null)
      {
        Enumeration<String> list = queryStr.getParameterNames();
        while (list.hasMoreElements())
        {
          String param = list.nextElement();
          if (param.equals(Bridge.PORTLET_MODE_PARAMETER))
          {
            try
            {
              actionResponse.setPortletMode(new PortletMode(queryStr.getParameter(param)));
            }
            catch (Exception e)
            {
              //TODO: Ignoring is probably dangerous here as it means that we are
              //      EITHER using exceptions for flow control (which is extreemly
              //      inefficient) or we should log a message saying what the issue
              //      is.  According to the Javadocs an exception is thrown here if the
              //      portlet mode is not allowed or if sendRedirect has already been
              //      called.  In either case we should log an information type message
              //      here.
              ; // do nothing -- just ignore
            }
          }
          else if (param.equals(Bridge.PORTLET_WINDOWSTATE_PARAMETER))
          {
            try
            {
              actionResponse.setWindowState(new WindowState(queryStr.getParameter(param)));
            }
            catch (Exception e)
            {
              ; // do nothing -- just ignore
            }
          }
          else if (param.equals(Bridge.PORTLET_SECURE_PARAMETER))
          {
            ; // ignore -- do nothing as can't encode into an actionResponse
          }
          else
          {
            actionResponse.setRenderParameter(param, queryStr.getParameter(param));
          }
        }
      }

      return url;
View Full Code Here

    methodInvoker.updateModelAttributes(
        handler, (mav != null ? mav.getModel() : null), implicitModel, webRequest);

    // Expose implicit model for subsequent render phase.
    if (response instanceof ActionResponse && !implicitModel.isEmpty()) {
      ActionResponse actionResponse = (ActionResponse) response;
      try {
        actionResponse.setRenderParameter(IMPLICIT_MODEL_ATTRIBUTE, Boolean.TRUE.toString());
        request.getPortletSession().setAttribute(IMPLICIT_MODEL_ATTRIBUTE, implicitModel);
      }
      catch (IllegalStateException ex) {
        // Probably sendRedirect called... no need to expose model to render phase.
      }
View Full Code Here

  }
 
  public void testActionRequestNotHandled() throws Exception {
    ParameterizableViewController controller = new ParameterizableViewController();
    ActionRequest request = new MockActionRequest();
    ActionResponse response = new MockActionResponse();
    try {
      controller.handleActionRequest(request, response);
      fail("should have thrown PortletException");
    }
    catch (PortletException ex) {
View Full Code Here

    public void testActionPortletRequest() throws NoSuchFieldException,
            IllegalAccessException    {
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        PortletContext portletContext = createMock(PortletContext.class);
        ActionRequest request = createMock(ActionRequest.class);
        ActionResponse response = createMock(ActionResponse.class);

        replay(applicationContext, portletContext, request, response);
        ActionPortletRequest req = new ActionPortletRequest(applicationContext,
                portletContext, request, response);
        Class<? extends ActionPortletRequest> clazz = req.getClass();
View Full Code Here

            }

            if (method == ContainerConstants.METHOD_ACTION)
            {
                ActionRequest actionRequest = (ActionRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
                ActionResponse actionResponse = (ActionResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);
                // inject the current request into the actionRequest handler (o.a.j.engine.servlet.ServletRequestImpl)
                ((HttpServletRequestWrapper)((HttpServletRequestWrapper)actionRequest).getRequest()).setRequest(request);

                portlet.processAction(actionRequest, actionResponse);
            }
View Full Code Here

        url = xhtmlEncode(url);
      }
    }
    else
    { // action - write the viewId to navigational state
      ActionResponse actionResponse = (ActionResponse) getResponse();

      // set request params into navigational states
      Enumeration<String> list = queryStr.getParameterNames();
      while (list.hasMoreElements())
      {
        String param = list.nextElement();
        if (param.equals(Bridge.PORTLET_MODE_PARAMETER))
        {
          try
          {
            actionResponse.setPortletMode(new PortletMode(queryStr.getParameter(param)));
          }
          catch (Exception e)
          {
            //TODO: Ignoring is probably dangerous here as it means that we are
            //      EITHER using exceptions for flow control (which is extreemly
            //      inefficient) or we should log a message saying what the issue
            //      is.  According to the Javadocs an exception is thrown here if the
            //      portlet mode is not allowed or if sendRedirect has already been
            //      called.  In either case we should log an information type message
            //      here.
            ; // do nothing -- just ignore
          }
        }
        else if (param.equals(Bridge.PORTLET_WINDOWSTATE_PARAMETER))
        {
          try
          {
            actionResponse.setWindowState(new WindowState(queryStr.getParameter(param)));
          }
          catch (Exception e)
          {
            ; // do nothing -- just ignore
          }
        }
        else if (param.equals(Bridge.PORTLET_SECURE_PARAMETER))
        {
          ; // ignore -- do nothing as can't encode into an actionResponse
        }
        else
        {
          actionResponse.setRenderParameter(param, queryStr.getParameter(param));
        }
      }
    }
    // Because we want to support translating a redirect that occurs
    // during a render as an in place navigation AND we can't reverse
View Full Code Here

TOP

Related Classes of javax.portlet.ActionResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.