List of usage examples for javax.servlet.jsp PageContext setAttribute
abstract public void setAttribute(String name, Object value, int scope);
From source file:com.eurelis.opencms.admin.xmltransformation.ui.CmsXmlMockProcessDialog.java
public static CmsXmlMockProcessDialog newInstance(PageContext context, HttpServletRequest req, HttpServletResponse res) {/*from w w w .jav a 2s .c om*/ String currentParamSessionSortCol = (String) context.getAttribute("sort_column", PageContext.SESSION_SCOPE); CmsListOrderEnum currentSessionSortOrder = (CmsListOrderEnum) context.getAttribute("sort_order", PageContext.SESSION_SCOPE); String requestParamSessionSortCol = req.getParameter(PARAM_SORT_COL); String action = req.getParameter(PARAM_ACTION); CmsListOrderEnum listOrder; boolean refreshList = false; if (currentParamSessionSortCol == null || requestParamSessionSortCol == null) { listOrder = CmsListOrderEnum.ORDER_ASCENDING; requestParamSessionSortCol = LIST_COLUMN_PATH; } else { if (action.equals(LIST_SORT)) { if (requestParamSessionSortCol.equals(currentParamSessionSortCol)) { refreshList = true; if (currentSessionSortOrder.equals(CmsListOrderEnum.ORDER_ASCENDING)) { listOrder = CmsListOrderEnum.ORDER_DESCENDING; } else { listOrder = CmsListOrderEnum.ORDER_ASCENDING; } } else { listOrder = CmsListOrderEnum.ORDER_ASCENDING; } } else { listOrder = currentSessionSortOrder; } } context.setAttribute("sort_order", listOrder, PageContext.SESSION_SCOPE); context.setAttribute("sort_column", requestParamSessionSortCol, PageContext.SESSION_SCOPE); CmsXmlMockProcessDialog returnObject = new CmsXmlMockProcessDialog( new CmsJspActionElement(context, req, res), LIST_ID, Messages.get().container(Messages.GUI_MOCK_PROCESS_LIST_NAME_0), requestParamSessionSortCol, listOrder, null); if (refreshList) { returnObject.refreshList(); } return returnObject; }
From source file:com.glaf.core.tag.TagUtils.java
/** * Returns the appropriate MessageResources object for the current module * and the given bundle./* w w w. ja va 2s .co m*/ * * @param pageContext * Search the context's scopes for the resources. * @param bundle * The bundle name to look for. If this is <code>null</code>, the * default bundle name is used. * @param checkPageScope * Whether to check page scope * @return MessageResources The bundle's resources stored in some scope. * @throws JspException * if the MessageResources object could not be found. */ public MessageResources retrieveMessageResources(PageContext pageContext, String bundle, boolean checkPageScope) throws JspException { MessageResources resources = null; if (bundle == null) { bundle = conf.get("i18n.messages_key"); } if (bundle == null) { bundle = Globals.MESSAGES_KEY; } if (checkPageScope) { resources = (MessageResources) pageContext.getAttribute(bundle, PageContext.PAGE_SCOPE); } if (resources == null) { resources = (MessageResources) pageContext.getAttribute(bundle, PageContext.REQUEST_SCOPE); } if (resources == null) { resources = (MessageResources) pageContext.getAttribute(bundle, PageContext.APPLICATION_SCOPE); } if (resources == null) { resources = (MessageResources) pageContext.getAttribute(Globals.DEFAULT_RESOURCE_NAME, PageContext.APPLICATION_SCOPE); if (resources == null) { resources = PropertyMessageResourcesFactory.createFactory() .createResources(Globals.DEFAULT_RESOURCE_NAME); pageContext.setAttribute(Globals.DEFAULT_RESOURCE_NAME, resources, PageContext.APPLICATION_SCOPE); } } if (resources == null) { JspException e = new JspException(messages.getMessage("message.bundle", bundle)); saveException(pageContext, e); throw e; } return resources; }
From source file:org.apache.struts.taglib.tiles.util.TagUtils.java
/** * Store bean in requested context.//w w w . j a v a 2s . co m * If scope is <code>null</code>, save it in REQUEST_SCOPE context. * * @param pageContext Current pageContext. * @param name Name of the bean. * @param scope Scope under which bean is saved (page, request, session, application) * or <code>null</code> to store in <code>request()</code> instead. * @param value Bean value to store. * * @exception JspException Scope name is not recognized as a valid scope */ public static void setAttribute(PageContext pageContext, String name, Object value, String scope) throws JspException { if (scope == null) pageContext.setAttribute(name, value, PageContext.REQUEST_SCOPE); else if (scope.equalsIgnoreCase("page")) pageContext.setAttribute(name, value, PageContext.PAGE_SCOPE); else if (scope.equalsIgnoreCase("request")) pageContext.setAttribute(name, value, PageContext.REQUEST_SCOPE); else if (scope.equalsIgnoreCase("session")) pageContext.setAttribute(name, value, PageContext.SESSION_SCOPE); else if (scope.equalsIgnoreCase("application")) pageContext.setAttribute(name, value, PageContext.APPLICATION_SCOPE); else { throw new JspException("Error - bad scope name '" + scope + "'"); } }
From source file:org.apache.struts.taglib.tiles.util.TagUtils.java
/** * Store bean in REQUEST_SCOPE context.// ww w.j a v a 2 s . c o m * * @param pageContext Current pageContext. * @param name Name of the bean. * @param beanValue Bean value to store. * * @exception JspException Scope name is not recognized as a valid scope */ public static void setAttribute(PageContext pageContext, String name, Object beanValue) throws JspException { pageContext.setAttribute(name, beanValue, PageContext.REQUEST_SCOPE); }
From source file:org.apache.struts.taglib.tiles.util.TagUtils.java
/** * Save the specified exception as a request attribute for later use. * * @param pageContext The PageContext for the current page. * @param exception The exception to be saved. *//*from w ww . j ava 2 s . co m*/ public static void saveException(PageContext pageContext, Throwable exception) { pageContext.setAttribute(Globals.EXCEPTION_KEY, exception, PageContext.REQUEST_SCOPE); }
From source file:org.apache.tiles.jsp.context.JspUtil.java
/** * Sets the option that enables the forced include of the response. * * @param context The page context.//from w w w.java2 s.c o m * @param forceInclude If <code>true</code> the include operation must be * forced. * @since 2.0.6 */ public static void setForceInclude(PageContext context, boolean forceInclude) { Boolean retValue = Boolean.valueOf(forceInclude); context.setAttribute(ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME, retValue, PageContext.REQUEST_SCOPE); }
From source file:org.apache.tiles.jsp.context.JspUtil.java
/** * Configures the container to be used in the application. * * @param context The page context object to use. * @param container The container object to set. * @param key The key under which the container will be stored. * @since 2.1.2/*from www. j a v a 2 s . c om*/ */ public static void setContainer(PageContext context, TilesContainer container, String key) { Log log = LogFactory.getLog(ServletUtil.class); if (key == null) { key = TilesAccess.CONTAINER_ATTRIBUTE; } if (container == null) { if (log.isInfoEnabled()) { log.info("Removing TilesContext for context: " + context.getClass().getName()); } context.removeAttribute(key, PageContext.APPLICATION_SCOPE); } if (container != null && log.isInfoEnabled()) { log.info("Publishing TilesContext for context: " + context.getClass().getName()); } context.setAttribute(key, container, PageContext.APPLICATION_SCOPE); }
From source file:org.apache.tiles.jsp.context.JspUtil.java
/** * Sets the current container to use in web pages. * * @param context The page context to use. * @param key The key under which the container is stored. * @since 2.1.0/* w ww . j a v a 2 s. c o m*/ */ public static void setCurrentContainer(PageContext context, String key) { TilesContainer container = getContainer(context, key); if (container != null) { context.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME, container, PageContext.REQUEST_SCOPE); } else { throw new NoSuchContainerException("The container with the key '" + key + "' cannot be found"); } }
From source file:org.apache.tiles.jsp.context.JspUtil.java
/** * Sets the current container to use in web pages. * * @param context The page context to use. * @param container The container to use as the current container. * @since 2.1.0/*ww w . jav a 2 s .co m*/ */ public static void setCurrentContainer(PageContext context, TilesContainer container) { if (container != null) { context.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME, container, PageContext.REQUEST_SCOPE); } else { throw new NoSuchContainerException("The container cannot be null"); } }
From source file:org.apache.tiles.jsp.context.JspUtil.java
/** * Returns the current container that has been set, or the default one. * * @param context The page context to use. * @return The current Tiles container to use in web pages. * @since 2.1.0/* w w w . j av a2s .c o m*/ */ public static TilesContainer getCurrentContainer(PageContext context) { TilesContainer container = (TilesContainer) context .getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME, PageContext.REQUEST_SCOPE); if (container == null) { container = getContainer(context); context.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME, container, PageContext.REQUEST_SCOPE); } return container; }