/** * Get the next unique ID (within the given {@link PageContext}) for the supplied name. */ public static String nextId(String name, PageContext pageContext) { String attributeName = PAGE_CONTEXT_ATTRIBUTE_PREFIX + name; Integer currentCount = (Integer) pageContext.getAttribute(attributeName); currentCount = (currentCount != null ? currentCount + 1 : 1); pageContext.setAttribute(attributeName, currentCount); return (name + currentCount); }
@Override public int doEndTag() { this.pageContext.removeAttribute(ERRORS_VARIABLE_NAME, PageContext.REQUEST_SCOPE); return EVAL_PAGE; }
public JspPropertyAccessor(PageContext pageContext) { this.pageContext = pageContext; this.variableResolver = pageContext.getVariableResolver(); }
/** * Create a new JspAwareRequestContext for the given page context, * using the given model attributes for Errors retrieval. * @param pageContext current JSP page context * @param model the model attributes for the current view * (can be {@code null}, using the request attributes for Errors retrieval) */ public JspAwareRequestContext(PageContext pageContext, @Nullable Map<String, Object> model) { super((HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse(), pageContext.getServletContext(), model); this.pageContext = pageContext; }
/** * Reset any previous nestedPath value. */ @Override public int doEndTag() { if (this.previousNestedPath != null) { // Expose previous nestedPath value. this.pageContext.setAttribute(NESTED_PATH_VARIABLE_NAME, this.previousNestedPath, PageContext.REQUEST_SCOPE); } else { // Remove exposed nestedPath value. this.pageContext.removeAttribute(NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE); } return EVAL_PAGE; }
/** * The user customised the output of the error messages - flush the * buffered content into the main {@link javax.servlet.jsp.JspWriter}. */ protected void flushBufferedBodyContent(BodyContent bodyContent) throws JspException { try { bodyContent.writeOut(bodyContent.getEnclosingWriter()); } catch (IOException ex) { throw new JspException("Unable to write buffered body content.", ex); } }
@Override protected BindStatus getBindStatus() { return (BindStatus) this.pageContext.getAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE); }
public AttributeEvaluator createEvaluator() { ELAttributeEvaluator evaluator = new ELAttributeEvaluator(); evaluator.setExpressionFactory( JspFactory.getDefaultFactory().getJspApplicationContext(servletContext).getExpressionFactory()); evaluator.setResolver(new CompositeELResolverImpl()); return evaluator; } }
@Override public void print(boolean value) throws IOException { getEnclosingWriter().print(value); }
@Override public void clearBuffer() throws IOException { getEnclosingWriter().clearBuffer(); }
@Override public void println(boolean value) throws IOException { getEnclosingWriter().println(value); }
@Override public int doEndTag() { // Reset previous status values. if (this.previousPageStatus != null) { this.pageContext.setAttribute(STATUS_VARIABLE_NAME, this.previousPageStatus, PageContext.PAGE_SCOPE); } if (this.previousRequestStatus != null) { this.pageContext.setAttribute(STATUS_VARIABLE_NAME, this.previousRequestStatus, PageContext.REQUEST_SCOPE); } else { this.pageContext.removeAttribute(STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE); } return EVAL_PAGE; }
@Override public int doStartTag() throws JspException { // Save previous nestedPath value, build and expose current nestedPath value. // Use request scope to expose nestedPath to included pages too. this.previousNestedPath = (String) this.pageContext.getAttribute(NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE); String nestedPath = (this.previousNestedPath != null ? this.previousNestedPath + getPath() : getPath()); this.pageContext.setAttribute(NESTED_PATH_VARIABLE_NAME, nestedPath, PageContext.REQUEST_SCOPE); return EVAL_BODY_INCLUDE; }
@Override protected BindStatus getBindStatus() { return (BindStatus) this.pageContext.getAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE); }
/** * Clears the {@link TagWriter} that might have been left over when using * nested {@link OptionTag options}. */ @Override public void doFinally() { super.doFinally(); this.tagWriter = null; this.pageContext.removeAttribute(LIST_VALUE_PAGE_ATTRIBUTE); }
/** * Removes any bind status error messages that were previously stored under * {@link #MESSAGES_ATTRIBUTE this key} in the {@link PageContext#PAGE_SCOPE}. * @see #exposeAttributes() */ @Override protected void removeAttributes() { if (this.errorMessagesWereExposed) { if (this.oldMessages != null) { this.pageContext.setAttribute(MESSAGES_ATTRIBUTE, this.oldMessages, PageContext.PAGE_SCOPE); this.oldMessages = null; } else { this.pageContext.removeAttribute(MESSAGES_ATTRIBUTE, PageContext.PAGE_SCOPE); } } }
/** * Get the value of the nested path that may have been exposed by the * {@link NestedPathTag}. */ @Nullable protected String getNestedPath() { return (String) this.pageContext.getAttribute(NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE); }
@Override protected void removeAttributes() { if (this.oldValue != null) { this.pageContext.setAttribute(VALUE_ATTRIBUTE, this.oldValue); this.oldValue = null; } else { this.pageContext.removeAttribute(VALUE_VARIABLE_NAME); } if (this.oldDisplayValue != null) { this.pageContext.setAttribute(DISPLAY_VALUE_VARIABLE_NAME, this.oldDisplayValue); this.oldDisplayValue = null; } else { this.pageContext.removeAttribute(DISPLAY_VALUE_VARIABLE_NAME); } }
@Override protected void renderDefaultContent(TagWriter tagWriter) throws JspException { Object value = this.pageContext.getAttribute(VALUE_VARIABLE_NAME); String label = getLabelValue(value); renderOption(value, label, tagWriter); }