myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r740926 - in /myfaces/tobago/branches/tobago-1.0.x: core/src/main/java/org/apache/myfaces/tobago/taglib/component/ example/facelets/src/main/webapp/ extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/
Date Wed, 04 Feb 2009 22:40:56 GMT
Author: bommel
Date: Wed Feb  4 22:40:55 2009
New Revision: 740926

URL: http://svn.apache.org/viewvc?rev=740926&view=rev
Log:
(TOBAGO-741) TabChangeListener doesn't work with facelets

Modified:
    myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTag.java
    myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java
    myfaces/tobago/branches/tobago-1.0.x/example/facelets/src/main/webapp/layout.xml
    myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeListenerHandler.java
    myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeSourceRule.java

Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTag.java?rev=740926&r1=740925&r2=740926&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTag.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTag.java
Wed Feb  4 22:40:55 2009
@@ -29,6 +29,8 @@
 import static org.apache.myfaces.tobago.component.UITabGroup.SWITCH_TYPE_RELOAD_PAGE;
 
 import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.application.Application;
 
 public class TabGroupTag extends TobagoTag
     implements TabGroupTagDeclaration {
@@ -40,6 +42,7 @@
   private String immediate;
   private String state;
   private String showNavigationBar;
+  private String tabChangeListener;
 
   @Override
   public String getComponentType() {
@@ -54,6 +57,12 @@
     ComponentUtil.setStringProperty(component, ATTR_SWITCH_TYPE, switchType);
     ComponentUtil.setBooleanProperty(component, ATTR_IMMEDIATE, immediate);
     ComponentUtil.setBooleanProperty(component, ATTR_SHOW_NAVIGATION_BAR, showNavigationBar);
+    if (tabChangeListener != null && component instanceof  UITabGroup &&
isValueReference(tabChangeListener)) {
+      final Application application = FacesContext.getCurrentInstance().getApplication();
+      final javax.faces.el.MethodBinding methodBinding = application.createMethodBinding(tabChangeListener,
+          new Class[] { org.apache.myfaces.tobago.event.TabChangeEvent.class } );
+      ((UITabGroup)component).setTabChangeListener(methodBinding);
+    }
   }
 
   @Override
@@ -64,6 +73,7 @@
     immediate = null;
     selectedIndex = null;
     showNavigationBar = null;
+    tabChangeListener = null;
   }
 
   public void setServerside(String serverside) {
@@ -95,5 +105,13 @@
   public void setShowNavigationBar(String showNavigationBar) {
     this.showNavigationBar = showNavigationBar;
   }
+
+  public String getTabChangeListener() {
+    return tabChangeListener;
+  }
+
+  public void setTabChangeListener(final String tabChangeListener) {
+    this.tabChangeListener = tabChangeListener;
+  }
 }
 

Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java?rev=740926&r1=740925&r2=740926&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TabGroupTagDeclaration.java
Wed Feb  4 22:40:55 2009
@@ -22,6 +22,7 @@
 import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.DynamicExpression;
 import org.apache.myfaces.tobago.component.UITabGroup;
 import org.apache.myfaces.tobago.taglib.decl.HasDeprecatedDimension;
 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
@@ -96,4 +97,10 @@
   @UIComponentTagAttribute(type = "java.lang.Integer")
   @Deprecated()
   void setState(String state);
+
+  @TagAttribute
+  @UIComponentTagAttribute(
+      type = "javax.faces.el.MethodBinding",
+      expression = DynamicExpression.METHOD_BINDING)
+  void setTabChangeListener(String listener);
 }

Modified: myfaces/tobago/branches/tobago-1.0.x/example/facelets/src/main/webapp/layout.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/example/facelets/src/main/webapp/layout.xml?rev=740926&r1=740925&r2=740926&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/example/facelets/src/main/webapp/layout.xml (original)
+++ myfaces/tobago/branches/tobago-1.0.x/example/facelets/src/main/webapp/layout.xml Wed Feb
 4 22:40:55 2009
@@ -18,7 +18,7 @@
         <tc:tabChangeListener
             type="org.apache.myfaces.tobago.example.facelets.TestTabChangeListener"
             binding="#{tabController.listener}"
-            listener="#{tabController.changeTab}"/>
+            listener="#{tabController.processTabChange}"/>
         <tc:tab label="Demo">
           <f:facet name="layout">
             <tc:gridLayout

Modified: myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeListenerHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeListenerHandler.java?rev=740926&r1=740925&r2=740926&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeListenerHandler.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeListenerHandler.java
Wed Feb  4 22:40:55 2009
@@ -24,12 +24,14 @@
 import com.sun.facelets.tag.TagException;
 import com.sun.facelets.FaceletContext;
 import com.sun.facelets.el.LegacyValueBinding;
+import com.sun.facelets.el.LegacyMethodBinding;
 
 import java.io.IOException;
 
 import org.apache.myfaces.tobago.event.TabChangeSource;
 import org.apache.myfaces.tobago.event.TabChangeListener;
 import org.apache.myfaces.tobago.event.TabChangeListenerValueBindingDelegate;
+import org.apache.myfaces.tobago.event.TabChangeEvent;
 
 import javax.faces.FacesException;
 import javax.faces.component.UIComponent;
@@ -43,17 +45,22 @@
  */
 public class TabChangeListenerHandler extends TagHandler {
 
+  private static final Class[] TAB_CHANGE_LISTENER_ARGS = new Class[] {TabChangeEvent.class};
+
   private Class listenerType;
 
   private final TagAttribute type;
 
   private final TagAttribute binding;
 
+  private final TagAttribute listener;
+
 
   public TabChangeListenerHandler(TagConfig config) {
     super(config);
     binding = getAttribute("binding");
     type = getAttribute("type");
+    listener = getAttribute("listener");
     if (type != null) {
       if (!type.isLiteral()) {
         throw new TagAttributeException(tag, type, "Must be literal");
@@ -72,28 +79,33 @@
       // only process if parent was just created
       if (parent.getParent() == null) {
         TabChangeSource changeSource = (TabChangeSource) parent;
-        TabChangeListener listener = null;
+        TabChangeListener changeListener = null;
         ValueExpression valueExpression = null;
         if (binding != null) {
           valueExpression = binding.getValueExpression(faceletContext, TabChangeListener.class);
-          listener = (TabChangeListener) valueExpression.getValue(faceletContext);
+          changeListener = (TabChangeListener) valueExpression.getValue(faceletContext);
         }
-        if (listener == null) {
+        if (changeListener == null) {
           try {
-            listener = (TabChangeListener) listenerType.newInstance();
+            changeListener = (TabChangeListener) listenerType.newInstance();
           } catch (Exception e) {
             throw new TagAttributeException(tag, type, e.getCause());
           }
           if (valueExpression != null) {
-            valueExpression.setValue(faceletContext, listener);
+            valueExpression.setValue(faceletContext, changeListener);
           }
         }
         if (valueExpression != null) {
           changeSource.addTabChangeListener(new TabChangeListenerValueBindingDelegate(type.getValue(),
               new LegacyValueBinding(valueExpression)));
         } else {
-          changeSource.addTabChangeListener(listener);
+          changeSource.addTabChangeListener(changeListener);
         }
+        if (listener != null && !listener.isLiteral()) {
+          changeSource.setTabChangeListener(new LegacyMethodBinding(
+              listener.getMethodExpression(faceletContext, null, TAB_CHANGE_LISTENER_ARGS)));
+        }
+
       }
     } else {
       throw new TagException(tag, "Parent is not of type TabChangeSource, type is: " + parent);

Modified: myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeSourceRule.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeSourceRule.java?rev=740926&r1=740925&r2=740926&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeSourceRule.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeSourceRule.java
Wed Feb  4 22:40:55 2009
@@ -27,13 +27,12 @@
 import org.apache.myfaces.tobago.event.TabChangeEvent;
 
 /*
- * User: bommel
  * Date: 15.04.2006
  * Time: 14:24:54
  */
 public class TabChangeSourceRule extends MetaRule {
   static final Class[] ACTION_LISTENER = new Class[]{TabChangeEvent.class};
-  public static final SortActionSourceRule INSTANCE = new SortActionSourceRule();
+  public static final TabChangeSourceRule INSTANCE = new TabChangeSourceRule();
 
   public Metadata applyRule(String name, TagAttribute attribute,
       MetadataTarget metadataTarget) {



Mime
View raw message