myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r492676 - in /myfaces/tobago/trunk: contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/ core/src/main/java/org/apache/myfaces/tobago/taglib/component/ example/demo/src/main/webapp/overview/
Date Thu, 04 Jan 2007 18:42:18 GMT
Author: bommel
Date: Thu Jan  4 10:42:13 2007
New Revision: 492676

URL: http://svn.apache.org/viewvc?view=rev&rev=492676
Log:
(TOBAGO-217) Create a popup ref tag

Added:
    myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/PopupReferenceHandler.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java
Modified:
    myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java
    myfaces/tobago/trunk/example/demo/src/main/webapp/overview/toolbar.jsp

Modified: myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java?view=diff&rev=492676&r1=492675&r2=492676
==============================================================================
--- myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java
(original)
+++ myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AbstractTobagoTagLibrary.java
Thu Jan  4 10:42:13 2007
@@ -31,6 +31,7 @@
     super(namespace);
     addTagHandler("attribute", AttributeHandler.class);
     addTagHandler("tabChangeListener", TabChangeListenerHandler.class);
+    addTagHandler("popupReference", PopupReferenceHandler.class);
     addTagHandler("loadBundle", LoadBundleHandler.class);
     addTagHandler("converter", ConverterHandler.class);
   }

Added: myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/PopupReferenceHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/PopupReferenceHandler.java?view=auto&rev=492676
==============================================================================
--- myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/PopupReferenceHandler.java
(added)
+++ myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/PopupReferenceHandler.java
Thu Jan  4 10:42:13 2007
@@ -0,0 +1,61 @@
+package org.apache.myfaces.tobago.facelets;
+
+/*
+ * 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.TagHandler;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagException;
+import com.sun.facelets.FaceletContext;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import java.io.IOException;
+
+import org.apache.myfaces.tobago.event.PopupActionListener;
+
+/*
+ * Created by IntelliJ IDEA.
+ * User: bommel
+ * Date: Jan 4, 2007
+ * Time: 6:25:09 PM
+ */
+public class PopupReferenceHandler extends TagHandler {
+
+  private final TagAttribute _for;
+
+  public PopupReferenceHandler(TagConfig config) {
+    super(config);
+    _for = getAttribute("for");
+  }
+
+  public void apply(FaceletContext faceletContext, UIComponent parent)
+      throws IOException, FacesException, ELException {
+    if (parent instanceof ActionSource) {
+      // only process if parent was just created
+      if (parent.getParent() == null) {
+        ActionSource actionSource = (ActionSource) parent;
+        actionSource.addActionListener(new PopupActionListener(_for.getValue()));
+      }
+    } else {
+      throw new TagException(tag, "Parent is not of type ActionSource, type is: " + parent);
+    }
+  }
+}

Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java?view=auto&rev=492676
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java
(added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java
Thu Jan  4 10:42:13 2007
@@ -0,0 +1,88 @@
+package org.apache.myfaces.tobago.taglib.component;
+
+/*
+ * 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.Tag;
+import org.apache.myfaces.tobago.apt.annotation.BodyContent;
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
+import org.apache.myfaces.tobago.event.PopupActionListener;
+
+import javax.servlet.jsp.tagext.TagSupport;
+import javax.servlet.jsp.JspException;
+import javax.faces.webapp.UIComponentTag;
+import javax.faces.component.UIComponent;
+import javax.faces.component.ActionSource;
+
+/*
+ * Created by IntelliJ IDEA.
+ * User: bommel
+ * Date: Jan 3, 2007
+ * Time: 10:42:11 PM
+ */
+
+/**
+ * Register an PopupActionListener instance on the UIComponent
+ * associated with the closest parent UIComponent.
+ */
+@Tag(name = "popupReference", bodyContent = BodyContent.EMPTY)
+public class PopupReferenceTag extends TagSupport {
+  private String _for;
+
+  /**
+   * The id of a Popup.
+   */
+  @TagAttribute
+  public void setFor(String popupId) {
+    this._for = popupId;
+  }
+
+  public int doStartTag() throws JspException {
+
+    // Locate our parent UIComponentTag
+    UIComponentTag tag =
+        UIComponentTag.getParentUIComponentTag(pageContext);
+    if (tag == null) {
+      // TODO Message resource i18n
+      throw new JspException("Not nested in faces tag");
+    }
+
+    if (!tag.getCreated()) {
+      return (SKIP_BODY);
+    }
+
+    UIComponent component = tag.getComponentInstance();
+    if (component == null) {
+      // TODO Message resource i18n
+      throw new JspException("Component Instance is null");
+    }
+    if (!(component instanceof ActionSource)) {
+      // TODO Message resource i18n
+      throw new JspException("Component "+ component.getClass().getName() + " is not instanceof
ActionSource");
+    }
+    ActionSource actionSource = (ActionSource) component;
+    actionSource.addActionListener(new PopupActionListener(_for));
+    return (SKIP_BODY);
+  }
+
+  /**
+   * <p>Release references to any acquired resources.
+   */
+  public void release() {
+    this._for = null;
+  }
+}

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/overview/toolbar.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/overview/toolbar.jsp?view=diff&rev=492676&r1=492675&r2=492676
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/overview/toolbar.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/overview/toolbar.jsp Thu Jan  4 10:42:13
2007
@@ -98,8 +98,8 @@
         <tc:toolBarCommand id="popupButton2"
             actionListener="#{overviewController.click}"
             label="#{overviewBundle.toolbar_popupButtonAction}">
-
-          <f:facet name="popup">
+           <tc:popupReference for=":page:popup" />
+          <%--f:facet name="popup">
             <tc:popup width="200" height="100" id="popup2" >
 
               <f:facet name="layout">
@@ -114,7 +114,7 @@
               </tc:button>
 
             </tc:popup>
-          </f:facet>
+          </f:facet--%>
         </tc:toolBarCommand>
 
         <tc:toolBarCommand id="DropDown2" action="overview/toolbar"



Mime
View raw message