/** * Expose an array of header values. * @throws JspException * @since Struts 1.2 */ protected void handleMultipleHeaders() throws JspException { ArrayList values = new ArrayList(); Enumeration items = ((HttpServletRequest) pageContext.getRequest()).getHeaders(name); while (items.hasMoreElements()){ values.add(items.nextElement()); } if (values.isEmpty() && (this.value != null)){ values.add(this.value); } String headers[] = new String[values.size()]; if (headers.length == 0) { JspException e = new JspException(messages.getMessage("header.get", name)); TagUtils.getInstance().saveException(pageContext, e); throw e; } pageContext.setAttribute(id, values.toArray(headers)); }
/** * Process nested ≶putList> tag. * Method is called from nested ≶putList> tags. * Nested list is added to current list. * If role is defined, nested attribute is wrapped into an untyped definition * containing attribute value and role. */ public void processNestedTag(PutListTag nestedTag) throws JspException { // Get real value and check role // If role is set, add it in attribute definition if any. // If no attribute definition, create untyped one and set role. Object attributeValue = nestedTag.getList(); if (nestedTag.getRole() != null) { AttributeDefinition def = new UntypedAttribute(attributeValue); def.setRole(nestedTag.getRole()); attributeValue = def; } // Check if a name is defined if (nestedTag.getName() == null) { throw new JspException("Error - PutList : attribute name is not defined. It is mandatory as the list is added to a 'definition'."); } // now add attribute to enclosing parent (i.e. : this object). putAttribute(nestedTag.getName(), attributeValue); }
/** * Overriding method of the heart of the tag. Gets the relative property * and tells the JSP engine to evaluate its body content. * * @return int JSP continuation directive. */ public int doStartTag() throws JspException { // set the original property originalProperty = property; HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); String nesting = NestedPropertyHelper.getAdjustedProperty(request, property); if (id != null) { // use it as a scripting variable instead pageContext.setAttribute(id, nesting); } else { /* write output, filtering if required */ if (this.filter) { TagUtils.getInstance().write(pageContext, TagUtils.getInstance().filter(nesting)); } else { TagUtils.getInstance().write(pageContext, nesting); } } /* continue with page processing */ return (SKIP_BODY); }
/** * Retrieve format string from message bundle and return null if * message not found or message string. * * @param formatKey value to use as key to search message in bundle * @exception JspException if a JSP exception has occurred */ protected String retrieveFormatString(String formatKey) throws JspException { String result = TagUtils.getInstance().message( pageContext, this.bundle, this.localeKey, formatKey); if ((result != null) && !(result.startsWith("???") && result.endsWith("???"))) { return result; } else { return null; } }
/** * Overriding to allow the chance to set the details of the system, so that * dynamic includes can be possible * @return int JSP continuation directive. */ public int doStartTag() throws JspException { // store original result int temp = super.doStartTag(); HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); // original nesting details originalNesting = NestedPropertyHelper.getCurrentProperty(request); originalNestingName = NestedPropertyHelper.getCurrentName(request, this); // some new details NestedPropertyHelper.setProperty(request, null); NestedPropertyHelper.setName(request, super.getBeanName()); // continue return temp; }
/** Make sure tag is within a form */ public void otherDoStartTagOperations() { if (log.isDebugEnabled()) log.debug(this.NAME+".otherDoStartTagOperations: START"); try { super.otherDoStartTagOperations(); } catch (JspException e) { log.error(this.NAME+".otherDoStartTagOperations: error: " + e, e); } if (log.isDebugEnabled()) log.debug(this.NAME+".otherDoStartTagOperations: m_containsContent=" + m_containsContent); // Preprocess if within a Property widget lookupPropertyTag(); // Get the formtag from the page & register the widget FormTag formTag = TagHelper.getFormTag(pageContext); if(formTag == null) { String str = "The " + TAG_NAME + " should be inside a FormTag"; log.error(str); throw new OuterFormTagMissingRuntimeException(str); } }
/** * Expose a single header value. * @throws JspException * @since Struts 1.2 */ protected void handleSingleHeader() throws JspException { String value = ((HttpServletRequest) pageContext.getRequest()).getHeader(name); if ((value == null) && (this.value != null)) { value = this.value; } if (value == null) { JspException e = new JspException(messages.getMessage("header.get", name)); TagUtils.getInstance().saveException(pageContext, e); throw e; } pageContext.setAttribute(id, value); }
/** * Prepare the name element * @return The element name. */ protected String prepareName() throws JspException { if (property == null) { return null; } // * @since Struts 1.1 if(indexed) { StringBuffer results = new StringBuffer(); prepareIndex(results, name); results.append(property); return results.toString(); } return property; }
/** * Redirect to the given path converting exceptions to JspException. * @param path The path to redirect to. * @throws JspException * @since Struts 1.2 */ protected void doRedirect(String path) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); try { if (path.startsWith("/")) { path = request.getContextPath() + path; } response.sendRedirect(response.encodeRedirectURL(path)); } catch (Exception e) { TagUtils.getInstance().saveException(pageContext, e); throw new JspException( messages.getMessage("forward.redirect", name, e.toString())); } }
/** * Overriding method of the heart of the tag. Gets the relative property * and tells the JSP engine to evaluate its body content. * * @return int JSP continuation directive. */ public int doStartTag() throws JspException { /* set the nested reference for possible inclusions etc */ HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); // get al the originals originalName = name; originalNesting = NestedPropertyHelper.getCurrentProperty(request); originalNestingName = NestedPropertyHelper.getCurrentName(request, this); // set what we have to if (name != null) { NestedPropertyHelper.setProperty(request, ""); NestedPropertyHelper.setName(request, this.name); } // do the JSP thing return (EVAL_BODY_TAG); }
/** * Description of the Method * * @return * @exception JspException */ public int doStartTag() throws JspException { try { setupTag( pageContext ); MetadataVocabInputState inputState = (MetadataVocabInputState)pageContext.getSession().getAttribute( "MetadataVocabInputState" ); if ( inputState == null ) { inputState = new MetadataVocabInputState(); } if ( value != null ) { pageContext.getOut().print( vocab.getVocabCheckbox( group, value, label, inputState ) ); } else { pageContext.getOut().print( vocab.getVocabCheckboxes( system, group, wrap, tdWidth, skipTopRow, inputState ) ); } } catch ( java.io.IOException ex ) { throw new JspException( ex.getMessage() ); } return SKIP_BODY; }
/** * Try to process name as a definition, or as an URL if not found. * @param name Name to process. * @return appropriate TagHandler * @throws JspException InstantiationException Can't create requested controller */ public TagHandler processAsDefinitionOrURL(String name) throws JspException { try { ComponentDefinition definition = TilesUtil.getDefinition( name, pageContext.getRequest(), pageContext.getServletContext()); if (definition != null) { return processDefinition(definition); } } catch (DefinitionsFactoryException ex) { // silently failed, because we can choose to not define a factory. } // no definition found, try as url return processUrl(name); }
/** * This is only overriden to clean up the include reference * @return int JSP continuation directive. */ public int doEndTag() throws JspException { // super result int temp = super.doEndTag(); // all done. clean up HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); // reset the original nesting values if (originalNesting == null) { NestedPropertyHelper.deleteReference(request); } else { NestedPropertyHelper.setProperty(request, originalNesting); NestedPropertyHelper.setName(request, originalNestingName); } // return the super result return temp; }
/** * Render the end of this form. * * @exception JspException if a JSP exception has occurred */ public int doEndTag() throws JspException { // Remove the page scope attributes we created pageContext.removeAttribute(Constants.SELECT_KEY); // Render a tag representing the end of our current form StringBuffer results = new StringBuffer(); if (saveBody != null) { results.append(saveBody); saveBody = null; } results.append("</select>"); TagUtils.getInstance().write(pageContext, results.toString()); return (EVAL_PAGE); }
/** * Get scope value from string value * @param scopeName Scope as a String. * @param defaultValue Returned default value, if not found. * @return Scope as an <code>int</code>, or <code>defaultValue</code> if scope is <code>null</code>. * @throws JspException Scope name is not recognized as a valid scope. */ public static int getScope(String scopeName, int defaultValue) throws JspException { if (scopeName == null) { return defaultValue; } if (scopeName.equalsIgnoreCase("component")) { return ComponentConstants.COMPONENT_SCOPE; } else if (scopeName.equalsIgnoreCase("template")) { return ComponentConstants.COMPONENT_SCOPE; } else if (scopeName.equalsIgnoreCase("tile")) { return ComponentConstants.COMPONENT_SCOPE; } else { return org.apache.struts.taglib.TagUtils.getInstance().getScope( scopeName); } }
/** Returns a true if all the rows of the GridModel have not been iterated through. * @return a true if all the rows of the GridModel have not been iterated through. */ public boolean theBodyShouldBeEvaluatedAgain() throws JspException { if (m_modelIterator != null && m_modelIterator.hasNext() ) { m_currentRow = (GridModelRow) m_modelIterator.next(); setRowContext(); return true; } else { return false; } }
/** * Expose the requested attribute from component context. * * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { // Do a local copy of id String localId=this.id; if( localId==null ) localId=attributeName; ComponentContext compContext = (ComponentContext)pageContext.getAttribute( ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE); if( compContext == null ) throw new JspException ( "Error - tag useAttribute : no tiles context found." ); Object value = compContext.getAttribute(attributeName); // Check if value exists and if we must send a runtime exception if( value == null ) if(!isErrorIgnored) throw new JspException ( "Error - tag useAttribute : attribute '"+ attributeName + "' not found in context. Check tag syntax" ); else return SKIP_BODY; if( scopeName != null ) { scope = TagUtils.getScope( scopeName, PageContext.PAGE_SCOPE ); if(scope!=ComponentConstants.COMPONENT_SCOPE) pageContext.setAttribute(localId, value, scope); } else pageContext.setAttribute(localId, value); // Continue processing this page return SKIP_BODY; }
/** * Do end tag. */ public int doEndTag() throws JspException { // Call parent tag which in turn does what it want callParent(); // clean up tag handler for reuse. releaseInternal(); return EVAL_PAGE; }
@Override public void doTag() throws JspException, IOException { if (escapeHtml) { value = HtmlUtils.htmlEscape(value); } value = value.replaceAll("\n", "<br>"); getJspContext().getOut().write(value.toString()); }
/** * Render the resulting content evaluation. * * @return int JSP continuation directive. */ public int doAfterBody() throws JspException { /* Render the output */ if (bodyContent != null) { TagUtils.getInstance().writePrevious(pageContext, bodyContent.getString()); bodyContent.clearBody(); } return (SKIP_BODY); }
/** * Make the next collection element available and loop, or * finish the iterations if there are no more elements. * * @exception JspException if a JSP exception has occurred */ public int doAfterBody() throws JspException { // Render the output from this iteration to the output stream if (bodyContent != null) { TagUtils.getInstance().writePrevious(pageContext, bodyContent.getString()); bodyContent.clearBody(); } // Decide whether to iterate or quit if ((lengthValue > 0) && (lengthCount >= lengthValue)) { return (SKIP_BODY); } if (iterator.hasNext()) { Object element = iterator.next(); if (element == null) { pageContext.removeAttribute(id); } else { pageContext.setAttribute(id, element); } lengthCount++; if (indexId != null) { pageContext.setAttribute(indexId, new Integer(getIndex())); } return (EVAL_BODY_TAG); } else { return (SKIP_BODY); } }
/** * Retrieve the required property and expose it as a scripting variable. * * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { // Retrieve the required cookie value(s) ArrayList values = new ArrayList(); Cookie cookies[] = ((HttpServletRequest) pageContext.getRequest()).getCookies(); if (cookies == null) cookies = new Cookie[0]; for (int i = 0; i < cookies.length; i++) { if (name.equals(cookies[i].getName())) values.add(cookies[i]); } if ((values.size() < 1) && (value != null)) values.add(new Cookie(name, value)); if (values.size() < 1) { JspException e = new JspException (messages.getMessage("cookie.get", name)); TagUtils.getInstance().saveException(pageContext, e); throw e; } // Expose an appropriate variable containing these results if (multiple == null) { Cookie cookie = (Cookie) values.get(0); pageContext.setAttribute(id, cookie); } else { cookies = new Cookie[values.size()]; pageContext.setAttribute(id, values.toArray(cookies)); } return (SKIP_BODY); }
/** * Overriding method of the heart of the matter. Gets the relative property * and leaves the rest up to the original tag implementation. Sweet. * @return int JSP continuation directive. * This is in the hands of the super class. */ public int doStartTag() throws JspException { // get the original properties originalName = getName(); originalProperty = getProperty(); // request HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); // set the properties NestedPropertyHelper.setNestedProperties(request, this); // let the super do it's thing return super.doStartTag(); }
/** * Print the title card * @throws JspException jsp exception * @throws IOException io exception */ protected void printTitle() throws JspException, IOException { CardTitleTag cardTitleTag = new CardTitleTag(); cardTitleTag.setTitle(title); if (titleID != null) { cardTitleTag.setId(titleID); } if (titleColorCSS != null) { cardTitleTag.setCustomClasses(titleColorCSS); cardTitleTag.addAdditionalAttributeString(" style='color:white'"); } cardTitleTag.setParent(this); cardTitleTag.doTag(); }
@Override public int doAfterBody() throws JspException { try { String s = bodyOut.getString(); System.err.println(s); if (toBrowser) bodyOut.writeOut(bodyOut.getEnclosingWriter()); return SKIP_BODY; } catch (IOException ex) { throw new JspTagException(ex.toString()); } }
/** * Save the body contents of this tag as the constant that we will * be returning. * * @exception JspException if a JSP exception has occurred */ public int doAfterBody() throws JspException { if (bodyContent != null) { this.constant = bodyContent.getString().trim(); } if ("".equals(this.constant)) { this.constant = null; } return SKIP_BODY; }
@Override public void doTag() throws JspException, IOException { printContent("<meta charset=\"UTF-8\">"); printContent("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">"); printContent("<meta name=\"description\" content=\"Official Website of Sam\">"); printContent("<title>" + title +"</title>"); printContent("<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />"); printContent("<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/material-design-lite/1.3.0/material.deep_orange-red.min.css\" />"); printContent("<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" />"); printContent("<link rel=\"stylesheet\" href=\"/framework/css/base.css\" />"); printContent("<script defer src=\"https://cdnjs.cloudflare.com/ajax/libs/material-design-lite/1.3.0/material.min.js\"></script>"); printContent("<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>"); printContent("<link rel=\"shortcut icon\" href=\"/favicon.ico?v=2\" />"); }
/** * Complete the processing of the tag. The nested tags here will restore * all the original value for the tag itself and the nesting context. * @return int to describe the next step for the JSP processor * @throws JspException for the bad things JSP's do */ public int doEndTag() throws JspException { // do the super's ending part int i = super.doEndTag(); // reset the properties setName(origName); setProperty(origProperty); setParamProperty(origParamProperty); // continue return i; }
@Override public int doStartTag() throws JspException { try { fckEditor = new FCKeditor((HttpServletRequest) pageContext .getRequest(), instanceName, inputName); if (Utils.isNotEmpty(width)) fckEditor.setWidth(width); if (Utils.isNotEmpty(height)) fckEditor.setHeight(height); if (Utils.isNotEmpty(toolbarSet)) fckEditor.setToolbarSet(toolbarSet); if (Utils.isNotEmpty(value)) fckEditor.setValue(value); if (Utils.isNotEmpty(basePath)) fckEditor.setBasePath(basePath); } catch (Exception e) { throw new JspException(e); } return EVAL_BODY_INCLUDE; }
/** * This method is called when the JSP engine encounters the start tag, * after the attributes are processed. * Scripting variables (if any) have their values set here. * @return EVAL_BODY_TAG if the JSP engine should evaluate the tag body, otherwise return SKIP_BODY. * This method is automatically generated. Do not modify this method. * Instead, modify the methods that this method calls. * */ public int doStartTag() throws JspException { if(log.isDebugEnabled()) log.debug(this.NAME + ".doStartTag() - From CustomTag.doStartTag()"); otherDoStartTagOperations(); if (theBodyShouldBeEvaluated()) { if(IBodyTag.class.isInstance(this)) // See if we are evaluating the body return EVAL_BODY_BUFFERED; else return EVAL_BODY_INCLUDE; } else { return SKIP_BODY; } }
@Override public int doAfterBody() throws JspException { try { if (i == 3) { bodyOut.writeOut(bodyOut.getEnclosingWriter()); return SKIP_BODY; } pageContext.setAttribute("member", atts[i]); i++; return EVAL_BODY_BUFFERED; } catch (IOException ex) { throw new JspTagException(ex.toString()); } }
public int doStartTag() throws JspException { boolean authorized = getPermissionChecker().isAuthorized(permission); if (!authorized) { return Tag.SKIP_BODY; } return Tag.EVAL_BODY_INCLUDE; }
/** * Process the end tag by including the template. * Simply call the handler doEndTag */ public int doEndTag() throws JspException { if (!processEndTag) { releaseInternal(); return EVAL_PAGE; } int res = tagHandler.doEndTag(); // Reset properties used by object, in order to be able to reuse object. releaseInternal(); return res; }
/** .//GEN-BEGIN:doStartTag * * This method is called when the JSP engine encounters the start tag, * after the attributes are processed. * Scripting variables (if any) have their values set here. * @return EVAL_BODY_BUFFERED if the JSP engine should evaluate the tag body, otherwise return SKIP_BODY. * This method is automatically generated. Do not modify this method. * Instead, modify the methods that this method calls. * @throws JspException */ public int doStartTag() throws JspException { otherDoStartTagOperations(); if (theBodyShouldBeEvaluated()) { return EVAL_BODY_BUFFERED; } else { return SKIP_BODY; } }
/** * Overriding method of the heart of the matter. Gets the relative property * and leaves the rest up to the original tag implementation. Sweet. * @return int JSP continuation directive. * This is in the hands of the super class. */ public int doStartTag() throws JspException { // original values originalName = getName(); originalProperty = getProperty(); // set the ID to make the super tag happy if (id == null || id.trim().length() == 0) { id = property; } // the request object HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); // original nesting details originalNesting = NestedPropertyHelper.getCurrentProperty(request); originalNestingName = NestedPropertyHelper.getCurrentName(request, this); // set the bean if it's been provided // (the bean that's been provided! get it!?... nevermind) if (getName() == null) { // the qualified nesting value nesting = NestedPropertyHelper.getAdjustedProperty(request, getProperty()); } else { // it's just the property nesting = getProperty(); } // set the properties NestedPropertyHelper.setNestedProperties(request, this); // get the original result int temp = super.doStartTag(); // set the new reference (including the index etc) NestedPropertyHelper.setName(request, getName()); NestedPropertyHelper.setProperty(request, deriveNestedProperty()); // return the result return temp; }
/** * Complete the processing of the tag. The nested tags here will restore * all the original value for the tag itself and the nesting context. * @return int to describe the next step for the JSP processor * @throws JspException for the bad things JSP's do */ public int doEndTag() throws JspException { // do the super's ending part int i = super.doEndTag(); // reset the properties setName(originalName); setProperty(originalProperty); // continue return i; }
/** * Process a bean. * Get bean value, eventually using property and scope. Found value is process by processObjectValue(). * @param beanName Name of the bean * @param beanProperty Property in the bean, or null. * @param beanScope bean scope, or null. * @return Appropriate TagHandler. * @throws JspException - NoSuchDefinitionException No value associated to bean. * @throws JspException an error occur while reading bean, or no definition found. * @throws JspException - Throws by underlying nested call to processDefinitionName() */ protected TagHandler processBean( String beanName, String beanProperty, String beanScope) throws JspException { Object beanValue = TagUtils.getRealValueFromBean( beanName, beanProperty, beanScope, pageContext); if (beanValue == null) { throw new JspException( "Error - Tag Insert : No value defined for bean '" + beanName + "' with property '" + beanProperty + "' in scope '" + beanScope + "'."); } return processObjectValue(beanValue); }
/** * Gets the next available tag handler from this tag handler pool, * instantiating one if this tag handler pool is empty. * * @param handlerClass Tag handler class * * @return Reused or newly instantiated tag handler * * @throws JspException if a tag handler cannot be instantiated */ @Override public Tag get(Class<? extends Tag> handlerClass) throws JspException { PerThreadData ptd = perThread.get(); if(ptd.current >=0 ) { return ptd.handlers[ptd.current--]; } else { try { return handlerClass.newInstance(); } catch (Exception e) { throw new JspException(e.getMessage(), e); } } }
/** * This is only overriden as the include reference will need it's index * updated. * * @return int JSP continuation directive. */ public int doAfterBody() throws JspException { // store original result int temp = super.doAfterBody(); HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); if (temp != SKIP_BODY) { // set the new reference NestedPropertyHelper.setProperty(request, deriveNestedProperty()); } // return super result return temp; }