struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dge...@apache.org
Subject cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/template/util Content.java ContentMap.java
Date Tue, 16 Jan 2001 23:48:41 GMT
dgeary      01/01/16 15:48:41

  Modified:    src/doc  struts-template.xml
               src/share/org/apache/struts/taglib/template GetTag.java
                        PutTag.java
               src/share/org/apache/struts/taglib/template/util
                        Content.java ContentMap.java
  Log:
  Made Content and ContentMap serializable and added support for template roles
  
  Revision  Changes    Path
  1.4       +20 -0     jakarta-struts/src/doc/struts-template.xml
  
  Index: struts-template.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/doc/struts-template.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- struts-template.xml	2000/12/16 19:00:05	1.3
  +++ struts-template.xml	2001/01/16 23:48:40	1.4
  @@ -75,6 +75,16 @@
       </attribute>
   
       <attribute>
  +      <name>role</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +      <info>
  +      If the user is in the specified role, the content is stored for
  +      subsequent access by the get tag; otherwise, the content is ignored.
  +      </info>
  +    </attribute>
  +
  +    <attribute>
         <name>content</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
  @@ -115,6 +125,16 @@
         <rtexprvalue>true</rtexprvalue>
         <info>
         The name of the content to get from request scope.
  +      </info>
  +    </attribute>
  +
  +    <attribute>
  +      <name>role</name>
  +      <required>false</required>
  +      <rtexprvalue>true</rtexprvalue>
  +      <info>
  +      If the user is in the specified role, the content is retrieved,
  +      otherwise, the content is ignored.
         </info>
       </attribute>
   
  
  
  
  1.4       +27 -7     jakarta-struts/src/share/org/apache/struts/taglib/template/GetTag.java
  
  Index: GetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/GetTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GetTag.java	2000/10/12 23:05:21	1.3
  +++ GetTag.java	2001/01/16 23:48:41	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/GetTag.java,v
1.3 2000/10/12 23:05:21 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/10/12 23:05:21 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/GetTag.java,v
1.4 2001/01/16 23:48:41 dgeary Exp $
  + * $Revision: 1.4 $
  + * $Date: 2001/01/16 23:48:41 $
    *
    * ====================================================================
    *
  @@ -62,6 +62,7 @@
   
   import java.util.Hashtable;
   import java.util.Stack;
  +import javax.servlet.http.HttpServletRequest;
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.TagSupport;
  @@ -74,7 +75,7 @@
    * it, depending upon the value of the content's direct attribute.
    *
    * @author David Geary
  - * @version $Revision: 1.3 $ $Date: 2000/10/12 23:05:21 $
  + * @version $Revision: 1.4 $ $Date: 2001/01/16 23:48:41 $
    */
   public class GetTag extends TagSupport {
   
  @@ -86,9 +87,13 @@
        */
      private String name;
   
  +   /**
  +     * The role that the user must be in to retrieve content.
  +     */
  +   private String role;
   
      /**
  -     * 
  +     * Set the name attribute
        * @param name The name of the content to get.
        */
      public void setName(String name) {
  @@ -97,6 +102,16 @@
   
      }
   
  +   /**
  +     * Set the role attribute
  +     * @param name The role the user must be in to retrieve content.
  +     */
  +   public void setRole(String role) {
  +
  +      this.role = role;
  +
  +   }
  +
   // --------------------------------------------------------- Public Methods
   
      /**
  @@ -105,9 +120,14 @@
        */
      public int doStartTag() throws JspException {
   
  +      HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
  +   	
  +      if(role != null && !request.isUserInRole(role))
  +      	return SKIP_BODY;
  +
         ContentMap map = ContentMapStack.peek(pageContext);
         Content content = map.get(name);
  -      
  +
         if(content != null) {
            if(content.isDirect()) {
               try {
  @@ -141,7 +161,7 @@
        */
      public void release() {
   
  -      name = null;
  +      name = role = null;
   
      }
   
  
  
  
  1.6       +25 -6     jakarta-struts/src/share/org/apache/struts/taglib/template/PutTag.java
  
  Index: PutTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/PutTag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PutTag.java	2001/01/12 19:29:42	1.5
  +++ PutTag.java	2001/01/16 23:48:41	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/PutTag.java,v
1.5 2001/01/12 19:29:42 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/01/12 19:29:42 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/PutTag.java,v
1.6 2001/01/16 23:48:41 dgeary Exp $
  + * $Revision: 1.6 $
  + * $Date: 2001/01/16 23:48:41 $
    *
    * ====================================================================
    *
  @@ -62,6 +62,7 @@
   
   import java.util.Hashtable;
   import java.util.Stack;
  +import javax.servlet.http.HttpServletRequest;
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.BodyTagSupport;
  @@ -73,7 +74,7 @@
    * Tag handler for &lt;template:put&gt;, which puts content into request scope.
    *
    * @author David Geary
  - * @version $Revision: 1.5 $ $Date: 2001/01/12 19:29:42 $
  + * @version $Revision: 1.6 $ $Date: 2001/01/16 23:48:41 $
    */
   public class PutTag extends BodyTagSupport {
   
  @@ -85,6 +86,10 @@
        */
      private String name;
   
  +   /**
  +     * The role that the user must be in to store content.
  +     */
  +   private String role;
   
      /**
        * The content's URI (or text).
  @@ -110,6 +115,15 @@
   
      }
   
  +   /**
  +     * 
  +     * @param name The role the user must be in to store content.
  +     */
  +   public void setRole(String role) {
  +
  +      this.role = role;
  +
  +   }
   
      /**
        * Set the content's URI (if it's to be included) or text (if it's to
  @@ -142,11 +156,16 @@
        */
      public int doEndTag() throws JspException {
   
  +      HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
  +   	
  +      if(role != null && !request.isUserInRole(role))
  +      	return EVAL_PAGE;
  +
         InsertTag insertTag = (InsertTag)getAncestor(
                                 "org.apache.struts.taglib.template.InsertTag");
   
         if(insertTag == null)
  -         throw new JspException("PutTag.doStartTag(): " +
  +         throw new JspException("PutTag.doEndTag(): " +
                                   "No InsertTag ancestor");
   
         insertTag.put(name, new Content(getContent(), getDirect()));
  @@ -161,7 +180,7 @@
        */
      public void release() {
   
  -      name = content = direct = null;
  +      name = content = direct = role = null;
   
      }
   
  
  
  
  1.2       +4 -4      jakarta-struts/src/share/org/apache/struts/taglib/template/util/Content.java
  
  Index: Content.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/util/Content.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Content.java	2000/10/08 01:17:40	1.1
  +++ Content.java	2001/01/16 23:48:41	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/util/Content.java,v
1.1 2000/10/08 01:17:40 dgeary Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/10/08 01:17:40 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/util/Content.java,v
1.2 2001/01/16 23:48:41 dgeary Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/01/16 23:48:41 $
    *
    * ====================================================================
    *
  @@ -76,9 +76,9 @@
    *  </p>
    *
    * @author David Geary
  - * @revision $Revision: 1.1 $
  + * @revision $Revision: 1.2 $
    */
  -public class Content {
  +public class Content implements java.io.Serializable {
   
   // ----------------------------------------------------- Instance Variables
   
  
  
  
  1.2       +5 -5      jakarta-struts/src/share/org/apache/struts/taglib/template/util/ContentMap.java
  
  Index: ContentMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/util/ContentMap.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContentMap.java	2000/10/08 01:17:40	1.1
  +++ ContentMap.java	2001/01/16 23:48:41	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/util/ContentMap.java,v
1.1 2000/10/08 01:17:40 dgeary Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/10/08 01:17:40 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/util/ContentMap.java,v
1.2 2001/01/16 23:48:41 dgeary Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/01/16 23:48:41 $
    *
    * ====================================================================
    *
  @@ -67,9 +67,9 @@
    * that can be performed on a hash map of contents. 
    *
    * @author David Geary
  - * @version $Revision: 1.1 $ $Date: 2000/10/08 01:17:40 $
  + * @version $Revision: 1.2 $ $Date: 2001/01/16 23:48:41 $
    */
  -public class ContentMap {
  +public class ContentMap implements java.io.Serializable {
   
   
   // ------------------------------------------------------------ Construtors
  
  
  

Mime
View raw message