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...@locus.apache.org on 2000/11/18 23:10:56 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/form LinkTag.java LocalStrings.properties

craigmcc    00/11/18 14:10:56

  Modified:    src/share/org/apache/struts/action Action.java
                        ActionServlet.java
               src/share/org/apache/struts/taglib/form LinkTag.java
                        LocalStrings.properties
  Log:
  Correctly implement the "page" attribute for the Link tag.
  
  Correct references to the right Constants class.
  
  Revision  Changes    Path
  1.8       +5 -5      jakarta-struts/src/share/org/apache/struts/action/Action.java
  
  Index: Action.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Action.java	2000/10/12 22:31:32	1.7
  +++ Action.java	2000/11/18 22:10:55	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.7 2000/10/12 22:31:32 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/10/12 22:31:32 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.8 2000/11/18 22:10:55 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/11/18 22:10:55 $
    *
    * ====================================================================
    *
  @@ -71,7 +71,7 @@
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import javax.servlet.http.HttpSession;
  -import org.apache.struts.taglib.Constants;
  +import org.apache.struts.taglib.form.Constants;
   import org.apache.struts.util.ErrorMessages;
   import org.apache.struts.util.MessageResources;
   
  @@ -105,7 +105,7 @@
    * by this Action.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/10/12 22:31:32 $
  + * @version $Revision: 1.8 $ $Date: 2000/11/18 22:10:55 $
    */
   
   public class Action {
  
  
  
  1.34      +5 -5      jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
  
  Index: ActionServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- ActionServlet.java	2000/11/09 20:44:19	1.33
  +++ ActionServlet.java	2000/11/18 22:10:55	1.34
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.33 2000/11/09 20:44:19 mschachter Exp $
  - * $Revision: 1.33 $
  - * $Date: 2000/11/09 20:44:19 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.34 2000/11/18 22:10:55 craigmcc Exp $
  + * $Revision: 1.34 $
  + * $Date: 2000/11/18 22:10:55 $
    *
    * ====================================================================
    *
  @@ -79,7 +79,7 @@
   import javax.servlet.http.HttpServletResponse;
   import javax.servlet.http.HttpSession;
   import org.apache.struts.digester.Digester;
  -import org.apache.struts.taglib.Constants;
  +import org.apache.struts.taglib.form.Constants;
   import org.apache.struts.util.BeanUtils;
   import org.apache.struts.util.MessageResources;
   import org.xml.sax.SAXException;
  @@ -200,7 +200,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.33 $ $Date: 2000/11/09 20:44:19 $
  + * @version $Revision: 1.34 $ $Date: 2000/11/18 22:10:55 $
    */
   
   public class ActionServlet
  
  
  
  1.3       +44 -19    jakarta-struts/src/share/org/apache/struts/taglib/form/LinkTag.java
  
  Index: LinkTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/form/LinkTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LinkTag.java	2000/11/18 20:04:44	1.2
  +++ LinkTag.java	2000/11/18 22:10:56	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/form/LinkTag.java,v 1.2 2000/11/18 20:04:44 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/11/18 20:04:44 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/form/LinkTag.java,v 1.3 2000/11/18 22:10:56 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/11/18 22:10:56 $
    *
    * ====================================================================
    *
  @@ -85,7 +85,7 @@
    * Generate a URL-encoded hyperlink to the specified URI.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/11/18 20:04:44 $
  + * @version $Revision: 1.3 $ $Date: 2000/11/18 22:10:56 $
    */
   
   public class LinkTag extends TagSupport {
  @@ -144,6 +144,21 @@
   
   
       /**
  +     * The context-relative page URL (beginning with a slash) to which
  +     * this hyperlink will be rendered.
  +     */
  +    protected String page = null;
  +
  +    public String getPage() {
  +        return (this.page);
  +    }
  +
  +    public void setPage(String page) {
  +        this.page = page;
  +    }
  +
  +
  +    /**
        * The JSP bean property name for query parameters.
        */
       protected String property = null;
  @@ -195,21 +210,6 @@
        */
       public int doStartTag() throws JspException {
   
  -	// Validate our attributes
  -	if ((forward == null) && (href == null)) {
  -	    JspException e = new JspException
  -		(messages.getMessage("linkTag.destination"));
  -            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  -                                     PageContext.REQUEST_SCOPE);
  -            throw e;
  -        } else if ((forward != null) && (href != null)) {
  -	    JspException e = new JspException
  -		(messages.getMessage("linkTag.destination"));
  -            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  -                                     PageContext.REQUEST_SCOPE);
  -            throw e;
  -        }
  -
   	// Generate the hyperlink start element
   	HttpServletResponse response =
   	  (HttpServletResponse) pageContext.getResponse();
  @@ -272,6 +272,7 @@
   	forward = null;
   	href = null;
   	name = null;
  +        page = null;
   	property = null;
           scope = null;
   	target = null;
  @@ -290,6 +291,23 @@
        */
       protected String hyperlink() throws JspException {
   
  +        // Validate the number of href specifiers that were specified
  +        int n = 0;
  +        if (forward != null)
  +            n++;
  +        if (href != null)
  +            n++;
  +        if (page != null)
  +            n++;
  +        if (n != 1) {
  +            JspException e = new JspException
  +                (messages.getMessage("linkTag.destination"));
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
  +            throw e;
  +        }
  +
  +        // Start with an unadorned "href"
   	String href = this.href;
   
   	// If "forward" was specified, compute the "href" to forward to
  @@ -308,6 +326,13 @@
   		(HttpServletRequest) pageContext.getRequest();
   	    href = request.getContextPath() + forward.getPath();
   	}
  +
  +        // If "page" was specified, compute the "href" to forward to
  +        if (page != null) {
  +            HttpServletRequest request =
  +                (HttpServletRequest) pageContext.getRequest();
  +            href = request.getContextPath() + page;
  +        }
   
   	// Just return the "href" attribute if there is no bean to look up
   	if ((property != null) && (name == null)) {
  
  
  
  1.2       +1 -1      jakarta-struts/src/share/org/apache/struts/taglib/form/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/form/LocalStrings.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocalStrings.properties	2000/11/18 19:50:29	1.1
  +++ LocalStrings.properties	2000/11/18 22:10:56	1.2
  @@ -13,7 +13,7 @@
   includeTag.include=Error including page {0}: {1}
   includeTag.lookup=Cannot find global forward named {0}
   iterateTag.iterator=Cannot create iterator for {0}
  -linkTag.destination=You must specify exactly one of 'forward' or 'href'
  +linkTag.destination=You must specify exactly one of 'forward', 'href', or 'page'
   linkTag.forward=Cannot locate global forwarding for {0}
   linkTag.forwards=Cannot locate forwards mapping table
   linkTag.type=Object must be of type Map