dmkarr 2002/10/15 21:03:56
Modified: contrib/struts-el/src/share/org/apache/strutsel/taglib/logic
ELRedirectTag.java
contrib/struts-el/web/exercise-taglib logic-redirect.jsp
Added: contrib/struts-el/src/share/org/apache/strutsel/taglib/logic
ELRedirectTagBeanInfo.java
Log:
More boolean attribute mapping fixes
Revision Changes Path
1.4 +38 -9
jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/logic/ELRedirectTag.java
Index: ELRedirectTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/logic/ELRedirectTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ELRedirectTag.java 1 Oct 2002 04:25:51 -0000 1.3
+++ ELRedirectTag.java 16 Oct 2002 04:03:56 -0000 1.4
@@ -62,7 +62,7 @@
import org.apache.struts.taglib.logic.RedirectTag;
import javax.servlet.jsp.JspException;
-import org.apache.taglibs.standard.tag.el.core.ExpressionUtil;
+import org.apache.strutsel.taglib.utils.EvalHelper;
import org.apache.taglibs.standard.tag.common.core.NullAttributeException;
/**
@@ -80,6 +80,32 @@
public class ELRedirectTag extends RedirectTag {
/**
+ * String value of the "transaction" attribute.
+ */
+ private String transactionExpr;
+
+ /**
+ * Returns the string value of the "transaction" attribute.
+ */
+ public String getTransactionExpr() { return (transactionExpr); }
+
+ /**
+ * Sets the string value of the "transaction" attribute. This attribute is
+ * mapped to this method by the <code>ELRedirectTagBeanInfo</code> class.
+ */
+ public void setTransactionExpr(String transactionExpr)
+ { this.transactionExpr = transactionExpr; }
+
+ /**
+ * Resets attribute values for tag reuse.
+ */
+ public void release()
+ {
+ super.release();
+ setTransactionExpr(null);
+ }
+
+ /**
* Process the start tag.
*
* @exception JspException if a JSP exception has occurred
@@ -91,7 +117,8 @@
/**
* Evaluates and returns a single attribute value, given the attribute
- * name, attribute value, and attribute type. It uses
+ * name, attribute value, and attribute type. It uses the
+ * <code>EvalHelper</code> class to interface to
* <code>ExpressionUtil.evalNotNull</code> to do the actual evaluation, and
* it passes to this the name of the current tag, the <code>this</code>
* pointer, and the current pageContext.
@@ -99,6 +126,8 @@
* @param attrName attribute name being evaluated
* @param attrValue String value of attribute to be evaluated using EL
* @param attrType Required resulting type of attribute value
+ * @exception NullAttributeException if either the <code>attrValue</code>
+ * was null, or the resulting evaluated value was null.
* @return Resulting attribute value
*/
private Object evalAttr(String attrName,
@@ -106,8 +135,8 @@
Class attrType)
throws JspException, NullAttributeException
{
- return (ExpressionUtil.evalNotNull("redirect", attrName, attrValue,
- attrType, this, pageContext));
+ return (EvalHelper.eval("redirect", attrName, attrValue, attrType,
+ this, pageContext));
}
/**
@@ -187,7 +216,7 @@
try {
setTransaction(((Boolean) evalAttr("transaction",
- getTransaction() + "",
+ getTransactionExpr(),
Boolean.class)).
booleanValue());
} catch (NullAttributeException ex) {
1.1
jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/logic/ELRedirectTagBeanInfo.java
Index: ELRedirectTagBeanInfo.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-struts/contrib/struts-el/src/share/org/apache/strutsel/taglib/logic/ELRedirectTagBeanInfo.java,v
1.1 2002/10/16 04:03:56 dmkarr Exp $
* $Revision: 1.1 $
* $Date: 2002/10/16 04:03:56 $
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.strutsel.taglib.logic;
import java.beans.PropertyDescriptor;
import java.beans.IntrospectionException;
import java.beans.SimpleBeanInfo;
/**
* This is the <code>BeanInfo</code> descriptor for the
* <code>org.apache.strutsel.taglib.logic.ELRedirectTag</code> class. It is
* needed to override the default mapping of custom tag attribute names to
* class attribute names.
*<p>
* This is necessary because the base class,
* <code>org.apache.struts.taglib.logic.RedirectTag</code> defines some
* attributes whose type is not <code>java.lang.String</code>, so the subclass
* needs to define setter methods of a different name, which this class maps
* to.
*<p>
* Unfortunately, if a <code>BeanInfo</code> class needs to be provided to
* change the mapping of one attribute, it has to specify the mappings of ALL
* attributes, even if all the others use the expected mappings of "name" to
* "method".
*/
public class ELRedirectTagBeanInfo extends SimpleBeanInfo
{
public PropertyDescriptor[] getPropertyDescriptors()
{
PropertyDescriptor[] result = new PropertyDescriptor[12];
try {
result[0] = new PropertyDescriptor("anchor", ELRedirectTag.class,
null, "setAnchor");
result[1] = new PropertyDescriptor("forward", ELRedirectTag.class,
null, "setForward");
result[2] = new PropertyDescriptor("href", ELRedirectTag.class,
null, "setHref");
result[3] = new PropertyDescriptor("name", ELRedirectTag.class,
null, "setName");
result[4] = new PropertyDescriptor("page", ELRedirectTag.class,
null, "setPage");
result[5] = new PropertyDescriptor("paramId", ELRedirectTag.class,
null, "setParamId");
result[6] = new PropertyDescriptor("paramName", ELRedirectTag.class,
null, "setParamName");
result[7] = new PropertyDescriptor("paramProperty",
ELRedirectTag.class,
null, "setParamProperty");
result[8] = new PropertyDescriptor("paramScope",
ELRedirectTag.class,
null, "setParamScope");
result[9] = new PropertyDescriptor("property", ELRedirectTag.class,
null, "setProperty");
result[10] = new PropertyDescriptor("scope", ELRedirectTag.class,
null, "setScope");
result[11] = new PropertyDescriptor("transaction",
ELRedirectTag.class,
null, "setTransactionExpr");
}
catch (IntrospectionException ex) {
ex.printStackTrace();
}
return (result);
}
}
1.2 +2 -1
jakarta-struts/contrib/struts-el/web/exercise-taglib/logic-redirect.jsp
Index: logic-redirect.jsp
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/struts-el/web/exercise-taglib/logic-redirect.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- logic-redirect.jsp 26 Sep 2002 04:54:41 -0000 1.1
+++ logic-redirect.jsp 16 Oct 2002 04:03:56 -0000 1.2
@@ -7,7 +7,8 @@
<c:if test='${not empty param["redirectType"]}'>
<c:choose>
<c:when test='${param["redirectType"] eq "forward"}'>
- <logic-el:redirect forward='${param["param1"]}'/>
+ <logic-el:redirect forward='${param["param1"]}'
+ transaction="${!empty pageScope}"/>
</c:when>
<c:when test='${param["redirectType"] eq "href"}'>
<logic-el:redirect href='${param["param1"]}'/>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>