dev@javaserverfaces.java.net

Re: Seeking Review: 59-AttributeTag

From: Roger Kitain <Roger.Kitain_at_Sun.COM>
Date: Fri, 07 Jan 2005 11:39:57 -0500

Ed Burns wrote:

>This checkin implements the non-EL part of 59-AttributeTag.
>
>SECTION: Changes
>
>M conf/share/jsf_core.tld
>
>- use the RI private tag handler for f:attribute
>
>A src/com/sun/faces/taglib/jsf_core/AttributeTag.java
>
>- new file, copied from jsf-api and modified.
>
>M systest/web/golden/taglib/attributeTest.txt
>
>- new golden file
>
>M systest/web/taglib/attributeTest.jsp
>
>- new test content
>
>
>SECTION: Diffs
>
>Index: conf/share/jsf_core.tld
>===================================================================
>RCS file: /cvs/javaserverfaces-sources/jsf-ri/conf/share/jsf_core.tld,v
>retrieving revision 1.46
>diff -u -r1.46 jsf_core.tld
>--- conf/share/jsf_core.tld 8 Dec 2004 15:10:26 -0000 1.46
>+++ conf/share/jsf_core.tld 7 Jan 2005 00:52:33 -0000
>@@ -96,7 +96,7 @@
> <tag>
>
> <name>attribute</name>
>- <tag-class>javax.faces.webapp.AttributeTag</tag-class>
>+ <tag-class>com.sun.faces.taglib.jsf_core.AttributeTag</tag-class>
> <tei-class>com.sun.faces.taglib.FacesTagExtraInfo</tei-class>
> <body-content>empty</body-content>
> <description>
>Index: systest/build.xml
>===================================================================
>RCS file: /cvs/javaserverfaces-sources/jsf-ri/systest/build.xml,v
>retrieving revision 1.22
>diff -u -r1.22 build.xml
>--- systest/build.xml 12 Oct 2004 14:39:55 -0000 1.22
>+++ systest/build.xml 7 Jan 2005 00:52:34 -0000
>@@ -255,7 +255,7 @@
> <target name="passthru" depends="compile"
> description="Convenience target to execute just one test. Just change the nested traget attribute.">
>
>- <ant antfile="build-tests.xml" target="test.standard"/>
>+ <ant antfile="build-tests.xml" target="test.valueBindingGet"/>
>
> </target>
>
>Index: systest/web/golden/taglib/attributeTest.txt
>===================================================================
>RCS file: /cvs/javaserverfaces-sources/jsf-ri/systest/web/golden/taglib/attributeTest.txt,v
>retrieving revision 1.1
>diff -u -r1.1 attributeTest.txt
>--- systest/web/golden/taglib/attributeTest.txt 29 Jul 2004 21:18:05 -0000 1.1
>+++ systest/web/golden/taglib/attributeTest.txt 7 Jan 2005 00:52:34 -0000
>@@ -10,9 +10,18 @@
> <h1>f:attribute</h1>
>
>
>+ <p>
>
>
> <span style="color: red">This Should Be Red</span>
>+ </p>
>+
>+ <p>
>+
>+
>+ New String Value
>+ </p>
>+
>
>
> </body>
>Index: systest/web/taglib/attributeTest.jsp
>===================================================================
>RCS file: /cvs/javaserverfaces-sources/jsf-ri/systest/web/taglib/attributeTest.jsp,v
>retrieving revision 1.1
>diff -u -r1.1 attributeTest.jsp
>--- systest/web/taglib/attributeTest.jsp 29 Jul 2004 21:18:06 -0000 1.1
>+++ systest/web/taglib/attributeTest.jsp 7 Jan 2005 00:52:35 -0000
>@@ -10,9 +10,18 @@
> <h1>f:attribute</h1>
>
> <f:view>
>+ <p>
> <h:outputText value="This Should Be Red">
> <f:attribute name="style" value="color: red" />
> </h:outputText>
>+ </p>
>+
>+ <p>
>+ <h:outputText>
>+ <f:attribute name="value" value="#{test2.stringProperty}" />
>+ </h:outputText>
>+ </p>
>+
> </f:view>
>
> </body>
>
>SECTION: New Files
>
>/*
> * $Id: AttributeTag.java,v 1.4 2004/11/22 21:27:01 edburns Exp $
> */
>
>/*
> * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
> * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
> */
>
>package com.sun.faces.taglib.jsf_core;
>
>
>import javax.faces.component.UIComponent;
>import javax.faces.webapp.UIComponentTag;
>import javax.faces.context.FacesContext;
>import javax.faces.el.ValueBinding;
>import javax.servlet.jsp.JspException;
>import javax.servlet.jsp.tagext.Tag;
>import javax.servlet.jsp.tagext.TagSupport;
>
>
>/**
> * <p>Tag implementation that adds an attribute with a specified name
> * and String value to the component whose tag it is nested inside,
> * if the component does not already contain an attribute with the
> * same name. This tag creates no output to the page currently
> * being created.</p>
> *
> */
>
>public class AttributeTag extends TagSupport {
>
>
> // ------------------------------------------------------------- Attributes
>
>
> /**
> * <p>The name of the attribute to be created, if not already present.
> */
> private String name = null;
>
>
> /**
> * <p>Set the attribute name.</p>
> *
> * @param name The new attribute name
> */
> public void setName(String name) {
>
> this.name = name;
>
> }
>
>
> /**
> * <p>The value to be associated with this attribute, if it is created.</p>
> */
> private String value = null;
>
>
>
> /**
> * <p>Set the attribute value.</p>
> *
> * @param value The new attribute value
> */
> public void setValue(String value) {
>
> this.value = value;
>
> }
>
>
> // --------------------------------------------------------- Public Methods
>
>
> /**
> * <p>Register the specified attribute name and value with the
> * {_at_link UIComponent} instance associated with our most immediately
> * surrounding {_at_link UIComponentTag} instance, if this {_at_link UIComponent}
> * does not already have a value for the specified attribute name.</p>
> *
> * @exception JspException if a JSP error occurs
> */
> public int doStartTag() throws JspException {
>
> // Locate our parent UIComponentTag
> UIComponentTag tag =
> UIComponentTag.getParentUIComponentTag(pageContext);
> if (tag == null) { // PENDING - i18n
> throw new JspException("Not nested in a UIComponentTag");
> }
>
> // Add this attribute if it is not already defined
> UIComponent component = tag.getComponentInstance();
> if (component == null) { // PENDING - i18n
> throw new JspException("No component associated with UIComponentTag");
> }
> String nameVal = name;
>
> FacesContext context = FacesContext.getCurrentInstance();
>
> if (UIComponentTag.isValueReference(name)) {
> ValueBinding vb =
> context.getApplication().createValueBinding(name);
> nameVal = (String) vb.getValue(context);
> }
> if (null != component.getAttributes().get(nameVal)) {
> return (SKIP_BODY);
> }
> if (UIComponentTag.isValueReference(value)) {
> ValueBinding vb =
> context.getApplication().createValueBinding(value);
> component.setValueBinding(nameVal, vb);
> }
> else {
> component.getAttributes().put(nameVal, value);
> }
> return (SKIP_BODY);
>
> }
>
>
> /**
> * <p>Release references to any acquired resources.
> */
> public void release() {
>
> this.name = null;
> this.value = null;
> }
>
>}
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
>For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>
>
>
r=rogerk

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net