List of usage examples for javax.servlet.jsp PageContext getAttribute
abstract public Object getAttribute(String name);
From source file:de.micromata.genome.gwiki.page.impl.i18n.GWikiMessageTag.java
@SuppressWarnings("unchecked") public static void renderPatchDom(PageContext pageContext) throws JspException { Object l = pageContext.getAttribute(GWIKI_MESSAGE_ATTR); if ((l instanceof List) == false) { return;/* w w w. j av a 2s. c o m*/ } List<GWikiMessageTag> tags = (ArrayList<GWikiMessageTag>) l; if (tags.isEmpty() == true) { return; } StringBuilder sb = new StringBuilder(); sb.append("<script type=\"text/javascript\">gwikiPatchI18NElements(["); boolean first = true; for (GWikiMessageTag tag : tags) { if (first == false) { sb.append(", "); } else { first = false; } sb.append("{ id: '" + tag.getTagId() + "', i18nKey: '" + tag.getKeyAttrValue() + "'}"); } sb.append("]);</script>"); try { pageContext.getOut().write(sb.toString()); } catch (IOException e) { throw new JspException(e); } }
From source file:net.sourceforge.fenixedu.presentationTier.TagLib.content.ContentLinkTag.java
public static Object getObject(final String name, final PageContext pageContext, final String scope) { final int pageScope = getPageScope(scope); return pageScope == -1 ? pageContext.getAttribute(name) : pageContext.getAttribute(name, pageScope); }
From source file:com.redhat.rhn.frontend.taglibs.list.ListTagUtil.java
/** * Gets the current value of a "persistent" counter * @param ctx active PageContext//www . j av a 2 s . c om * @param name name of counter * @return current value if counter exists, else -1 */ public static long getPersistentCounterValue(PageContext ctx, String name) { long retval = -1; Long counter = (Long) ctx.getAttribute(name); if (counter != null) { retval = counter.longValue(); } return retval; }
From source file:eionet.cr.web.util.JstlFunctions.java
/** * * @param objectValue/*from w w w. j ava 2 s . c o m*/ * @param pageContext * @return */ public static boolean isObjectValueDisplayed(String predicate, String objectValue, PageContext pageContext) { boolean result = false; if (predicate != null) { String previousPredicate = (String) pageContext.getAttribute("prevPredicate"); HashSet<String> objectValues = (HashSet<String>) pageContext.getAttribute("displayedObjectValues"); if (objectValues == null || previousPredicate == null || !predicate.equals(previousPredicate)) { objectValues = new HashSet<String>(); pageContext.setAttribute("displayedObjectValues", objectValues); } result = objectValues.contains(objectValue); pageContext.setAttribute("prevPredicate", predicate); objectValues.add(objectValue); } return result; }
From source file:org.sakaiproject.iclicker.tool.ToolController.java
@SuppressWarnings("unchecked") public static void addMessage(PageContext context, String key, String message) { if (context == null || key == null) { throw new IllegalArgumentException( "context (" + context + ") and key (" + key + ") must both not be null"); }/* www .ja v a2s . co m*/ if (message != null && !"".equals(message)) { String keyVal = ICLICKER_MESSAGES + key; if (context.getAttribute(keyVal) == null) { context.setAttribute(keyVal, new Vector<String>(), PageContext.REQUEST_SCOPE); } List<String> l = (List<String>) context.getAttribute(keyVal, PageContext.REQUEST_SCOPE); l.add(message); } }
From source file:com.redhat.rhn.frontend.taglibs.list.ListTagUtil.java
/** * Locates the current ListCommand/* ww w .j a v a2 s . c o m*/ * @param caller tag calling the method * @param ctx caller's page context * @return ListCommand if found, otherwise null */ public static ListCommand getCurrentCommand(Tag caller, PageContext ctx) { ListTag parent = null; if (!(caller instanceof ListTag)) { parent = (ListTag) BodyTagSupport.findAncestorWithClass(caller, ListTag.class); } else { parent = (ListTag) caller; } if (parent != null) { return (ListCommand) ctx.getAttribute(parent.getUniqueName() + "_cmd"); } return null; }
From source file:net.mlw.vlh.web.util.ImagesHomeDisplayHelper.java
/** * @see net.mlw.vlh.web.util.DisplayHelper#help(javax.servlet.jsp.PageContext, * java.lang.String)//from w w w . j a va 2 s . co m */ public String help(PageContext pageContext, String key) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Replacing images home '" + (String) pageContext.getAttribute(IMAGES_HOME_ATTRIBUTE_KEY) + "' in key '" + key + "'"); } return key.replaceAll("@IMAGES_HOME@", (String) pageContext.getAttribute(IMAGES_HOME_ATTRIBUTE_KEY)); }
From source file:org.gvnix.datatables.tags.SpringContextHelper.java
/** * Returns the current request Spring {@link RequestContext} object. If a * {@link RequestContext} is not already available, a new one is created and * included in the {@link PageContext}/*from w w w.j a v a 2s.c o m*/ * * @param pageContext the current page context * @return the {@link RequestContext} related to this request. */ public RequestContext getRequestContext(PageContext pageContext) { RequestContext requestContext = (RequestContext) pageContext .getAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE); if (requestContext == null) { requestContext = new JspAwareRequestContext(pageContext); pageContext.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, requestContext); } return requestContext; }
From source file:com.ecyrd.jspwiki.filters.SpamFilter.java
/** * This method checks if the hash value is still valid, i.e. if it exists at all. This * can occur in two cases: either this is a spam bot which is not adaptive, or it is * someone who has been editing one page for too long, and their session has expired. * <p>//from w ww . j a va2 s . c o m * This method puts a redirect to the http response field to page "SessionExpired" * and logs the incident in the spam log (it may or may not be spam, but it's rather likely * that it is). * * @param context The WikiContext * @param pageContext The JSP PageContext. * @return True, if hash is okay. False, if hash is not okay, and you need to redirect. * @throws IOException If redirection fails * @since 2.6 */ public static final boolean checkHash(WikiContext context, PageContext pageContext) throws IOException { String hashName = getHashFieldName((HttpServletRequest) pageContext.getRequest()); if (pageContext.getRequest().getParameter(hashName) == null) { if (pageContext.getAttribute(hashName) == null) { Change change = getChange(context, EditorManager.getEditedText(pageContext)); log(context, REJECT, "MissingHash", change.m_change); String redirect = context.getURL(WikiContext.VIEW, "SessionExpired"); ((HttpServletResponse) pageContext.getResponse()).sendRedirect(redirect); return false; } } return true; }
From source file:org.openmrs.web.taglib.FormatTagTest.java
/** * This method checks correctness of start tag evaluation of given tag * //w ww. j a v a2 s. c o m * @param pageContext the page context to be used when checking start tag evaluation * @param tag the format tag whose doStartTag() method will be evaluated * @param object the object to format with given tag * @param expected the expected result of object formatting */ private void checkStartTagEvaluation(PageContext pageContext, FormatTag tag, Object object, String expected) { tag.setObject(object); Assert.assertEquals(Tag.SKIP_BODY, tag.doStartTag()); Assert.assertNotNull(pageContext.getAttribute(ATTRIBUTE_OBJECT_VALUE)); Assert.assertEquals(expected, pageContext.getAttribute(ATTRIBUTE_OBJECT_VALUE)); }