List of usage examples for javax.servlet.jsp PageContext setAttribute
abstract public void setAttribute(String name, Object value);
From source file:fll.web.admin.ChangePassword.java
public static void populateContext(final HttpServletRequest request, final ServletContext application, final PageContext pageContext) { final DataSource datasource = ApplicationAttributes.getDataSource(application); Connection connection = null; try {/*from w w w . java 2 s . c om*/ connection = datasource.getConnection(); final Collection<String> loginKeys = CookieUtils.findLoginKey(request); final String user = Queries.checkValidLogin(connection, loginKeys); pageContext.setAttribute("fll_user", user); } catch (final SQLException e) { throw new RuntimeException(e); } finally { SQLFunctions.close(connection); } }
From source file:com.redhat.rhn.frontend.taglibs.list.ListTagUtil.java
/** * Stores a ListCommand in the page context and makes it current * @param ctx caller's page context//from w ww. j av a2 s. c o m * @param uniqueName owning list's unique name * @param cmd new current command */ public static void setCurrentCommand(PageContext ctx, String uniqueName, ListCommand cmd) { ctx.setAttribute(uniqueName + "_cmd", cmd); }
From source file:eionet.cr.web.util.JstlFunctions.java
/** * * @param objectValue// ww w . j a v a2 s . com * @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:test.pl.chilldev.web.tags.page.MetaPropertyTagTest.java
@Test public void doEndTag() throws JspTagException { PageContext context = new MockPageContext(); MetaPropertyTag tag = new MetaPropertyTag(); tag.setPageContext(context);//from w w w .j a v a2 s.c om // set up context String attribute = "foo"; context.setAttribute(attribute, this.page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String key = "bar"; String value = "baz"; // run the tag tag.setKey(key); tag.setValue(value); tag.doEndTag(); verify(this.page).setMetaProperty(key, value); }
From source file:test.pl.chilldev.web.tags.page.MetaHttpEquivTagTest.java
@Test public void doEndTag() throws JspTagException { PageContext context = new MockPageContext(); MetaHttpEquivTag tag = new MetaHttpEquivTag(); tag.setPageContext(context);/*w w w . j a v a 2 s. c o m*/ // set up context String attribute = "foo"; context.setAttribute(attribute, this.page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String key = "bar"; String value = "baz"; // run the tag tag.setKey(key); tag.setValue(value); tag.doEndTag(); verify(this.page).setHttpEquiv(key, value); }
From source file:test.pl.chilldev.web.tags.page.MetaNameTagTest.java
@Test public void doEndTag() throws JspTagException { PageContext context = new MockPageContext(); MetaNameTag tag = new MetaNameTag(); tag.setPageContext(context);// ww w.java 2 s .c o m // set up context String attribute = "foo"; context.setAttribute(attribute, this.page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String key = "bar"; String value = "baz"; // run the tag tag.setKey(key); tag.setValue(value); tag.doEndTag(); verify(this.page).setMetaName(key, value); }
From source file:test.pl.chilldev.web.tags.page.MetaNameTagTest.java
@Test public void doEndTagWithBodyContent() throws JspTagException { PageContext context = new MockPageContext(); MetaNameTag tag = new MetaNameTag(); tag.setPageContext(context);//w w w. ja va2s.c om // set up context String attribute = "foo"; context.setAttribute(attribute, this.page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String key = "bar"; String value = "baz"; when(this.body.getString()).thenReturn(value); // run the tag tag.setKey(key); tag.setBodyContent(this.body); tag.doEndTag(); verify(this.page).setMetaName(key, value); }
From source file:test.pl.chilldev.web.tags.page.TitleAddTagTest.java
@Test(expected = JspTagException.class) public void doEndTagInvalidModelType() throws JspTagException { PageContext context = new MockPageContext(); TitleAddTag tag = new TitleAddTag(); tag.setPageContext(context);//from ww w . ja v a2s .co m // set up context String attribute = "foo"; context.setAttribute(attribute, this); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); // run the tag tag.doEndTag(); }
From source file:test.pl.chilldev.web.tags.page.TitleAddTagTest.java
@Test public void doEndTag() throws JspTagException { PageContext context = new MockPageContext(); TitleAddTag tag = new TitleAddTag(); tag.setPageContext(context);/*from w w w.j a v a2 s . c o m*/ // set up context String attribute = "foo"; context.setAttribute(attribute, this.page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String part = "bar"; // run the tag tag.setPart(part); tag.doEndTag(); verify(this.page).addTitlePart(part); }
From source file:test.pl.chilldev.web.tags.page.TitleAddTagTest.java
@Test public void doEndTagWithBodyContent() throws JspTagException { PageContext context = new MockPageContext(); TitleAddTag tag = new TitleAddTag(); tag.setPageContext(context);// ww w.j a v a 2 s.c o m // set up context String attribute = "foo"; context.setAttribute(attribute, this.page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String part = "bar"; when(this.body.getString()).thenReturn(part); // run the tag tag.setBodyContent(this.body); tag.doEndTag(); verify(this.page).addTitlePart(part); }