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/06/30 18:21:12 UTC

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

craigmcc    00/06/30 09:21:10

  Modified:    src/share/org/apache/struts/taglib Link1Tag.java
                        LinkTag.java LocalStrings.properties
               web/example mainMenu.jsp
  Log:
  Fix the query parameters enhancement recently added.
  Submitted by:	Richard Backhouse <ri...@hotmail.com>
  
  Revision  Changes    Path
  1.2       +15 -9     jakarta-struts/src/share/org/apache/struts/taglib/Link1Tag.java
  
  Index: Link1Tag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/Link1Tag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Link1Tag.java	2000/06/27 01:58:29	1.1
  +++ Link1Tag.java	2000/06/30 16:20:59	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/Link1Tag.java,v 1.1 2000/06/27 01:58:29 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/06/27 01:58:29 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/Link1Tag.java,v 1.2 2000/06/30 16:20:59 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/06/30 16:20:59 $
    *
    * ====================================================================
    *
  @@ -82,7 +82,7 @@
    * a Map, so that it works on JDK 1.1 platforms.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/06/27 01:58:29 $
  + * @version $Revision: 1.2 $ $Date: 2000/06/30 16:20:59 $
    */
   
   public class Link1Tag extends TagSupport {
  @@ -295,21 +295,27 @@
   
   	// Look up the dictionary we will be using
   	Object bean = pageContext.findAttribute(name);
  -	Dictionary dictionary = null;
  -	if (dictionary == null)
  +	if (bean == null)
   	    throw new JspException
   		(messages.getMessage("linkTag.bean", name));
  -	if (property != null) {
  +	Dictionary dictionary = null;
  +	if (property == null) {
  +	    try {
  +		dictionary = (Dictionary) bean;
  +	    } catch (ClassCastException e) {
  +		throw new JspException
  +		    (messages.getMessage("linkTag.type1"));
  +	    }
  +	} else {
   	    String methodName = "get" + BeanUtils.capitalize(property);
   	    Class paramTypes[] = new Class[0];
   	    Method method = null;
   	    try {
   		method = bean.getClass().getMethod(methodName, paramTypes);
  -		bean = method.invoke(dictionary, new Object[0]);
  +		dictionary = (Dictionary) method.invoke(bean, new Object[0]);
   		if (bean == null)
   		    throw new JspException
   			(messages.getMessage("linkTag.property", methodName));
  -		dictionary = (Dictionary) bean;
   	    } catch (ClassCastException e) {
   		throw new JspException
   		    (messages.getMessage("linkTag.type1"));
  
  
  
  1.5       +15 -9     jakarta-struts/src/share/org/apache/struts/taglib/LinkTag.java
  
  Index: LinkTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/LinkTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LinkTag.java	2000/06/29 21:54:03	1.4
  +++ LinkTag.java	2000/06/30 16:21:00	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/LinkTag.java,v 1.4 2000/06/29 21:54:03 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/06/29 21:54:03 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/LinkTag.java,v 1.5 2000/06/30 16:21:00 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/06/30 16:21:00 $
    *
    * ====================================================================
    *
  @@ -81,7 +81,7 @@
    * Generate a URL-encoded hyperlink to the specified URI.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2000/06/29 21:54:03 $
  + * @version $Revision: 1.5 $ $Date: 2000/06/30 16:21:00 $
    */
   
   public class LinkTag extends TagSupport {
  @@ -294,21 +294,27 @@
   
   	// Look up the map we will be using
   	Object bean = pageContext.findAttribute(name);
  -	Map map = null;
  -	if (map == null)
  +	if (bean == null)
   	    throw new JspException
   		(messages.getMessage("linkTag.bean", name));
  -	if (property != null) {
  +	Map map = null;
  +	if (property == null) {
  +	    try {
  +		map = (Map) bean;
  +	    } catch (ClassCastException e) {
  +		throw new JspException
  +		    (messages.getMessage("linkTag.type"));
  +	    }
  +	} else {
   	    String methodName = "get" + BeanUtils.capitalize(property);
   	    Class paramTypes[] = new Class[0];
   	    Method method = null;
   	    try {
   		method = bean.getClass().getMethod(methodName, paramTypes);
  -		bean = method.invoke(map, new Object[0]);
  +		map = (Map) method.invoke(bean, new Object[0]);
   		if (bean == null)
   		    throw new JspException
   			(messages.getMessage("linkTag.property", methodName));
  -		map = (Map) bean;
   	    } catch (ClassCastException e) {
   		throw new JspException
   		    (messages.getMessage("linkTag.type"));
  
  
  
  1.6       +1 -0      jakarta-struts/src/share/org/apache/struts/taglib/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/LocalStrings.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LocalStrings.properties	2000/06/30 00:46:39	1.5
  +++ LocalStrings.properties	2000/06/30 16:21:00	1.6
  @@ -29,6 +29,7 @@
   iterate.noCollection=Cannot create iterator for {0}
   iterate.noProperty=Cannot find property {1} for bean attribute {0}
   linkTag.bean=Missing object for attribute {0}
  +linkTag.cast=Cannot cast attribute {0} to a Map
   linkTag.method=Object has no method named {0}
   linkTag.name=You must specify a name attribute if the property attribute is present
   linkTag.property=Method {0} returned null
  
  
  
  1.3       +0 -1      jakarta-struts/web/example/mainMenu.jsp
  
  Index: mainMenu.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/example/mainMenu.jsp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- mainMenu.jsp	2000/06/16 01:32:25	1.2
  +++ mainMenu.jsp	2000/06/30 16:21:06	1.3
  @@ -17,6 +17,5 @@
   <li><struts:link href="logoff.do"><struts:message key="mainMenu.logoff"/></struts:link>
   </ul>
   
  -
   </body>
   </html>