当前位置: 首页>>代码示例>>Java>>正文


Java PortletSession.setAttribute方法代码示例

本文整理汇总了Java中javax.portlet.PortletSession.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java PortletSession.setAttribute方法的具体用法?Java PortletSession.setAttribute怎么用?Java PortletSession.setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.portlet.PortletSession的用法示例。


在下文中一共展示了PortletSession.setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAttribute

import javax.portlet.PortletSession; //导入方法依赖的package包/类
@Override
public void setAttribute(String name, Object value, int scope) {
	if (scope == SCOPE_REQUEST) {
		if (!isRequestActive()) {
			throw new IllegalStateException(
					"Cannot set request attribute - request is not active anymore!");
		}
		this.request.setAttribute(name, value);
	}
	else {
		PortletSession session = getSession(true);
		if (scope == SCOPE_GLOBAL_SESSION) {
			session.setAttribute(name, value, PortletSession.APPLICATION_SCOPE);
			this.globalSessionAttributesToUpdate.remove(name);
		}
		else {
			session.setAttribute(name, value);
			this.sessionAttributesToUpdate.remove(name);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:PortletRequestAttributes.java

示例2: serveResource

import javax.portlet.PortletSession; //导入方法依赖的package包/类
@Override
public void serveResource(ResourceRequest resourceRequest,
		ResourceResponse resourceResponse) throws IOException,
		PortletException {
	System.out.println("=====serveResource=======");
	String domainNo = ParamUtil.getString(resourceRequest, "domainNo");
	String administrationNo = ParamUtil.getString(resourceRequest,
			"administrationNo");
	PrintWriter pw = resourceResponse.getWriter();
	JSONObject juser = JSONFactoryUtil.createJSONObject();

	juser.put("domainNo", domainNo);
	juser.put("administrationNo", administrationNo);
	pw.println(juser.toString());
	PortletSession session = resourceRequest.getPortletSession();
	// PortletMode portletMode= resourceRequest.getPortletMode();
	// portletMode.s
	session.setAttribute("domainNo", domainNo);
	System.out.println(juser.toString());
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:21,代码来源:DossierProcPortlet.java

示例3: serveResource

import javax.portlet.PortletSession; //导入方法依赖的package包/类
@Override
public void serveResource(ResourceRequest resourceRequest,
		ResourceResponse resourceResponse) throws IOException,
		PortletException {
	System.out.println("=====serveResource=======");
	String domainNo = ParamUtil.getString(resourceRequest, "domainNo");
	String administrationNo = ParamUtil.getString(resourceRequest,
			"administrationNo");
	PrintWriter pw = resourceResponse.getWriter();
	JSONObject juser = JSONFactoryUtil.createJSONObject();

	juser.put("domainNo", domainNo);
	juser.put("administrationNo", administrationNo);
	pw.println(juser.toString());
	PortletSession session = resourceRequest.getPortletSession();
	session.setAttribute("domainNo", domainNo);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:18,代码来源:MenuListDomain.java

示例4: setErrorMessage

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public static void setErrorMessage(PortletRequest request, String errorMsg, Throwable t)
{
	if ( errorMsg == null ) errorMsg = "null";
	PortletSession pSession = request.getPortletSession(true);
	pSession.setAttribute("error.message",errorMsg);

	OutputStream oStream = new ByteArrayOutputStream();
	PrintStream pStream = new PrintStream(oStream);

	log.error("{}", oStream);
	log.error("{}", pStream);

	// errorMsg = errorMsg .replaceAll("<","&lt;").replaceAll(">","&gt;");

	StringBuffer errorOut = new StringBuffer();
	errorOut.append("<p class=\"portlet-msg-error\">\n");
	errorOut.append(FormattedText.escapeHtmlFormattedText(errorMsg));
	errorOut.append("\n</p>\n<!-- Traceback for this error\n");
	errorOut.append(oStream.toString());
	errorOut.append("\n-->\n");

	pSession.setAttribute("error.output",errorOut.toString());

	Map map = request.getParameterMap();
	pSession.setAttribute("error.map",map);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:27,代码来源:PortletHelper.java

示例5: debugPrint

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public static void debugPrint(PortletRequest request, String line)
{
	if ( line == null ) return;
	line = line.replaceAll("<","&lt;").replaceAll(">","&gt;");

	PortletSession pSession = request.getPortletSession(true);
	String debugOut = null;
	try {
		debugOut = (String) pSession.getAttribute("debug.print");
	} catch (Throwable t) {
		debugOut = null;
	}
	if ( debugOut == null ) {
		debugOut = line;
	} else {
		debugOut = debugOut + "\n" + line;
	}
	pSession.setAttribute("debug.print",debugOut);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:20,代码来源:PortletHelper.java

示例6: processActionReset

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public void processActionReset(String action,ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	// TODO: Check Role
	log.debug("Removing preferences....");
	clearSession(request);
	PortletSession pSession = request.getPortletSession(true);
	PortletPreferences prefs = request.getPreferences();
	try {
		prefs.reset("sakai.descriptor");
		for (String element : fieldList) {
			prefs.reset("imsti."+element);
			prefs.reset("sakai:imsti."+element);
		}
		log.debug("Preference removed");
	} catch (ReadOnlyException e) {
		setErrorMessage(request, rb.getString("error.modify.prefs")) ;
		return;
	}
	prefs.store();

	// Go back to the main edit page
	pSession.setAttribute("sakai.view", "edit");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:25,代码来源:IMSBLTIPortlet.java

示例7: handleError

import javax.portlet.PortletSession; //导入方法依赖的package包/类
/**
 * Handles errors that occur during a process action request
 */
private void handleError(ActionRequest request, ActionResponse response, Throwable error)
   throws PortletException, IOException
{
   // get the error bean from the session and set the error that occurred.
   PortletSession session = request.getPortletSession();
   ErrorBean errorBean = (ErrorBean)session.getAttribute(ErrorBean.ERROR_BEAN_NAME, 
                          PortletSession.PORTLET_SCOPE);
   if (errorBean == null)
   {
      errorBean = new ErrorBean();
      session.setAttribute(ErrorBean.ERROR_BEAN_NAME, errorBean, PortletSession.PORTLET_SCOPE);
   }
   errorBean.setLastError(error);
   
   response.setRenderParameter(ERROR_OCCURRED, "true");
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:20,代码来源:AlfrescoFacesPortlet.java

示例8: checkRemoveAppScopedAttribute

import javax.portlet.PortletSession; //导入方法依赖的package包/类
protected TestResult checkRemoveAppScopedAttribute(PortletSession session) {
    TestResult result = new TestResult();
    result.setDescription("Remove an application scoped session attribute "
    		+ "and ensure it's null.");
    result.setSpecPLT("15.3");

    session.setAttribute(KEY, VALUE, PortletSession.APPLICATION_SCOPE);
    session.removeAttribute(KEY, PortletSession.APPLICATION_SCOPE);
    Object value = session.getAttribute(KEY, PortletSession.APPLICATION_SCOPE);
    if (value == null) {
    	result.setReturnCode(TestResult.PASSED);
    } else {
    	TestUtils.failOnAssertion("session attribute", value, null, result);
    }
    return result;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:17,代码来源:AppScopedSessionAttributeTest.java

示例9: setAttribute

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public void setAttribute(String name, Object value, int scope) {
	if (scope == SCOPE_REQUEST) {
		if (!isRequestActive()) {
			throw new IllegalStateException(
					"Cannot set request attribute - request is not active anymore!");
		}
		this.request.setAttribute(name, value);
	}
	else {
		PortletSession session = getSession(true);
		if (scope == SCOPE_GLOBAL_SESSION) {
			session.setAttribute(name, value, PortletSession.APPLICATION_SCOPE);
			this.globalSessionAttributesToUpdate.remove(name);
		}
		else {
			session.setAttribute(name, value);
			this.sessionAttributesToUpdate.remove(name);
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:PortletRequestAttributes.java

示例10: testSimpleFormViewWithSessionAndBindOnNewForm

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public void testSimpleFormViewWithSessionAndBindOnNewForm() throws Exception {
	MockRenderRequest renderRequest = new MockRenderRequest();
	MockRenderResponse renderResponse = new MockRenderResponse();
	renderRequest.setParameter("action", "form-session-bind");
	renderRequest.setParameter("age", "30");
	TestBean testBean = new TestBean();
	testBean.setAge(40);
	SimplePortletApplicationContext ac =
			(SimplePortletApplicationContext)simpleDispatcherPortlet.getPortletApplicationContext();
	String formAttribute = ac.getFormSessionAttributeName();
	PortletSession session = new MockPortletSession();
	session.setAttribute(formAttribute, testBean);
	renderRequest.setSession(session);
	simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
	assertEquals("35", renderResponse.getContentAsString());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:DispatcherPortletTests.java

示例11: checkSetAttribute

import javax.portlet.PortletSession; //导入方法依赖的package包/类
protected TestResult checkSetAttribute(PortletSession session) {
    TestResult res = new TestResult();
    res.setName("Set Attribute Test");
    res.setDescription("Sets and retrieves portlet sessionuest attribute.");

    session.setAttribute(KEY, VAL);
    Object val = session.getAttribute(KEY);
    if(!VAL.equals(val)) {
        res.setReturnCode(TestResult.FAILED);
        res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
    }
    else {
        res.setReturnCode(TestResult.PASSED);
    }

    session.removeAttribute(KEY);
    return res;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:19,代码来源:SimpleAttributeTest.java

示例12: checkRemoveAttribute

import javax.portlet.PortletSession; //导入方法依赖的package包/类
protected TestResult checkRemoveAttribute(PortletSession session) {
    TestResult res = new TestResult();
    res.setName("Remove Session Attribute Test");
    res.setDescription("Sets, removes and retrieves portlet request attribute.");

    session.setAttribute(KEY, VAL);
    session.removeAttribute(KEY);
    Object val = session.getAttribute(KEY);
    if(val!=null) {
        res.setReturnCode(TestResult.FAILED);
        res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
    }
    else {
        res.setReturnCode(TestResult.PASSED);
    }

    return res;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:19,代码来源:SimpleAttributeTest.java

示例13: getParameterAndSaveItToSession

import javax.portlet.PortletSession; //导入方法依赖的package包/类
protected String getParameterAndSaveItToSession(String paramName, PortletRequest req, PortletSession session) {
    String paramValue = req.getParameter(paramName);
    if (paramValue != null) {
        session.setAttribute(paramName, paramValue);
    } else {
        paramValue = (String) session.getAttribute(paramName);
    }

    return paramValue;
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:11,代码来源:AbstractSocialPortlet.java

示例14: getFriendsCount

import javax.portlet.PortletSession; //导入方法依赖的package包/类
private int getFriendsCount(PortletSession session, FacebookClientWrapper facebookClient) throws PortletException,
        IOException {
    Integer friendsCount = (Integer) session.getAttribute(ATTR_FRIENDS_COUNT);
    if (friendsCount == null) {
        friendsCount = facebookClient.getFriendsCount();
        session.setAttribute(ATTR_FRIENDS_COUNT, friendsCount);
    }
    return friendsCount;
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:10,代码来源:FacebookFriendsPortlet.java

示例15: getCurrentPageNumber

import javax.portlet.PortletSession; //导入方法依赖的package包/类
private int getCurrentPageNumber(RenderRequest request, PortletSession session) {
    Integer currentPage;
    if (request.getParameter(PARAM_PAGE) != null) {
        currentPage = Integer.parseInt(request.getParameter(PARAM_PAGE));
        session.setAttribute(PARAM_PAGE, currentPage);
    } else {
        currentPage = (Integer) session.getAttribute(PARAM_PAGE);
    }
    if (currentPage == null) {
        currentPage = 1;
    }
    return currentPage;
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:14,代码来源:FacebookFriendsPortlet.java


注:本文中的javax.portlet.PortletSession.setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。