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.apache.struts.taglib.bean.TestSizeTag.java
public void testSizeTagNamePropertyMapNoScopeNested() throws IOException, ServletException { request.setAttribute("runTest", "testSizeTagNamePropertyMapNoScopeNested"); SimpleBeanForTesting sbft = new SimpleBeanForTesting(); SimpleBeanForTesting sbft2 = new SimpleBeanForTesting(); sbft.setMap(map);//from w w w. ja v a 2 s. co m sbft2.setNestedObject(sbft); pageContext.setAttribute(REQUEST_KEY, sbft2, PageContext.APPLICATION_SCOPE); pageContext.forward("/test/org/apache/struts/taglib/bean/TestSizeTag.jsp"); }
From source file:org.apache.struts.taglib.bean.TestSizeTag.java
public void testSizeTagNamePropertyMapApplicationScopeNested() throws IOException, ServletException { request.setAttribute("runTest", "testSizeTagNamePropertyMapApplicationScopeNested"); SimpleBeanForTesting sbft = new SimpleBeanForTesting(); SimpleBeanForTesting sbft2 = new SimpleBeanForTesting(); sbft.setMap(map);/*from ww w.j a va 2 s . co m*/ sbft2.setNestedObject(sbft); pageContext.setAttribute(REQUEST_KEY, sbft2, PageContext.APPLICATION_SCOPE); pageContext.forward("/test/org/apache/struts/taglib/bean/TestSizeTag.jsp"); }
From source file:org.apache.struts.taglib.html.JavascriptValidatorTag.java
/** * Returns fully rendered JavaScript.//from ww w .j av a 2 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 = null; if ("true".equalsIgnoreCase(dynamicJavascript)) { form = resources.getForm(locale, formName); if (form == null) { throw new JspException("No form found under '" + formName + "' in locale '" + locale + "'. A form must be defined in the " + "Commons Validator configuration when " + "dynamicJavascript=\"true\" is set."); } } 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(); }
From source file:org.apache.struts.taglib.html.JavascriptValidatorTag.java
/** * Determines if validations should stop on an error. * * @param config The <code>ModuleConfig</code> used to lookup the * stopOnError setting./*from w ww .j av a 2 s . c om*/ * @return <code>true</code> if validations should stop on errors. */ private boolean stopOnError(ModuleConfig config) { Object stopOnErrorObj = pageContext.getAttribute( ValidatorPlugIn.STOP_ON_ERROR_KEY + '.' + config.getPrefix(), PageContext.APPLICATION_SCOPE); boolean stopOnError = true; if (stopOnErrorObj instanceof Boolean) { stopOnError = ((Boolean) stopOnErrorObj).booleanValue(); } return stopOnError; }
From source file:org.apache.struts.taglib.logic.TestIterateTag.java
/** * Testing <code>IterateTag</code> using name attribute in * the application scope.//from www .jav a 2s.c o m * * Tests the equivalent of this tag in a jsp: * <logic:iterate id="theId" name="testApplicationScopeNameIterateList" * scope="application"> * */ // ========= Application public void testApplicationScopeNameIterateList() throws ServletException, JspException, IOException { String testKey = "testApplicationScopeNameIterateList"; ArrayList lst = new ArrayList(); for (int i = 0; i < iterations; i++) { lst.add("test" + i); } pageContext.setAttribute(testKey, lst, PageContext.APPLICATION_SCOPE); IterateTag tag = new IterateTag(); tag.setPageContext(pageContext); tag.setId("theId"); tag.setName(testKey); tag.setScope("application"); int iteration = 0; tag.doStartTag(); tag.doInitBody(); do { out.print((String) pageContext.getAttribute("theId")); iteration++; } while (tag.doAfterBody() == tag.EVAL_BODY_TAG); tag.doEndTag(); assertEquals(iterations, iteration); }
From source file:org.apache.struts.taglib.logic.TestIterateTag.java
/** * Testing <code>IterateTag</code> using name attribute in * the application scope.//from ww w .j ava2s. c o m * * Tests the equivalent of this tag in a jsp: * <logic:iterate id="theId" name="testApplicationScopeNameIterateList" * property="list" scope="application"> * */ // ========= Application public void testApplicationScopePropertyIterateList() throws ServletException, JspException, IOException { String testKey = "testApplicationScopePropertyIterate"; ArrayList lst = new ArrayList(); for (int i = 0; i < iterations; i++) { lst.add("test" + i); } SimpleBeanForTesting sbft = new SimpleBeanForTesting(); sbft.setList(lst); pageContext.setAttribute(testKey, sbft, PageContext.APPLICATION_SCOPE); IterateTag tag = new IterateTag(); tag.setPageContext(pageContext); /* * Tests the equivalent of this tag in a jsp: * <logic:iterate id="theId" name="testApplicationScopePropertyIterate" * scope="application"> */ tag.setId("theId"); tag.setName(testKey); tag.setScope("application"); tag.setProperty("list"); int iteration = 0; tag.doStartTag(); tag.doInitBody(); do { out.print((String) pageContext.getAttribute("theId")); iteration++; } while (tag.doAfterBody() == tag.EVAL_BODY_TAG); tag.doEndTag(); assertEquals(iterations, iteration); }
From source file:org.apache.struts.taglib.logic.TestIterateTag.java
/** * Testing <code>IterateTag</code> using name attribute in * the application scope.//from w w w . java 2s .c o m * * Tests the equivalent of this tag in a jsp: * <logic:iterate id="theId" name="testApplicationScopeNameIterateEnumeration" * scope="application"> * */ // ========= Application public void testApplicationScopeNameIterateEnumeration() throws ServletException, JspException, IOException { String testKey = "testApplicationScopeNameIterateEnumeration"; StringTokenizer st = new StringTokenizer("Application Scope Name Iterate Enumeration"); pageContext.setAttribute(testKey, st, PageContext.APPLICATION_SCOPE); IterateTag tag = new IterateTag(); tag.setPageContext(pageContext); tag.setId("theId"); tag.setName(testKey); tag.setScope("application"); tag.doStartTag(); tag.doInitBody(); do { out.print((String) pageContext.getAttribute("theId")); } while (tag.doAfterBody() == tag.EVAL_BODY_TAG); tag.doEndTag(); }
From source file:org.apache.struts.taglib.logic.TestIterateTag.java
/** * Testing <code>IterateTag</code> using property attribute in * the application scope./*from w ww .j a v a 2 s .co m*/ * * Tests the equivalent of this tag in a jsp: * <logic:iterate id="theId" name="testApplicationScopePropertyIterateEnumeration" * scope="application"> * */ // ========= Application public void testApplicationScopePropertyIterateEnumeration() throws ServletException, JspException, IOException { String testKey = "testApplicationScopePropertyIterateEnumeration"; StringTokenizer st = new StringTokenizer("Application Scope Property Iterate Enumeration"); SimpleBeanForTesting sbft = new SimpleBeanForTesting(); sbft.setEnumeration(st); pageContext.setAttribute(testKey, sbft, PageContext.APPLICATION_SCOPE); IterateTag tag = new IterateTag(); tag.setPageContext(pageContext); tag.setId("theId"); tag.setName(testKey); tag.setScope("application"); tag.setProperty("enumeration"); tag.doStartTag(); tag.doInitBody(); do { out.print((String) pageContext.getAttribute("theId")); } while (tag.doAfterBody() == tag.EVAL_BODY_TAG); tag.doEndTag(); }
From source file:org.apache.struts.taglib.logic.TestIterateTag.java
/** * Testing <code>IterateTag</code> using name attribute in * the application scope.//from w ww . ja v a 2 s .c o m * * Tests the equivalent of this tag in a jsp: * <logic:iterate id="theId" name="testApplicationScopeNameIterateMap" * scope="application"> * */ // ========= Application public void testApplicationScopeNameIterateMap() throws ServletException, JspException, IOException { String testKey = "testApplicationScopeNameIterateMap"; HashMap map = new HashMap(); for (int i = 0; i < iterations; i++) { map.put("test" + i, "test" + i); } pageContext.setAttribute(testKey, map, PageContext.APPLICATION_SCOPE); IterateTag tag = new IterateTag(); tag.setPageContext(pageContext); tag.setId("theId"); tag.setName(testKey); tag.setScope("application"); int iteration = 0; tag.doStartTag(); tag.doInitBody(); do { out.print(pageContext.getAttribute("theId")); iteration++; } while (tag.doAfterBody() == tag.EVAL_BODY_TAG); tag.doEndTag(); assertEquals(iterations, iteration); }
From source file:org.apache.struts.taglib.logic.TestIterateTag.java
/** * Testing <code>IterateTag</code> using property attribute in * the application scope./*from ww w .ja v a 2 s. c o m*/ * * Tests the equivalent of this tag in a jsp: * <logic:iterate id="theId" name="testApplicationScopePropertyIterateMap" * scope="application"> * */ // ========= Application public void testApplicationScopePropertyIterateMap() throws ServletException, JspException, IOException { String testKey = "testApplicationScopePropertyIterateMap"; HashMap map = new HashMap(); for (int i = 0; i < iterations; i++) { map.put("test" + i, "test" + i); } SimpleBeanForTesting sbft = new SimpleBeanForTesting(); sbft.setMap(map); pageContext.setAttribute(testKey, sbft, PageContext.APPLICATION_SCOPE); IterateTag tag = new IterateTag(); tag.setPageContext(pageContext); tag.setId("theId"); tag.setName(testKey); tag.setScope("application"); tag.setProperty("map"); int iteration = 0; tag.doStartTag(); tag.doInitBody(); do { out.print(pageContext.getAttribute("theId")); iteration++; } while (tag.doAfterBody() == tag.EVAL_BODY_TAG); tag.doEndTag(); assertEquals(iterations, iteration); }