You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2001/02/08 00:10:48 UTC

cvs commit: jakarta-struts/web/example index.jsp

craigmcc    01/02/07 15:10:48

  Modified:    src/doc  struts-html.xml
               src/share/org/apache/struts/taglib/html ImgTag.java
                        LocalStrings.properties
               web/example index.jsp
  Log:
  Add a "page" attribute to the <html:img> tag that can be used, instead of the
  "src" attribute, to specify a context-relative path to the image resource to
  be rendered.  The tag will automatically prepend the context path of this web
  application to the rendered URL, in a manner analogous to the way that the
  "page" attribute on the <html:link> tag works.
  
  Revision  Changes    Path
  1.6       +70 -59    jakarta-struts/src/doc/struts-html.xml
  
  Index: struts-html.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/doc/struts-html.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- struts-html.xml	2001/01/28 03:48:02	1.5
  +++ struts-html.xml	2001/02/07 23:10:42	1.6
  @@ -1402,15 +1402,19 @@
                   <p>Renders an HTML <code>&lt;img&gt;</code> element with
                   the image at the specified URL.  Like the link tag, URL
                   rewriting will be applied automatically to the value
  -                specified in <code>src</code>, to maintain session state
  +                specified in <code>src</code> or <code>page</code>,
  +                to maintain session state
                   in the absence of cookies.  This will allow dynamic
                   generation of an image where the content displayed for this
                   image will be taken from the attributes of this tag.</p>
   
                   <p>The base URL for this image is calculated based on
  -                the value specified in <code>src</code>.</p>
  +                the value specified in <code>src</code> or <code>page</code>.
  +                You <strong>must</strong> specify exactly one of these
  +                attributes.</p>
   
  -                <p>Normally, the <code>src</code> you specify will be left
  +                <p>Normally, the <code>src</code> or <code>page</code> that
  +                you specify will be left
                   unchanged (other than URL rewriting if necessary).  However,
                   there are two ways you can append one or more dynamically
                   defined query parameters to the <code>src</code> URL --
  @@ -1521,18 +1525,6 @@
                   </attribute>
   
                   <attribute>
  -                  <name>imageName</name>
  -                  <required>false</required>
  -                  <rtexprvalue>true</rtexprvalue>
  -                  <info>
  -                  <p>The scriptable name to be defined within this page, so 
  -                  that
you can reference it with intra-page scripts.  In other
  -                  words, the value specified here will render a "name" element
  -                  in the generated image tag.</p>
  -                  </info>
  -                </attribute>
  -
  -                <attribute>
                     <name>height</name>
                     <required>false</required>
                     <rtexprvalue>true</rtexprvalue>
  @@ -1600,50 +1592,6 @@
                   </attribute>
   
                   <attribute>
  -                  <name>src</name>
  -                  <required>true</required>
  -                  <rtexprvalue>true</rtexprvalue>
  -                  <info>
  -                  <p>The URL to which this image will be transferred from
  -                  This image may be dynamically modified
  -                  by the inclusion of query parameters, as described in the
  -                  tag description.  You <strong>must</strong> specify
  -                  the <code>src</code> attribute.</p>
  -                  </info>
  -                </attribute>
  -
  -                <attribute>
  -                  <name>usemap</name>
  -                  <required>false</required>
  -                  <rtexprvalue>true</rtexprvalue>
  -                  <info>
  -                  <p>The name of the map as defined within this page for
  -                     mapping hot-spot areas of this image.</p>
  -                  </info>
  -                </attribute>
  -
  -                <attribute>
  -                  <name>vspace</name>
  -                  <required>false</required>
  -                  <rtexprvalue>true</rtexprvalue>
  -                  <info>
  -                  <p>The amount of vertical spacing between the icon and
  -                     the text, above and below.</p>
  -                  </info>
  -                </attribute>
  -
  -                <attribute>
  -                  <name>width</name>
  -                  <required>false</required>
  -                  <rtexprvalue>true</rtexprvalue>
  -                  <info>
  -                  <p>The width of the image being displayed.  This parameter
  -                     is very nice to specificy (along with <code>height</code>)
  -                     to help the browser render the page faster.</p>
  -                  </info>
  -                </attribute>
  -
  -                <attribute>
                     <name>onkeydown</name>
                     <required>false</required>
                     <rtexprvalue>true</rtexprvalue>
  @@ -1687,6 +1635,22 @@
                   </attribute>
   
                   <attribute>
  +                  <name>page</name>
  +                  <required>false</required>
  +                  <rtexprvalue>true</rtexprvalue>
  +                  <info>
  +                  <p>The context-relative path, starting with a slash, of
  +                  the image to be displayed by this tag.  The rendered
  +                  URL for this image will automatically prepend the context
  +                  path of this web application (in the same manner as the
  +                  <code>page</code> attribute on the link tag works),
  +                  in addition to any necessary URL rewriting.  You
  +                  <strong>must</strong> specify either the <code>page</code>
  +                  attribute or the <code>src</code> attribute.</p>
  +                  </info>
  +                </attribute>
  +
  +                <attribute>
                     <name>paramName</name>
                     <required>false</required>
                     <rtexprvalue>true</rtexprvalue>
  @@ -1751,6 +1715,22 @@
                   </attribute>
   
                   <attribute>
  +                  <name>src</name>
  +                  <required>false</required>
  +                  <rtexprvalue>true</rtexprvalue>
  +                  <info>
  +                  <p>The URL to which this image will be transferred from
  +                  This image may be dynamically modified
  +                  by the inclusion of query parameters, as described in the
  +                  tag description.  This value will be used unmodified (other
  +                  than potential URL rewriting) as the value of the "src"
  +                  attribute in the rendered tag.  You <strong>must</strong>
  +                  specify either the <code>page</code> attribute or the
  +                  the <code>src</code> attribute.</p>
  +                  </info>
  +                </attribute>
  +
  +                <attribute>
                     <name>style</name>
                     <required>false</required>
                     <rtexprvalue>true</rtexprvalue>
  @@ -1765,6 +1745,37 @@
                     <rtexprvalue>true</rtexprvalue>
                     <info>
                     <p>CSS stylesheet class to be applied to this element.</p>
  +                  </info>
  +                </attribute>
  +
  +                <attribute>
  +                  <name>usemap</name>
  +                  <required>false</required>
  +                  <rtexprvalue>true</rtexprvalue>
  +                  <info>
  +                  <p>The name of the map as defined within this page for
  +                     mapping hot-spot areas of this image.</p>
  +                  </info>
  +                </attribute>
  +
  +                <attribute>
  +                  <name>vspace</name>
  +                  <required>false</required>
  +                  <rtexprvalue>true</rtexprvalue>
  +                  <info>
  +                  <p>The amount of vertical spacing between the icon and
  +                     the text, above and below.</p>
  +                  </info>
  +                </attribute>
  +
  +                <attribute>
  +                  <name>width</name>
  +                  <required>false</required>
  +                  <rtexprvalue>true</rtexprvalue>
  +                  <info>
  +                  <p>The width of the image being displayed.  This parameter
  +                     is very nice to specificy (along with <code>height</code>)
  +                     to help the browser render the page faster.</p>
                     </info>
                   </attribute>
   
  
  
  
  1.3       +34 -5     jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java
  
  Index: ImgTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ImgTag.java	2001/01/31 22:00:16	1.2
  +++ ImgTag.java	2001/02/07 23:10:44	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java,v 1.2 2001/01/31 22:00:16 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/01/31 22:00:16 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java,v 1.3 2001/02/07 23:10:44 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/02/07 23:10:44 $
    *
    * ====================================================================
    *
  @@ -95,7 +95,7 @@
    *
    * @author Michael Westbay
    * @author Craig McClanahan
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   
   public class ImgTag extends BaseHandlerTag {
  @@ -239,6 +239,21 @@
   
   
       /**
  +     * The context-relative path, starting with a slash character, of the
  +     * image to be displayed by this rendered tag.
  +     */
  +    protected String page = null;
  +
  +    public String getPage() {
  +        return (this.page);
  +    }
  +
  +    public void setPage(String page) {
  +        this.page = page;
  +    }
  +
  +
  +    /**
        * In situations where an image is dynamically generated (such as to create
        * a chart graph), this specifies the single-parameter request parameter
        * name to generate.
  @@ -404,10 +419,23 @@
       public int doEndTag() throws JspException {
   
   	// Generate the name definition or image element
  +        HttpServletRequest request =
  +	  (HttpServletRequest) pageContext.getRequest();
   	HttpServletResponse response =
   	  (HttpServletResponse) pageContext.getResponse();
   	StringBuffer results = new StringBuffer("<img");
  -        String srcurl = url(this.src);
  +	String srcurl = null;
  +	if (this.src != null)
  +	    srcurl = url(this.src);
  +	else if (this.page != null)
  +	    srcurl = url(request.getContextPath() + this.page);
  +	else {
  +	    JspException e = new JspException
  +	      (messages.getMessage("imgTag.source"));
  +	    pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +				     PageContext.REQUEST_SCOPE);
  +	    throw e;
  +	}
           String lowsrcurl = url(this.lowsrc);
           if (srcurl != null) {
               results.append(" src=\"");
  @@ -503,6 +531,7 @@
           ismap = null;
           lowsrc = null;
   	name = null;
  +        page = null;
           paramId = null;
           paramName = null;
           paramProperty = null;
  
  
  
  1.4       +1 -0      jakarta-struts/src/share/org/apache/struts/taglib/html/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LocalStrings.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LocalStrings.properties	2001/01/28 03:48:03	1.3
  +++ LocalStrings.properties	2001/02/07 23:10:44	1.4
  @@ -14,6 +14,7 @@
   getter.name=You must specify a name attribute if the property attribute is present
   getter.property=Property {0} returned a null value
   getter.result=Getter for property {0} threw exception: {1}
  +imgTag.source=You must specify either page or src
   imgTag.type=Object must be of type Map
   includeTag.include=Error including page {0}: {1}
   includeTag.lookup=Cannot find global forward named {0}
  
  
  
  1.15      +1 -1      jakarta-struts/web/example/index.jsp
  
  Index: index.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/example/index.jsp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- index.jsp	2001/01/28 03:48:03	1.14
  +++ index.jsp	2001/02/07 23:10:47	1.15
  @@ -34,7 +34,7 @@
   <p>&nbsp;</p>
   <p><a target="_blank" href="tour.htm"><font size="1">A Walking Tour of the Example Application</font></a></p>
   
  -<html:img src="struts-power.gif" alt="Powered by Struts"/>
  +<html:img page="/struts-power.gif" alt="Powered by Struts"/>
   
   </body>
   </html:html>