List of usage examples for javax.servlet.jsp PageContext APPLICATION_SCOPE
int APPLICATION_SCOPE
To view the source code for javax.servlet.jsp PageContext APPLICATION_SCOPE.
Click Source Link
From source file:org.hyperic.hq.ui.taglib.display.TableTag.java
/** * This functionality is borrowed from struts, but I've removed some struts * specific features so that this tag can be used both in a struts * application, and outside of one./*from w ww.j a v a2 s .c o m*/ * * Locate and return the specified bean, from an optionally specified scope, * in the specified page context. If no such bean is found, return * <code>null</code> instead. * * @param pageContext * Page context to be searched * @param name * Name of the bean to be retrieved * @param scope * Scope to be searched (page, request, session, application) or * <code>null</code> to use <code>findAttribute()</code> instead * * @exception JspException * if an invalid scope name is requested */ public Object lookup(PageContext pageContext, String name, String scope) throws JspException { Object bean = null; if (scope == null) bean = pageContext.findAttribute(name); else if (scope.equalsIgnoreCase("page")) bean = pageContext.getAttribute(name, PageContext.PAGE_SCOPE); else if (scope.equalsIgnoreCase("request")) bean = pageContext.getAttribute(name, PageContext.REQUEST_SCOPE); else if (scope.equalsIgnoreCase("session")) bean = pageContext.getAttribute(name, PageContext.SESSION_SCOPE); else if (scope.equalsIgnoreCase("application")) bean = pageContext.getAttribute(name, PageContext.APPLICATION_SCOPE); else { Object[] objs = { name, scope }; if (prop.getProperty("error.msg.cant_find_bean") != null) { String msg = MessageFormat.format(prop.getProperty("error.msg.cant_find_bean"), objs); throw new JspException(msg); } else { throw new JspException("Could not find " + name + " in scope " + scope); } } return (bean); }
From source file:org.rhq.enterprise.gui.legacy.taglib.display.TableTag.java
/** * This functionality is borrowed from struts, but I've removed some struts specific features so that this tag can * be used both in a struts application, and outside of one. * * <p/>Locate and return the specified bean, from an optionally specified scope, in the specified page context. If * no such bean is found, return <code>null</code> instead. * * @param pageContext Page context to be searched * @param name Name of the bean to be retrieved * @param scope Scope to be searched (page, request, session, application) or <code>null</code> to use <code> * findAttribute()</code> instead * * @throws JspException if an invalid scope name is requested *///from w w w . j av a 2 s . c om public Object lookup(PageContext pageContext, String name, String scope) throws JspException { log.trace("looking up: " + name + " in scope: " + scope); Object bean; if (scope == null) { bean = pageContext.findAttribute(name); } else if (scope.equalsIgnoreCase("page")) { bean = pageContext.getAttribute(name, PageContext.PAGE_SCOPE); } else if (scope.equalsIgnoreCase("request")) { bean = pageContext.getAttribute(name, PageContext.REQUEST_SCOPE); } else if (scope.equalsIgnoreCase("session")) { bean = pageContext.getAttribute(name, PageContext.SESSION_SCOPE); } else if (scope.equalsIgnoreCase("application")) { bean = pageContext.getAttribute(name, PageContext.APPLICATION_SCOPE); } else { Object[] objs = { name, scope }; if (prop.getProperty("error.msg.cant_find_bean") != null) { String msg = MessageFormat.format(prop.getProperty("error.msg.cant_find_bean"), objs); throw new JspException(msg); } else { throw new JspException("Could not find " + name + " in scope " + scope); } } return (bean); }
From source file:org.sakaiproject.metaobj.security.control.tag.AuthZMapTag.java
public void setScope(String scope) { if (scope.equalsIgnoreCase("page")) { this.scope = PageContext.PAGE_SCOPE; } else if (scope.equalsIgnoreCase("request")) { this.scope = PageContext.REQUEST_SCOPE; } else if (scope.equalsIgnoreCase("session")) { this.scope = PageContext.SESSION_SCOPE; } else if (scope.equalsIgnoreCase("application")) { this.scope = PageContext.APPLICATION_SCOPE; }// w w w . j a v a 2s.c o m // TODO: Add error handling? Needs direction from spec. }
From source file:org.theospi.portfolio.security.control.tag.AuthZMapTag.java
public void setScope(String scope) { if (scope.equalsIgnoreCase("page")) this.scope = PageContext.PAGE_SCOPE; else if (scope.equalsIgnoreCase("request")) this.scope = PageContext.REQUEST_SCOPE; else if (scope.equalsIgnoreCase("session")) this.scope = PageContext.SESSION_SCOPE; else if (scope.equalsIgnoreCase("application")) this.scope = PageContext.APPLICATION_SCOPE; // TODO: Add error handling? Needs direction from spec. }
From source file:us.mn.state.health.lims.taglib.JavascriptValidatorTag.java
/** * Returns fully rendered JavaScript.//from w ww. j av a2 s . co m * @since Struts 1.2 */ protected String renderJavascript() throws JspException { StringBuffer results = new StringBuffer(); ModuleConfig config = TagUtils.getInstance().getModuleConfig(pageContext); ValidatorResources resources = (ValidatorResources) pageContext .getAttribute(ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix(), PageContext.APPLICATION_SCOPE); if (resources == null) { throw new JspException("ValidatorResources not found in application scope under key \"" + ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix() + "\""); } Locale locale = TagUtils.getInstance().getUserLocale(this.pageContext, null); Form form = resources.getForm(locale, formName); if ("true".equalsIgnoreCase(dynamicJavascript) && form == null) { throw new JspException("No form found under '" + formName + "' in locale '" + locale + "'"); } if (form != null) { if ("true".equalsIgnoreCase(dynamicJavascript)) { results.append(this.createDynamicJavascript(config, resources, locale, form)); } else if ("true".equalsIgnoreCase(staticJavascript)) { results.append(this.renderStartElement()); if ("true".equalsIgnoreCase(htmlComment)) { results.append(HTML_BEGIN_COMMENT); } } } if ("true".equalsIgnoreCase(staticJavascript)) { results.append(getJavascriptStaticMethods(resources)); } if (form != null && ("true".equalsIgnoreCase(dynamicJavascript) || "true".equalsIgnoreCase(staticJavascript))) { results.append(getJavascriptEnd()); } return results.toString(); }