oalexeev 02/02/21 09:48:14 Modified: src/share/org/apache/struts/taglib/bean DefineTag.java DefineTei.java LocalStrings.properties Log: Modify bean:define tag - add ability to take tag's body as value for the new scripting variable. Revision Changes Path 1.13 +25 -11 jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java Index: DefineTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- DefineTag.java 23 Apr 2001 22:52:20 -0000 1.12 +++ DefineTag.java 21 Feb 2002 17:48:14 -0000 1.13 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java,v 1.12 2001/04/23 22:52:20 craigmcc Exp $ - * $Revision: 1.12 $ - * $Date: 2001/04/23 22:52:20 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java,v 1.13 2002/02/21 17:48:14 oalexeev Exp $ + * $Revision: 1.13 $ + * $Date: 2002/02/21 17:48:14 $ * * ==================================================================== * @@ -67,7 +67,8 @@ import java.lang.reflect.InvocationTargetException; import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; -import javax.servlet.jsp.tagext.TagSupport; +import javax.servlet.jsp.tagext.BodyTagSupport; +import org.apache.struts.util.MessageResources; import org.apache.struts.util.RequestUtils; @@ -76,11 +77,19 @@ * bean property. * * @author Craig R. McClanahan - * @version $Revision: 1.12 $ $Date: 2001/04/23 22:52:20 $ + * @version $Revision: 1.13 $ $Date: 2002/02/21 17:48:14 $ */ -public class DefineTag extends TagSupport { +public class DefineTag extends BodyTagSupport { + // ---------------------------------------------------- Protected variables + + /** + * The message resources for this package. + */ + protected static MessageResources messages = + MessageResources.getMessageResources + ("org.apache.struts.taglib.bean.LocalStrings"); // ------------------------------------------------------------- Properties @@ -186,17 +195,21 @@ // --------------------------------------------------------- Public Methods - /** * Retrieve the required property and expose it as a scripting variable. * * @exception JspException if a JSP exception has occurred */ - public int doStartTag() throws JspException { + public int doEndTag() throws JspException { + + if( this.value!=null && bodyContent!=null ) + throw new JspException( messages.getMessage("define.value", name) ); // Retrieve the required property value Object value = this.value; - if (value == null) + if (value == null) + value = bodyContent.getString(); + if (value == null) value = RequestUtils.lookup(pageContext, name, property, scope); // Expose this value as a scripting variable @@ -208,10 +221,11 @@ else if ("application".equals(toScope)) inScope = PageContext.APPLICATION_SCOPE; pageContext.setAttribute(id, value, inScope); - return (SKIP_BODY); - } + // Continue processing this page + return (EVAL_PAGE); + } /** * Release all allocated resources. 1.7 +13 -12 jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTei.java Index: DefineTei.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTei.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DefineTei.java 22 Apr 2001 00:46:19 -0000 1.6 +++ DefineTei.java 21 Feb 2002 17:48:14 -0000 1.7 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTei.java,v 1.6 2001/04/22 00:46:19 craigmcc Exp $ - * $Revision: 1.6 $ - * $Date: 2001/04/22 00:46:19 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTei.java,v 1.7 2002/02/21 17:48:14 oalexeev Exp $ + * $Revision: 1.7 $ + * $Date: 2002/02/21 17:48:14 $ * * ==================================================================== * @@ -73,7 +73,7 @@ * tag, identifying the scripting object(s) to be made visible. * * @author Craig R. McClanahan - * @version $Revision: 1.6 $ $Date: 2001/04/22 00:46:19 $ + * @version $Revision: 1.7 $ $Date: 2002/02/21 17:48:14 $ */ public class DefineTei extends TagExtraInfo { @@ -85,20 +85,21 @@ public VariableInfo[] getVariableInfo(TagData data) { String type = data.getAttributeString("type"); + String name = data.getAttributeString("name"); Object value = data.getAttribute("value"); if (type == null) { - if (value != null) + if ( (value!=null) || ( (value==null) && (name==null) ) ) type = "java.lang.String"; - else + else type = "java.lang.Object"; } - return new VariableInfo[] { - new VariableInfo(data.getAttributeString("id"), - type, - true, - VariableInfo.AT_BEGIN) - }; + return new VariableInfo[] { + new VariableInfo(data.getAttributeString("id"), + type, + true, + VariableInfo.AT_END ) + }; } 1.15 +2 -1 jakarta-struts/src/share/org/apache/struts/taglib/bean/LocalStrings.properties Index: LocalStrings.properties =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/LocalStrings.properties,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- LocalStrings.properties 21 Nov 2001 18:47:28 -0000 1.14 +++ LocalStrings.properties 21 Feb 2002 17:48:14 -0000 1.15 @@ -16,4 +16,5 @@ size.collection=No valid collection specified for size tag struts.missing=No Struts internal object named {0} is available struts.selector=You must specify exactly one of formBean, forward, or mapping -write.format=Wrong format string: '{0}' \ No newline at end of file +write.format=Wrong format string: '{0}' +define.value=Define tag can contain value attribute or body - both can not be processed. \ No newline at end of file
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>