@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; }
/** * 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); }
/** * 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; }
/** * 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); } } }
@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); } }
/** * Exposes any bind status error messages under {@link #MESSAGES_ATTRIBUTE this key} * in the {@link PageContext#PAGE_SCOPE}. * <p>Only called if {@link #shouldRender()} returns {@code true}. * @see #removeAttributes() */ @Override protected void exposeAttributes() throws JspException { List<String> errorMessages = new ArrayList<>(); errorMessages.addAll(Arrays.asList(getBindStatus().getErrorMessages())); this.oldMessages = this.pageContext.getAttribute(MESSAGES_ATTRIBUTE, PageContext.PAGE_SCOPE); this.pageContext.setAttribute(MESSAGES_ATTRIBUTE, errorMessages, PageContext.PAGE_SCOPE); this.errorMessagesWereExposed = true; }
/** * 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); }
/** * Create and expose the current RequestContext. * Delegates to {@link #doStartTagInternal()} for actual work. * @see #REQUEST_CONTEXT_PAGE_ATTRIBUTE * @see org.springframework.web.servlet.support.JspAwareRequestContext */ @Override public final int doStartTag() throws JspException { try { this.requestContext = (RequestContext) this.pageContext.getAttribute(REQUEST_CONTEXT_PAGE_ATTRIBUTE); if (this.requestContext == null) { this.requestContext = new JspAwareRequestContext(this.pageContext); this.pageContext.setAttribute(REQUEST_CONTEXT_PAGE_ATTRIBUTE, this.requestContext); } return doStartTagInternal(); } catch (JspException | RuntimeException ex) { logger.error(ex.getMessage(), ex); throw ex; } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new JspTagException(ex.getMessage()); } }
@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 void exposeAttributes() throws JspException { Object value = resolveValue(); this.oldValue = this.pageContext.getAttribute(VALUE_VARIABLE_NAME); this.pageContext.setAttribute(VALUE_VARIABLE_NAME, value); this.oldDisplayValue = this.pageContext.getAttribute(DISPLAY_VALUE_VARIABLE_NAME); this.pageContext.setAttribute(DISPLAY_VALUE_VARIABLE_NAME, getDisplayString(value, getBindStatus().getEditor())); }
@Override public int doEndTag() throws JspException { EvaluationContext evaluationContext = (EvaluationContext) this.pageContext.getAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE); if (evaluationContext == null) { evaluationContext = createEvaluationContext(this.pageContext); this.pageContext.setAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE, evaluationContext); } if (this.var != null) { Object result = (this.expression != null ? this.expression.getValue(evaluationContext) : null); this.pageContext.setAttribute(this.var, result, this.scope); } else { try { String result = (this.expression != null ? this.expression.getValue(evaluationContext, String.class) : null); result = ObjectUtils.getDisplayString(result); result = htmlEscape(result); result = (this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(result) : result); this.pageContext.getOut().print(result); } catch (IOException ex) { throw new JspException(ex); } } return EVAL_PAGE; }
@Override public int doEndTag() throws JspException { String url = createUrl(); RequestDataValueProcessor processor = getRequestContext().getRequestDataValueProcessor(); ServletRequest request = this.pageContext.getRequest(); if ((processor != null) && (request instanceof HttpServletRequest)) { url = processor.processUrl((HttpServletRequest) request, url); } if (this.var == null) { // print the url to the writer try { this.pageContext.getOut().print(url); } catch (IOException ex) { throw new JspException(ex); } } else { // store the url as a variable this.pageContext.setAttribute(this.var, url, this.scope); } return EVAL_PAGE; }
/** * Clears the stored {@link TagWriter}. */ @Override public void doFinally() { super.doFinally(); this.pageContext.removeAttribute(MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE); 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); } this.tagWriter = null; this.previousNestedPath = null; }
@Override protected final int doStartTagInternal() throws ServletException, JspException { this.errors = getRequestContext().getErrors(this.name, isHtmlEscape()); if (this.errors != null && this.errors.hasErrors()) { this.pageContext.setAttribute(ERRORS_VARIABLE_NAME, this.errors, PageContext.REQUEST_SCOPE); return EVAL_BODY_INCLUDE; } else { return SKIP_BODY; } }
this.pageContext.setAttribute(this.var, result, TagUtils.getScope(this.scope));
@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 void exposeAttributes() throws JspException { Object value = resolveValue(); this.oldValue = this.pageContext.getAttribute(VALUE_VARIABLE_NAME); this.pageContext.setAttribute(VALUE_VARIABLE_NAME, value); this.oldDisplayValue = this.pageContext.getAttribute(DISPLAY_VALUE_VARIABLE_NAME); this.pageContext.setAttribute(DISPLAY_VALUE_VARIABLE_NAME, getDisplayString(value, getBindStatus().getEditor())); }
@Override protected final int doStartTagInternal() throws Exception { String resolvedPath = getPath(); if (!isIgnoreNestedPath()) { String nestedPath = (String) this.pageContext.getAttribute( NestedPathTag.NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE); // only prepend if not already an absolute path if (nestedPath != null && !resolvedPath.startsWith(nestedPath) && !resolvedPath.equals(nestedPath.substring(0, nestedPath.length() - 1))) { resolvedPath = nestedPath + resolvedPath; } } try { this.status = new BindStatus(getRequestContext(), resolvedPath, isHtmlEscape()); } catch (IllegalStateException ex) { throw new JspTagException(ex.getMessage()); } // Save previous status values, for re-exposure at the end of this tag. this.previousPageStatus = this.pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE); this.previousRequestStatus = this.pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE); // Expose this tag's status object as PageContext attribute, // making it available for JSP EL. this.pageContext.removeAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE); this.pageContext.setAttribute(STATUS_VARIABLE_NAME, this.status, PageContext.REQUEST_SCOPE); return EVAL_BODY_INCLUDE; }
@Override protected final int doStartTagInternal() throws ServletException, JspException { this.errors = getRequestContext().getErrors(this.name, isHtmlEscape()); if (this.errors != null && this.errors.hasErrors()) { this.pageContext.setAttribute(ERRORS_VARIABLE_NAME, this.errors, PageContext.REQUEST_SCOPE); return EVAL_BODY_INCLUDE; } else { return SKIP_BODY; } }
this.pageContext.setAttribute(this.var, msg, TagUtils.getScope(this.scope));