You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Paul Benedict (JIRA)" <ji...@apache.org> on 2007/09/01 06:11:34 UTC

[jira] Closed: (STR-2250) [tiles] PresentTag

     [ https://issues.apache.org/struts/browse/STR-2250?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict closed STR-2250.
------------------------------

    Resolution: Incomplete
      Assignee:     (was: Struts Developers)

> [tiles] PresentTag
> ------------------
>
>                 Key: STR-2250
>                 URL: https://issues.apache.org/struts/browse/STR-2250
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Taglibs
>    Affects Versions: Future
>         Environment: Operating System: All
> Platform: All
>            Reporter: Levieux Cedric
>            Priority: Minor
>
> package org.jdt.common.tags.tilesextended;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.jsp.JspException;
> import javax.servlet.jsp.PageContext;
> import javax.servlet.jsp.tagext.TagSupport;
> import org.apache.struts.taglib.tiles.ComponentConstants;
> import org.apache.struts.tiles.ComponentContext;
> /**
>  * Render the body only if the specified component/template attribute property
>  * id present.
>  */
> public class PresentTag extends TagSupport implements ComponentConstants
> {
>     private String attribute = null;
>     /** Role attribute */
>     private String role = null;
>     /**
>      * Default constructor.
>      */
>     public PresentTag()
>     {
>         super();
>     }
>     /**
>      * Release all allocated resources.
>      */
>     public void release()
>     {
>         super.release();
>         attribute = null;
>         role = null;
>     }
>     /**
>      * Set attribute.
>      * 
>      * @param attribute
>      *            Attribute.
>      */
>     public void setAttribute(String attribute)
>     {
>         this.attribute = attribute;
>     }
>     /**
>      * Get attribute.
>      * 
>      * @return Attribute.
>      */
>     public String getAttribute()
>     {
>         return attribute;
>     }
>     /**
>      * Set Name. Same as setAttribute().
>      * 
>      * @param value
>      *            Attribute.
>      */
>     public void setName(String value)
>     {
>         this.attribute = value;
>     }
>     /**
>      * Get Name. Set as getAttribute().
>      * 
>      * @return Attribute.
>      */
>     public String getName()
>     {
>         return attribute;
>     }
>     /**
>      * Set role.
>      * 
>      * @param role
>      *            The role the user must be in to store content.
>      */
>     public void setRole(String role)
>     {
>         this.role = role;
>     }
>     /**
>      * Get role.
>      * 
>      * @return Role.
>      */
>     public String getRole()
>     {
>         return role;
>     }
>     /**
>      * Perform the test required for this particular tag, and either evaluate or
>      * skip the body of this tag.
>      * 
>      * @exception JspException
>      *                if a JSP exception occurs
>      */
>     public int doStartTag() throws JspException
>     {
>         // Check role
>         if (role != null
>                 && !((HttpServletRequest) pageContext.getRequest())
>                         .isUserInRole(role))
>         {
>             return SKIP_BODY;
>         } // end if
>         // Get context
>         ComponentContext compContext = (ComponentContext) pageContext
>                 .getAttribute(ComponentConstants.COMPONENT_CONTEXT,
>                         PageContext.REQUEST_SCOPE);
>         if (compContext == null)
>                 throw new JspException(
>                         "Error - tag.present : component context is not defined.
> Check tag syntax");
>         Object value = compContext.getAttribute(attribute);
>         // The value is not null so present
>         if (value != null) return (EVAL_BODY_INCLUDE);
>         return (SKIP_BODY);
>     }
>     /**
>      * Evaluate the remainder of the current page normally.
>      * 
>      * @exception JspException
>      *                if a JSP exception occurs
>      */
>     public int doEndTag() throws JspException
>     {
>         return (EVAL_PAGE);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.