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

The following examples show how to use javax.portlet.ActionRequest#getParameterNames() . 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: ActionParameterTest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
protected TestResult checkParameterNames(ActionRequest request) {
    TestResult result = new TestResult();
    result.setDescription("Ensure parameters encoded in action URL "
    		+ "exists in the parameter name enumeration.");

    boolean hasParameterName = false;
    for (Enumeration<String> en = request.getParameterNames();
    		!hasParameterName && en.hasMoreElements(); ) {
    	String name = en.nextElement();
    	if (KEY.equals(name)) {
    		hasParameterName = true;
    	}
    }

    if (hasParameterName) {
    	result.setReturnCode(TestResult.PASSED);
    } else {
    	result.setReturnCode(TestResult.FAILED);
    	result.setResultMessage("Parameter name " + KEY
    			+ " not found in parameter name enumeration.");
    }
    return result;
}
 
Example 2
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 3
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);
}
 
Example 4
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);
}