List of usage examples for javax.servlet.jsp PageContext getAttribute
abstract public Object getAttribute(String name, int scope);
From source file:org.mitre.medj.WebUtils.java
/** * Gets the requiredAttribute attribute of the WebUtils class * * @param page Description of the Parameter * @param name Description of the Parameter * @param scope Description of the Parameter * @return The requiredAttribute value *///from w w w . j a v a 2 s .c o m public static String getRequiredAttribute(PageContext page, String name, int scope) { Object ret = page.getAttribute(name, scope); if (ret == null) { throw new NullPointerException("This form requires a \"" + name + "\" parameter, which was missing from the submitted request."); } return ret.toString(); }
From source file:org.mitre.medj.WebUtils.java
/** * Gets the optionalAttribute attribute of the WebUtils class * * @param page Description of the Parameter * @param name Description of the Parameter * @param scope Description of the Parameter * @return The optionalAttribute value *//*ww w . j a va 2 s.c om*/ public static String getOptionalAttribute(PageContext page, String name, int scope) { Object ret = page.getAttribute(name, scope); if (ret == null) { return ""; } return ret.toString(); }
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 *//*w w w . java 2s .co m*/ 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.squale.welcom.taglib.field.util.LayoutUtils.java
/** * Get the label with the key 'key' from the pageContext messageRessources. Handle classic exception * /*from w w w . j a v a 2s.c om*/ * @param pageContext le page context * @param pBundle le bundle * @param key la cle * @param args les arguments * @throws JspException exception pouvant etre levee * @return le label */ public static String getLabel(final PageContext pageContext, final String pBundle, final String key, final Object args[]) throws JspException { // Acquire the resources object containing our messages final MessageResources resources = (MessageResources) pageContext.findAttribute(pBundle); if (resources == null) { throw new JspException(messages.getMessage("messageTag.resources", pBundle)); } // Calculate the Locale we will be using Locale locale = null; try { locale = (Locale) pageContext.getAttribute(localeKey, PageContext.SESSION_SCOPE); } catch (final IllegalStateException e) { // Invalidated session locale = null; } if (locale == null) { locale = Locale.getDefault(); } // Retrieve the message string we are looking for final String message = resources.getMessage(locale, key, args); if (message == null) { return key; } return message; }
From source file:org.vulpe.view.tags.Functions.java
/** * * @param pageContext/*from w ww. ja v a 2 s . c om*/ * @param key * @param value * @param scope * @return */ public static Object get(final PageContext pageContext, final String key, final Integer scope) { return pageContext.getAttribute(key, scope); }