Java Code Examples for javax.portlet.ActionResponse#setRenderParameter()

The following examples show how to use javax.portlet.ActionResponse#setRenderParameter() . 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: RequestParameters.java    From journaldev with MIT License 6 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
	// Fetch username and password from the request parameters of action
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	
	// Do some checking procedure
	if(username != null && username.equals("journaldev") &&
			password != null && password.equals("journaldev")){
		// Use render parameters to pass the result
		response.setRenderParameter("loggedIn", "true");
	}
	else {
		// Use render parameters to pass the result
		response.setRenderParameter("loggedIn", "false");
	}
}
 
Example 2
Source File: URLTests_ActionURL.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@ActionMethod(portletName = "ActionURLTests")
public void processAction(ActionRequest portletReq,
      ActionResponse portletResp) throws PortletException, IOException {

   // evaluate results for test case
   // V3URLTests_ActionURL_setParameterB7
   {
      ModuleTestCaseDetails tcd = new ModuleTestCaseDetails();
      TestResult tr8 = tcd.getTestResultFailed(
          V3URLTESTS_ACTIONURL_SETPARAMETERB7);
      String tcval = portletReq.getParameter("tc");
      // let exception be thrown if tc parm isn't defined (test case error)
      if (tcval != null && tcval != null && tcval
          .equals("V3URLTests_ActionURL_setParameterB7")) {
         String[] aval = portletReq.getParameterValues("parm1");
         String[] eval = null;
         CompareUtils.arraysEqual("Request", aval, " expected: ", eval, tr8);
         PortletSession ps = portletReq.getPortletSession();
         ps.setAttribute(
             RESULT_ATTR_PREFIX
             + "V3URLTests_ActionURL_setParameterB7",
             tr8);
         portletResp.setRenderParameter("tc", tcval);
      }
   }
}
 
Example 3
Source File: MessageBoxPortlet.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void processAction(ActionRequest req, ActionResponse resp)
      throws PortletException, IOException {

   // the only action for this portlet is to reset the stored messages
   
   String actionName = req.getParameter("action");
   logger.debug("MBP: Resetting messages. numMsgs = 0,  actionName = " + actionName);

   ArrayList<String> msgs = new ArrayList<String>();
   StringBuffer sb = new StringBuffer();
   sb.append("<p style='margin:2px 5px 2px 5px; color:#00D;"
         + " background-color:#AAF;'>");
   sb.append("Reset - No messages.");
   sb.append("</p>");
   msgs.add(sb.toString());

   resp.setRenderParameter(PARAM_NUM_MSGS, "0");
   req.getPortletSession().setAttribute(ATTRIB_MSGS, msgs);
}
 
Example 4
Source File: PortletTagLibraryTests2_SPEC2_26_IncludeJSPRender.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@ProcessAction(name = "actionNameTr27")
public void actionUrlViaName(ActionRequest portletReq, ActionResponse portletResp)
    throws PortletException, IOException {
  portletResp.setRenderParameter("tr37", "true");
  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);
}
 
Example 5
Source File: PortletWrappingControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void processAction(ActionRequest request, ActionResponse response) throws PortletException {
	if (request.getParameter("test") != null) {
		response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, "myPortlet-action");
	} else if (request.getParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME) != null) {
		response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, getPortletConfig().getPortletName());
	} else {
		throw new IllegalArgumentException("no request parameters");
	}
}
 
Example 6
Source File: PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@ProcessAction(name = "actionNameTr27")
public void actionUrlViaName(ActionRequest portletReq, ActionResponse portletResp)
    throws PortletException, IOException {
  portletResp.setRenderParameter("tr37", "true");
  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);
}
 
Example 7
Source File: Portlet20AnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@RequestMapping("VIEW")
@ActionMapping
public void myHandle(Model model, ActionResponse response, SessionStatus status) {
	TestBean tb = new TestBean();
	tb.setJedi(true);
	model.addAttribute("testBean", tb);
	status.setComplete();
	response.setRenderParameter("test", "value");
}
 
Example 8
Source File: AddlRequestTests_SPEC2_11_Render.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
  public void processAction(ActionRequest portletReq, ActionResponse portletResp)
      throws PortletException, IOException {

    String action = portletReq.getParameter("inputval");
    if (V2ADDLREQUESTTESTS_SPEC2_11_RENDER_PARAMETERS10.equals(action)
        && portletReq.getParameter("actionURLTr0") != null
        && portletReq.getParameter("actionURLTr0").equals("true")) {
      /* TestCase: V2AddlRequestTests_SPEC2_11_Render_parameters10 */
      /* Details: "The portlet-container must not propagate parameters */
      /* received in an action or event request to subsequent render */
      /* requests of the portlet" */
      portletResp.setRenderParameter("tr0", "true");
    } else if (V2ADDLREQUESTTESTS_SPEC2_11_RENDER_PARAMETERS15.equals(action)
        && portletReq.getParameter("tr3a") != null
        && portletReq.getParameter("tr3a").equals("true")) {
       /* TestCase: V2AddlRequestTests_SPEC2_11_Render_parameters15 */
       /* Details: "Render parameters get automatically cleared if the */
       /* portlet receives a processAction or processEvent call" */
      portletResp.setRenderParameter("tr3b", "true");
    } else {
      portletResp.setRenderParameters(portletReq.getParameterMap());
    }

    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);

  }
 
Example 9
Source File: AddlEnvironmentTests_SPEC2_10_ContextOptions_event.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void processAction(ActionRequest portletReq, ActionResponse portletResp) throws PortletException, IOException {

   String tc = portletReq.getParameter(Constants.BUTTON_PARAM_NAME);
   portletResp.setRenderParameter(Constants.BUTTON_PARAM_NAME, tc);
   if (tc != null) {
      if (tc.equals(V2ADDLENVIRONMENTTESTS_SPEC2_10_CONTEXTOPTIONS_ACTIONSCOPEDREQUESTATTRIBUTES9)) {
         QName qn = new QName(Constants.TCKNAMESPACE, "AddlEnvironmentTests_SPEC2_10_ContextOptions");
         portletResp.setEvent(qn, V2ADDLENVIRONMENTTESTS_SPEC2_10_CONTEXTOPTIONS_ACTIONSCOPEDREQUESTATTRIBUTES9);
      }
   }
}
 
Example 10
Source File: PetSitesEditController.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@RequestMapping(params = "action=add")  // action phase
public void populateSite(
		@ModelAttribute("site") PetSite petSite, BindingResult result, SessionStatus status, ActionResponse response) {

	new PetSiteValidator().validate(petSite, result);
	if (!result.hasErrors()) {
		this.petSites.put(petSite.getName(), petSite.getUrl());
		status.setComplete();
		response.setRenderParameter("action", "list");
	}
}
 
Example 11
Source File: HeaderPortletTests_SPEC15_Header.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void processAction(ActionRequest actionRequest,
      ActionResponse actionResponse) throws PortletException, IOException {
   String action = actionRequest.getParameter("inputval");
   if (action != null) {
      if (V3HEADERPORTLETTESTS_SPEC15_HEADER_PARAMETERS10.equals(action)
            && actionRequest.getParameter("actionURLTr0") != null
            && actionRequest.getParameter("actionURLTr0").equals("true")) {
         /* TestCase: V2AddlRequestTests_SPEC2_11_Render_parameters10 */
         /* Details: "The portlet-container must not propagate parameters */
         /* received in an action or event request to subsequent render */
         /* requests of the portlet" */
         actionResponse.setRenderParameter("tr0", "true");
      } else if (V3HEADERPORTLETTESTS_SPEC15_HEADER_PARAMETERS15
            .equals(action) && actionRequest.getParameter("tr3a") != null
            && actionRequest.getParameter("tr3a").equals("true")) {
         /* TestCase: V3HeaderPortletTests_SPEC15_Header_parameters15 */
         /*
          * Details: "Render parameters get automatically cleared if the
          * portlet receives a processAction or processEvent call"
          */
         actionResponse.setRenderParameter("tr3b", "true");
      } else if (V3HEADERPORTLETTESTS_SPEC15_HEADER_COOKIE9.equals(action)) {
         /* TestCase: V3HeaderPortletTests_SPEC15_Header_cookie9 */
         /*
          * Details: "Cookies set during the Header phase should be available
          * to the portlet during a subsequent Action phase"
          */
         Cookie[] cookies = actionRequest.getCookies();
         for (Cookie c : cookies) {
            if (c.getName().equals("header_tr1_cookie")
                  && c.getValue().equals("true")) {
               c.setMaxAge(0);
               c.setValue("");
               actionResponse.setRenderParameter("trCookie1", "true");
            }
         }
      }
   }
}
 
Example 12
Source File: PortletUtils.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Pass all the action request parameters to the render phase by putting them into
 * the action response object. This may not be called when the action will call
 * {@link javax.portlet.ActionResponse#sendRedirect sendRedirect}.
 * @param request the current action request
 * @param response the current action response
 * @see javax.portlet.ActionResponse#setRenderParameter
 */
public static void passAllParametersToRenderPhase(ActionRequest request, ActionResponse response) {
	try {
		Enumeration<String> en = request.getParameterNames();
		while (en.hasMoreElements()) {
			String param = en.nextElement();
			String values[] = request.getParameterValues(param);
			response.setRenderParameter(param, values);
		}
	}
	catch (IllegalStateException ex) {
		// Ignore in case sendRedirect was already set.
	}
}
 
Example 13
Source File: ParameterMappingInterceptor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * If request is an {@link javax.portlet.ActionRequest ActionRequest},
 * get handler mapping parameter and add it to the ActionResponse.
 */
@Override
public boolean preHandleAction(ActionRequest request, ActionResponse response, Object handler) {
	String mappingParameter = request.getParameter(this.parameterName);
	if (mappingParameter != null) {
		response.setRenderParameter(parameterName, mappingParameter);
	}
	return true;
}
 
Example 14
Source File: ComplexPortletApplicationContext.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void handleActionRequest(ActionRequest request, ActionResponse response) {
	response.setRenderParameter("param", "help2 was here");
}
 
Example 15
Source File: Portlet20AnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@ActionMapping
public void myHandle(ActionRequest request, ActionResponse response) {
	response.setRenderParameter("test", "value");
}
 
Example 16
Source File: Portlet20AnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@ActionMapping(params = "action=details")
public void renderDetails(ActionRequest request, ActionResponse response, Model model) {
	response.setRenderParameter("test", "details");
}
 
Example 17
Source File: PortletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@RequestMapping("VIEW")
public void myHandle(ActionRequest request, ActionResponse response) throws IOException {
	response.setRenderParameter("test", "value");
}
 
Example 18
Source File: ComplexPortletApplicationContext.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void handleActionRequest(ActionRequest request, ActionResponse response) {
	response.setRenderParameter("result", "test1-action");
}
 
Example 19
Source File: PortletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@RequestMapping
public void myHandle(ActionRequest request, ActionResponse response) {
	response.setRenderParameter("test", "value");
}
 
Example 20
Source File: FilterTests_ActionFilter_ApiActionFilter_filter.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@Override
public void doFilter(ActionRequest portletReq, ActionResponse portletResp, FilterChain chain)
    throws IOException, PortletException {

  StringWriter writer = new StringWriter();

  // now do the tests and write output

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  // Create result objects for the tests

  /* TestCase: V2FilterTests_ActionFilter_ApiActionFilter_canBeConfigured1 */
  /* Details: "An ActionFilter can be configured in the portlet */
  /* descriptor" */
  TestResult tr0 =
      tcd.getTestResultFailed(V2FILTERTESTS_ACTIONFILTER_APIACTIONFILTER_CANBECONFIGURED1);
  String action1 = filterConfig.getFilterName();
  if (action1.equals("FilterTests_ActionFilter_ApiActionFilter_filter")) {
    tr0.setTcSuccess(true);
  }
  tr0.writeTo(writer);

  /* TestCase: V2FilterTests_ActionFilter_ApiActionFilter_doFilterProcessAction2 */
  /* Details: "After the doFilter(ActionRequest, ActionResponse, */
  /* FilterChain): method has sucessfully completed and invokes the */
  /* next filter, the next filter in the chain is called if multiple */
  /* filters are defined" */
  tr4_success = true;

  portletReq.getPortletSession().setAttribute(
      RESULT_ATTR_PREFIX + "FilterTests_ActionFilter_ApiActionFilter",
      writer.toString(), APPLICATION_SCOPE);

  chain.doFilter(portletReq, portletResp);

  /* TestCase: V2FilterTests_ActionFilter_ApiActionFilter_doFilterExamine */
  /* Details: "Method doFilter(ActionRequest, ActionResponse, */
  /* FilterChain): After the next filter has been successfully invoked, */
  /* the ActionResponse may be examined" */
  portletResp.setRenderParameter("tr8", "true");
}