You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/07/19 12:21:33 UTC

svn commit: r678124 - in /myfaces/tobago/trunk/extension: facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/ tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/ tobago-taglib-extension/src/main/java/org/a...

Author: bommel
Date: Sat Jul 19 03:21:30 2008
New Revision: 678124

URL: http://svn.apache.org/viewvc?rev=678124&view=rev
Log:
(TOBAGO-689) Extension tag for tc:separator

Added:
    myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/SeparatorExtensionHandler.java   (with props)
    myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/SeparatorExtensionTag.java   (with props)
    myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension12/SeparatorExtensionTag.java   (with props)
Modified:
    myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoExtensionTagLibrary.java

Added: myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/SeparatorExtensionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/SeparatorExtensionHandler.java?rev=678124&view=auto
==============================================================================
--- myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/SeparatorExtensionHandler.java (added)
+++ myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/SeparatorExtensionHandler.java Sat Jul 19 03:21:30 2008
@@ -0,0 +1,92 @@
+package org.apache.myfaces.tobago.facelets.extension;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.sun.facelets.tag.jsf.ComponentHandler;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentSupport;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.el.ELAdaptor;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.UIOutput;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import java.io.IOException;
+
+import org.apache.myfaces.tobago.TobagoConstants;
+import org.apache.myfaces.tobago.component.UILabel;
+import org.apache.myfaces.tobago.component.UISeparator;
+
+public class SeparatorExtensionHandler extends ComponentHandler {
+  private TagAttribute labelAttribute;
+
+  public SeparatorExtensionHandler(ComponentConfig config) {
+    super(config);
+    labelAttribute = getAttribute(TobagoConstants.ATTR_LABEL);
+  }
+
+  protected void applyNextHandler(FaceletContext faceletContext, UIComponent separator)
+      throws IOException, FacesException, ELException {
+    if (ComponentSupport.isNew(separator)) {
+      UIComponent component = (UIComponent) separator.getFacets().remove(TobagoConstants.FACET_LABEL);
+      nextHandler.apply(faceletContext, component);
+      separator.getFacets().put(TobagoConstants.FACET_LABEL, component);
+    } else {
+      nextHandler.apply(faceletContext, separator.getFacet(TobagoConstants.FACET_LABEL));
+    }
+  }
+
+  protected void onComponentCreated(FaceletContext faceletContext, UIComponent separator, UIComponent parent) {
+    Application application = faceletContext.getFacesContext().getApplication();
+    UIViewRoot root = ComponentSupport.getViewRoot(faceletContext, parent);
+    UIOutput label = (UIOutput) application.createComponent(UILabel.COMPONENT_TYPE);
+    label.setId(root.createUniqueId());
+    label.setRendererType("Label");
+    setAttributes(faceletContext, label);
+    separator.getFacets().put(TobagoConstants.FACET_LABEL, label);
+    if (labelAttribute != null) {
+      if (labelAttribute.isLiteral()) {
+        label.setValue(labelAttribute.getValue(faceletContext));
+      } else {
+        ValueExpression expression = labelAttribute.getValueExpression(faceletContext, String.class);
+        ELAdaptor.setExpression(label, TobagoConstants.ATTR_VALUE, expression);
+      }
+    }
+  }
+
+  protected MetaRuleset createMetaRuleset(Class aClass) {
+    MetaRuleset metaRuleset = super.createMetaRuleset(aClass);
+    if (UISeparator.class.isAssignableFrom(aClass)) {
+      metaRuleset.ignore(TobagoConstants.ATTR_LABEL);
+      return metaRuleset;
+    } else {
+      TagAttribute[] attrs = tag.getAttributes().getAll();
+      for (int i = 0; i < attrs.length; i++) {
+        TagAttribute attr = attrs[i];
+        metaRuleset.ignore(attr.getLocalName());
+      }
+      return metaRuleset;
+    }
+  }
+}

Propchange: myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/SeparatorExtensionHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/SeparatorExtensionHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoExtensionTagLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoExtensionTagLibrary.java?rev=678124&r1=678123&r2=678124&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoExtensionTagLibrary.java (original)
+++ myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoExtensionTagLibrary.java Sat Jul 19 03:21:30 2008
@@ -48,5 +48,7 @@
         SelectOneRadioExtensionHandler.class);
     addComponent("selectOneListbox", "org.apache.myfaces.tobago.Panel", "Panel",
         SelectOneListboxExtensionHandler.class);
+    addComponent("separator", "org.apache.myfaces.tobago.Separator", "Separator",
+        SeparatorExtensionHandler.class);
   }
 }

Added: myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/SeparatorExtensionTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/SeparatorExtensionTag.java?rev=678124&view=auto
==============================================================================
--- myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/SeparatorExtensionTag.java (added)
+++ myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/SeparatorExtensionTag.java Sat Jul 19 03:21:30 2008
@@ -0,0 +1,113 @@
+package org.apache.myfaces.tobago.taglib.extension;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
+import org.apache.myfaces.tobago.taglib.decl.HasLabel;
+import org.apache.myfaces.tobago.apt.annotation.Tag;
+import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
+import org.apache.myfaces.tobago.internal.taglib.SeparatorTag;
+import org.apache.myfaces.tobago.internal.taglib.LabelTag;
+
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.JspException;
+import javax.faces.webapp.FacetTag;
+
+/**
+ * Renders a separator.
+ * <br />
+ * Short syntax of:
+ * <p/>
+ * <pre>
+ * &lt;tc:separator>
+ *   &lt;f:facet name="label">
+ *     &lt;tc:label value="label"/>
+ *   &lt;/f:facet>
+ * &lt;/tc:separator>
+ * </pre>
+ */
+
+@Tag(name = "separator")
+@ExtensionTag(baseClassName = "org.apache.myfaces.tobago.internal.taglib.SeparatorTag")
+public class SeparatorExtensionTag extends BodyTagSupport implements HasIdBindingAndRendered, HasLabel {
+  private String binding;
+  private String rendered;
+  private String label;
+
+  private SeparatorTag separatorTag;
+  private FacetTag facetTag;
+  private LabelTag labelTag;
+
+  @Override
+  public int doStartTag() throws JspException {
+    separatorTag = new SeparatorTag();
+    separatorTag.setPageContext(pageContext);
+    separatorTag.setParent(getParent());
+    if (binding != null) {
+      separatorTag.setBinding(binding);
+    }
+    if (rendered != null) {
+      separatorTag.setRendered(rendered);
+    }
+    facetTag = new FacetTag();
+    facetTag.setPageContext(pageContext);
+    facetTag.setParent(separatorTag);
+    facetTag.setName(org.apache.myfaces.tobago.TobagoConstants.FACET_LABEL);
+
+    facetTag.doStartTag();
+    labelTag = new LabelTag();
+    labelTag.setPageContext(pageContext);
+    labelTag.setParent(facetTag);
+    if (label != null) {
+      labelTag.setValue(label);
+    }
+    labelTag.doStartTag();
+    return super.doStartTag();
+  }
+
+  @Override
+  public int doEndTag() throws JspException {
+    labelTag.doEndTag();
+    facetTag.doEndTag();
+    separatorTag.doEndTag();
+    return super.doEndTag();
+  }
+
+  @Override
+  public void release() {
+    super.release();
+    binding = null;
+    rendered = null;
+    label = null;
+    separatorTag = null;
+    facetTag = null;
+    labelTag = null;
+  }
+
+  public void setBinding(String binding) throws JspException {
+    this.binding = binding;
+  }
+
+  public void setRendered(String rendered) {
+    this.rendered = rendered;
+  }
+
+  public void setLabel(String label) {
+    this.label = label;
+  }
+}

Propchange: myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/SeparatorExtensionTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/SeparatorExtensionTag.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension12/SeparatorExtensionTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension12/SeparatorExtensionTag.java?rev=678124&view=auto
==============================================================================
--- myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension12/SeparatorExtensionTag.java (added)
+++ myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension12/SeparatorExtensionTag.java Sat Jul 19 03:21:30 2008
@@ -0,0 +1,126 @@
+package org.apache.myfaces.tobago.taglib.extension12;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+import org.apache.myfaces.tobago.internal.taglib.LabelTag;
+import org.apache.myfaces.tobago.internal.taglib.SeparatorTag;
+
+import javax.faces.webapp.FacetTag;
+import javax.servlet.jsp.JspException;
+
+/**
+ * Renders a separator.
+ * <br />
+ * Short syntax of:
+ * <p/>
+ * <pre>
+ * &lt;tc:separator>
+ *   &lt;f:facet name="label">
+ *     &lt;tc:label value="label"/>
+ *   &lt;/f:facet>
+ * &lt;/tc:separator>
+ * </pre>
+ */
+
+public class SeparatorExtensionTag extends TobagoExtensionBodyTagSupport {
+  private javax.el.ValueExpression binding;
+  private javax.el.ValueExpression rendered;
+  private javax.el.ValueExpression label;
+
+  private SeparatorTag separatorTag;
+  private FacetTag facetTag;
+  private LabelTag labelTag;
+
+  @Override
+  public int doStartTag() throws JspException {
+    separatorTag = new SeparatorTag();
+    separatorTag.setPageContext(pageContext);
+    separatorTag.setParent(getParent());
+    if (binding != null) {
+      separatorTag.setBinding(binding);
+    }
+    if (rendered != null) {
+      separatorTag.setRendered(rendered);
+    }
+    facetTag = new FacetTag();
+    facetTag.setPageContext(pageContext);
+    facetTag.setParent(separatorTag);
+    facetTag.setName(org.apache.myfaces.tobago.TobagoConstants.FACET_LABEL);
+
+    facetTag.doStartTag();
+    labelTag = new LabelTag();
+    labelTag.setPageContext(pageContext);
+    labelTag.setParent(facetTag);
+    if (label != null) {
+      labelTag.setValue(label);
+    }
+    labelTag.doStartTag();
+    return super.doStartTag();
+  }
+
+  @Override
+  public int doEndTag() throws JspException {
+    labelTag.doEndTag();
+    facetTag.doEndTag();
+    separatorTag.doEndTag();
+    return super.doEndTag();
+  }
+
+  @Override
+  public void release() {
+    super.release();
+    binding = null;
+    rendered = null;
+    label = null;
+    separatorTag = null;
+    facetTag = null;
+    labelTag = null;
+  }
+
+  /**
+   * The value binding expression linking this
+   * component to a property in a backing bean.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "javax.faces.component.UIComponent")
+  public void setBinding(javax.el.ValueExpression binding) throws JspException {
+    this.binding = binding;
+  }
+  
+  /**
+   * Flag indicating whether or not this component should be rendered
+   * (during Render Response Phase), or processed on any subsequent form submit.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "true")
+  public void setRendered(javax.el.ValueExpression rendered) {
+    this.rendered = rendered;
+  }
+
+  /**
+   * Text value to display as label.
+   * If text contains an underscore the next character is used as accesskey.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute()
+  public void setLabel(javax.el.ValueExpression label) {
+    this.label = label;
+  }
+}

Propchange: myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension12/SeparatorExtensionTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension12/SeparatorExtensionTag.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL