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


Java PortletSession.getAttribute方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: getErrorMessage

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public static String getErrorMessage(PortletRequest request)
{   
	PortletSession pSession = request.getPortletSession(true);
	try {
		return (String) pSession.getAttribute("error.message");
	} catch (Throwable t) {
		return null;
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:10,代码来源:PortletHelper.java

示例7: getErrorOutput

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public static String getErrorOutput(PortletRequest request)
{   
	PortletSession pSession = request.getPortletSession(true);
	try {
		return (String) pSession.getAttribute("error.output");
	} catch (Throwable t) {
		return null;
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:10,代码来源:PortletHelper.java

示例8: getErrorMap

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public static Map getErrorMap(PortletRequest request)
{   
	PortletSession pSession = request.getPortletSession(true);
	try {
		return (Map) pSession.getAttribute("error.map");
	} catch (Throwable t) {
		return null;
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:10,代码来源:PortletHelper.java

示例9: getDebugOutput

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public static String getDebugOutput(PortletRequest request)
{   
	PortletSession pSession = request.getPortletSession(true);
	try {
		return (String) pSession.getAttribute("debug.print");
	} catch (Throwable t) {
		return null;
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:10,代码来源:PortletHelper.java

示例10: doEdit

import javax.portlet.PortletSession; //导入方法依赖的package包/类
public void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException {

	response.setContentType("text/html");
	log.debug("==== doEdit called ====");

	PortletSession pSession = request.getPortletSession(true);

	String title = getTitleString(request);
	if ( title != null ) response.setTitle(title);

	// Debug
	String inputData = (String) pSession.getAttribute("sakai.descriptor");
	if ( inputData != null ) log.debug("descriptor.length()={}", inputData.length());
	String url = (String) pSession.getAttribute("sakai.url");
	log.debug("sakai.url={}", url);

	String view = (String) pSession.getAttribute("sakai.view");
	log.debug("sakai.view={}", view);
	if ( "edit.reset".equals(view) ) {
		sendToJSP(request, response, "/editreset.jsp");
	} else {
		prepareEdit(request);
		sendToJSP(request, response, "/edit.jsp");
	}

	clearErrorMessage(request);
	log.debug("==== doEdit called ====");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:30,代码来源:IMSBLTIPortlet.java

示例11: processAction

import javax.portlet.PortletSession; //导入方法依赖的package包/类
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 ====");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:38,代码来源:IMSBLTIPortlet.java

示例12: getErrorBean

import javax.portlet.PortletSession; //导入方法依赖的package包/类
/**
 * Gets the error bean from a request
 * 
 * @param request
 *           the request
 * @return the error bean
 */
public static ErrorBean getErrorBean(ServletRequest request)
{
   PortletRequest portletReq = (PortletRequest) request.getAttribute("javax.portlet.request");
   if (portletReq != null)
   {
      PortletSession session = portletReq.getPortletSession(false);
      if (session != null)
      {
         return (ErrorBean)session.getAttribute(ErrorBean.ERROR_BEAN_NAME);
      }
   }
   return null;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:21,代码来源:AlfrescoFacesPortlet.java

示例13: getPortletSessionAttribute

import javax.portlet.PortletSession; //导入方法依赖的package包/类
/**
  * Gets a session attribute.
  * 
  * @param context
  *            the faces context
  * @param attributeName
  *            the attribute name
  * @param shared
  *            get the attribute from shared (application) scope?
  * @return the portlet session attribute
  */
public static Object getPortletSessionAttribute(FacesContext context, String attributeName, boolean shared)
{
   Object portletReq = context.getExternalContext().getRequest();
   if (portletReq != null && portletReq instanceof PortletRequest)
   {
      PortletSession session = ((PortletRequest) portletReq).getPortletSession(false);
      if (session != null)
      {
         return session.getAttribute(attributeName, shared ? PortletSession.APPLICATION_SCOPE
               : PortletSession.PORTLET_SCOPE);
      }
   }
   return null;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:26,代码来源:AlfrescoFacesPortlet.java

示例14: setBeanHolder

import javax.portlet.PortletSession; //导入方法依赖的package包/类
/**
 * Sets the portlet session bean holder in a ThreadLocal object for the given portlet session. If no bean holder
 * exists in the session, a new one is created.
 * 
 * @param ps
 *           The portlet session.
 * @return The portlet session bean holder
 */
public static void setBeanHolder(PortletRequest req, PortletSessionScopedConfig config) {

   PortletSession ps = req.getPortletSession();
   String windowId = req.getWindowID();

   PortletSessionScopedBeanMap map = (PortletSessionScopedBeanMap) ps.getAttribute(ATTRIBNAME,
         PortletSession.APPLICATION_SCOPE);
   
   boolean createdMap = false;
   if (map == null) {
      map = new PortletSessionScopedBeanMap();
      ps.setAttribute(ATTRIBNAME, map, PortletSession.APPLICATION_SCOPE);
      createdMap = true;
   }

   PortletSessionBeanHolder holder = new PortletSessionBeanHolder(map, windowId, config);
   holders.set(holder);

   if (isTrace) {
      StringBuilder txt = new StringBuilder(80);
      txt.append("Set portlet session bean holder.");
      txt.append(" ThreadId: ").append(Thread.currentThread().getId());
      txt.append(", PortletSession: ").append(ps.getId());
      txt.append(", WindowId: ").append(windowId);
      txt.append(", Added new BeanMap to session: ").append(createdMap);
      LOG.debug(txt.toString());
   }
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:37,代码来源:PortletSessionBeanHolder.java

示例15: handleError

import javax.portlet.PortletSession; //导入方法依赖的package包/类
/**
 * Handles errors that occur during a render request
 */
private void handleError(RenderRequest request, RenderResponse 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);

   // if the faces context is available set the current view to the browse page
   // so that the error page goes back to the application (rather than going back
   // to the same page which just throws the error again meaning we can never leave
   // the error page)
   FacesContext context = FacesContext.getCurrentInstance();
   if (context != null)
   {
      ViewHandler viewHandler = context.getApplication().getViewHandler();
      // TODO: configure the portlet error return page
      UIViewRoot view = viewHandler.createView(context, FacesHelper.BROWSE_VIEW_ID);
      context.setViewRoot(view);
   }

   // get the error page and include that instead
   String errorPage = getErrorPage();
   
   if (logger.isDebugEnabled())
      logger.debug("An error has occurred, redirecting to error page: " + errorPage);
   
   response.setContentType("text/html");
   PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(errorPage);
   dispatcher.include(request, response);
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:41,代码来源:AlfrescoFacesPortlet.java


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