Java Code Examples for javax.portlet.ActionRequest#getParameter()

The following examples show how to use javax.portlet.ActionRequest#getParameter() . 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: PageAdminPortlet.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
public void doAddPortlet(ActionRequest request) {
    String page = request.getParameter("page");
    String applicationName = request.getParameter("applications");
    String portletName = request.getParameter("availablePortlets");

    LOG.info("Request: Add [applicationName=" + applicationName + ":portletName=" + portletName + "] to page '" + page + "'");

    String contextPath = applicationName;
    if (contextPath.length() > 0 && !contextPath.startsWith("/"))
    {
        contextPath = "/" + contextPath;
    }
    PageConfig config = getPageConfig(page);
    config.addPortlet(contextPath, portletName);

}
 
Example 3
Source File: PageAdminPortlet.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
/**
  * Adds a page to the portal via the <code>RenderConfigService</code>.
  * 
  *  This does not add portlets to the new page. Do that when the page is created
  *  using the Add Portlet button.
  *   
  * @param request The action request.
  */
 public void doAddPage(ActionRequest request) {
     String page = request.getParameter("newPage");//newPage text input element
     //Check if page is null or empty
     if (page == null || page.equals("")) {
LOG.warn("Page parameter is null or empty. Page addition will be ignored.");
//TODO: send message back to UI
     	return;
     }
     //TODO: add page URI input to form
     String uri = request.getParameter("pageURI");
     if (uri == null) {
     	uri = PortalDriverServlet.DEFAULT_PAGE_URI;
     }
     DriverConfiguration driverConfig = (DriverConfiguration) getPortletContext()
 		.getAttribute(AttributeKeys.DRIVER_CONFIG);
     PageConfig pageConfig = new PageConfig();
     pageConfig.setName(page);
     pageConfig.setUri(uri);

     RenderConfigService renderConfig = driverConfig.getRenderConfigService();
     renderConfig.addPage(pageConfig);
 }
 
Example 4
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 5
Source File: FilterTests_EventFilter_ApiEventFilter.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void processAction(ActionRequest portletReq, ActionResponse portletResp)
    throws PortletException, IOException {

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

  String action = portletReq.getParameter("inputval");
  if (action.equals("V2FilterTests_EventFilter_ApiEventFilter_doFilterBlock")) {
    QName eventQName_tr5 = new QName(TCKNAMESPACE, "FilterTests_EventFilter_ApiEventFilter_tr5");
    portletResp.setEvent(eventQName_tr5, "Hi!");
  }
  QName eventQName = new QName(TCKNAMESPACE, "FilterTests_EventFilter_ApiEventFilter");
  portletResp.setEvent(eventQName, "Hi!");
}
 
Example 6
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 7
Source File: PartialActionPortlet.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 increment the execition counter

   String val = req.getParameter(PARAM_NUM_ACTIONS);
   int na = 1;
   if (val != null) {
      try {
         na = Integer.parseInt(val) + 1;
      } catch (Exception e) {}
   }
   
   String actionName = req.getParameter("action");
   logger.debug("PAP: executing partial action. action number = " + na + ", name =  " + actionName);

   resp.setRenderParameter(PARAM_NUM_ACTIONS, Integer.toString(na));
}
 
Example 8
Source File: ActionParameterTest.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
protected TestResult checkGetActionParameter(ActionRequest request) {
    TestResult result = new TestResult();
    result.setDescription("Ensure parameters encoded in action URL are "
    		+ "available in the action request.");

    String value = request.getParameter(KEY);
    if (value != null && value.equals(VALUE)) {
    	result.setReturnCode(TestResult.PASSED);
    } else {
    	TestUtils.failOnAssertion("parameter", value, VALUE, result);
    }
    return result;
}
 
Example 9
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	log.debug("==== processAction called ====");

	PortletSession pSession = request.getPortletSession(true);

	// Our first challenge is to figure out which action we want to take
	// The view selects the "next action" either as a URL parameter
	// or as a hidden field in the POST data - we check both

	String doCancel = request.getParameter("sakai.cancel");
	String doUpdate = request.getParameter("sakai.update");

	// Our next challenge is to pick which action the previous view
	// has told us to do.  Note that the view may place several actions
	// on the screen and the user may have an option to pick between
	// them.  Make sure we handle the "no action" fall-through.

	pSession.removeAttribute("error.message");

	if ( doCancel != null ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( doUpdate != null ) {
		processActionEdit(request, response);
	} else {
		log.debug("Unknown action");
		response.setPortletMode(PortletMode.VIEW);
	}

	log.debug("==== End of ProcessAction  ====");
}
 
Example 10
Source File: AnnotationTests_ProcessAction_ApiAction.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void processAction(ActionRequest portletReq, ActionResponse portletResp)
    throws PortletException, IOException {

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

  StringWriter writer = new StringWriter();

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  /* TestCase: V2AnnotationTests_ProcessAction_ApiAction_name */
  /* Details: "Method name(): On an action request, the method is */
  /* executed if the parameter \"javax.portlet.action\" matches the */
  /* name field" */
  TestResult tr0 = tcd.getTestResultFailed(V2ANNOTATIONTESTS_PROCESSACTION_APIACTION_NAME);
  String nme = portletReq.getParameter(ActionRequest.ACTION_NAME);
  if (nme.equals(V2ANNOTATIONTESTS_PROCESSACTION_APIACTION_NAME)) {
    tr0.setTcSuccess(true);
  } else {
    tr0.setTcSuccess(false);
  }
  tr0.writeTo(writer);

  portletReq.getPortletSession().setAttribute(
      Constants.RESULT_ATTR_PREFIX + "AnnotationTests_ProcessAction_ApiAction", writer.toString(),
      APPLICATION_SCOPE);
}
 
Example 11
Source File: PortletTests_GenericPortlet_ApiRender.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@ProcessAction(name = V2PORTLETTESTS_GENERICPORTLET_APIRENDER_PROCESSACTION2)
public void newAction(ActionRequest portletReq, ActionResponse portletResp)
      throws PortletException, IOException {

   String nme = portletReq.getParameter(ActionRequest.ACTION_NAME);
   if (nme.equals(V2PORTLETTESTS_GENERICPORTLET_APIRENDER_PROCESSACTION2)) {
      portletResp.setRenderParameter(
            V2PORTLETTESTS_GENERICPORTLET_APIRENDER_PROCESSACTION2, "true");
   }
}
 
Example 12
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 13
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	log.debug("==== processAction called ====");

	String action = request.getParameter("sakai.action");
	log.debug("sakai.action = {}", action);

	PortletSession pSession = request.getPortletSession(true);

	// Clear before Action
	clearErrorMessage(request);

	String view = (String) pSession.getAttribute("sakai.view");
	log.debug("sakai.view={}", view);

	if ( action == null ) {
		// Do nothing
	} else if ( action.equals("main") ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( action.equals("edit") ) {
		pSession.setAttribute("sakai.view", "edit");
	} else if ( action.equals("edit.reset") ) {
		pSession.setAttribute("sakai.view","edit.reset");
	} else if (action.equals("edit.setup")){
		pSession.setAttribute("sakai.view","edit.setup");
	} else if ( action.equals("edit.clear") ) {
		clearSession(request);
		response.setPortletMode(PortletMode.VIEW);
		pSession.setAttribute("sakai.view", "main");
	} else if ( action.equals("edit.do.reset") ) {
		processActionReset(action,request, response);
	} else if ( action.equals("edit.save") ) {
		processActionSave(action,request, response);
	}
	log.debug("==== End of ProcessAction ====");
}
 
Example 14
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 15
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public String getFormParameter(ActionRequest request, Properties sakaiProperties, String propName)
{
	String propValue = getCorrectProperty(request, propName, null);
	if ( propValue == null || ! isPropertyFinal(propName) )
	{
		propValue = request.getParameter("imsti."+propName);
	}
	log.debug("Form/Final imsti.{}={}", propName, propValue);
	if (propValue != null ) propValue = propValue.trim();
	return propValue;
}
 
Example 16
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	log.debug("==== processAction called ====");

	String action = request.getParameter("sakai.action");
	log.debug("sakai.action = {}", action);

	PortletSession pSession = request.getPortletSession(true);

	// Clear before Action
	clearErrorMessage(request);

	String view = (String) pSession.getAttribute("sakai.view");
	log.debug("sakai.view={}", view);

	if ( action == null ) {
		// Do nothing
	} else if ( action.equals("main") ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( action.equals("edit") ) {
		pSession.setAttribute("sakai.view", "edit");
	} else if ( action.equals("edit.reset") ) {
		pSession.setAttribute("sakai.view","edit.reset");
	} else if (action.equals("edit.setup")){
		pSession.setAttribute("sakai.view","edit.setup");
	} else if ( action.equals("edit.clear") ) {
		clearSession(request);
		response.setPortletMode(PortletMode.VIEW);
		pSession.setAttribute("sakai.view", "main");
	} else if ( action.equals("edit.do.reset") ) {
		processActionReset(action,request, response);
	} else if ( action.equals("edit.save") ) {
		processActionSave(action,request, response);
	}
	log.debug("==== End of ProcessAction ====");
}
 
Example 17
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	log.debug("==== processAction called ====");

	PortletSession pSession = request.getPortletSession(true);

	// Our first challenge is to figure out which action we want to take
	// The view selects the "next action" either as a URL parameter
	// or as a hidden field in the POST data - we check both

	String doCancel = request.getParameter("sakai.cancel");
	String doUpdate = request.getParameter("sakai.update");

	// Our next challenge is to pick which action the previous view
	// has told us to do.  Note that the view may place several actions
	// on the screen and the user may have an option to pick between
	// them.  Make sure we handle the "no action" fall-through.

	pSession.removeAttribute("error.message");

	if ( doCancel != null ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( doUpdate != null ) {
		processActionEdit(request, response);
	} else {
		log.debug("Unknown action");
		response.setPortletMode(PortletMode.VIEW);
	}

	log.debug("==== End of ProcessAction  ====");
}
 
Example 18
Source File: PortletIFrame.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	// log.info("==== processAction called ====");

	PortletSession pSession = request.getPortletSession(true);

	// Our first challenge is to figure out which action we want to take
	// The view selects the "next action" either as a URL parameter
	// or as a hidden field in the POST data - we check both

	String doCancel = request.getParameter("sakai.cancel");
	String doUpdate = request.getParameter("sakai.update");

	// Our next challenge is to pick which action the previous view
	// has told us to do.  Note that the view may place several actions
	// on the screen and the user may have an option to pick between
	// them.  Make sure we handle the "no action" fall-through.

	pSession.removeAttribute("error.message");

	if ( doCancel != null ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( doUpdate != null ) {
		processActionEdit(request, response);
	} else {
		// log.info("Unknown action");
		response.setPortletMode(PortletMode.VIEW);
	}

	// log.info("==== End of ProcessAction  ====");
}
 
Example 19
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 20
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void processActionEdit(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	// TODO: Check Role

	// Stay in EDIT mode unless we are successful
	response.setPortletMode(PortletMode.EDIT);

	String id = request.getParameter(LTIService.LTI_ID);
	String toolId = request.getParameter(LTIService.LTI_TOOL_ID);
	Properties reqProps = new Properties();
	Enumeration<String> names = request.getParameterNames();
	while (names.hasMoreElements()) {
		String name = names.nextElement();
		reqProps.setProperty(name, request.getParameter(name));
	}
	Placement placement = ToolManager.getCurrentPlacement();
	m_ltiService.updateContent(Long.parseLong(id), reqProps, placement.getContext());
	String fa_icon = (String) request.getParameter(LTIService.LTI_FA_ICON);
	if ( fa_icon != null && fa_icon.length() > 0 ) {
		placement.getPlacementConfig().setProperty("imsti.fa_icon",fa_icon);
	}

	// get the site toolConfiguration, if this is part of a site.
	ToolConfiguration toolConfig = SiteService.findTool(placement.getId());

	String title = reqProps.getProperty("title");
	if (StringUtils.isNotBlank(title)) {
		// Set the title for the page
		toolConfig.getContainingPage().setTitle(title);

		try {
			SiteService.save(SiteService.getSite(toolConfig.getSiteId()));
		} catch (Exception e) {
			log.error("Failed to save site", e);
		}
	}

	placement.save();

	response.setPortletMode(PortletMode.VIEW);
}