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 2011/09/06 23:41:46 UTC

svn commit: r1165871 - in /myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets: OrderByRule.java TobagoComponentHandler.java

Author: bommel
Date: Tue Sep  6 21:41:45 2011
New Revision: 1165871

URL: http://svn.apache.org/viewvc?rev=1165871&view=rev
Log:
(TOBAGO-1023)
Exception if using orderBy attribute of UIMessage in a JDK 1.4 environment

Added:
    myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/OrderByRule.java
Modified:
    myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java

Added: myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/OrderByRule.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/OrderByRule.java?rev=1165871&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/OrderByRule.java (added)
+++ myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/OrderByRule.java Tue Sep  6 21:41:45 2011
@@ -0,0 +1,60 @@
+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.FaceletContext;
+import com.sun.facelets.el.ELAdaptor;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+import org.apache.myfaces.tobago.TobagoConstants;
+import org.apache.myfaces.tobago.component.UIMessages;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+
+public class OrderByRule extends MetaRule {
+
+  public static final OrderByRule INSTANCE = new OrderByRule();
+
+  public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget metadataTarget) {
+    if ("orderBy".equals(name)) {
+      return new OrderByRuleMapper(attribute);
+    }
+    return null;
+  }
+
+  static final class OrderByRuleMapper extends Metadata {
+
+    private final TagAttribute attribute;
+
+    public OrderByRuleMapper(TagAttribute attribute) {
+      this.attribute = attribute;
+    }
+
+    public void applyMetadata(FaceletContext ctx, Object instance) {
+      if (attribute.isLiteral()) {
+        ((UIMessages) instance).setOrderBy(UIMessages.OrderBy.parse(attribute.getValue()));
+      } else {
+        ValueExpression expression = attribute.getValueExpression(ctx, Object.class);
+        ELAdaptor.setExpression((UIComponent) instance, TobagoConstants.ATTR_ORDER_BY, expression);
+      }
+    }
+  }
+}

Modified: myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java?rev=1165871&r1=1165870&r2=1165871&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java Tue Sep  6 21:41:45 2011
@@ -25,6 +25,7 @@ import org.apache.myfaces.tobago.TobagoC
 import org.apache.myfaces.tobago.component.OnComponentCreated;
 import org.apache.myfaces.tobago.component.SupportsMarkup;
 import org.apache.myfaces.tobago.component.UIInput;
+import org.apache.myfaces.tobago.component.UIMessages;
 import org.apache.myfaces.tobago.component.UIPage;
 import org.apache.myfaces.tobago.event.SheetStateChangeSource;
 import org.apache.myfaces.tobago.event.SortActionSource;
@@ -62,6 +63,9 @@ public class TobagoComponentHandler exte
     if (UIInput.class.isAssignableFrom(aClass)) {
       metaRuleset.addRule(SuggestMethodRule.INSTANCE);
     }
+    if (UIMessages.class.isAssignableFrom(aClass)) {
+        metaRuleset.addRule(OrderByRule.INSTANCE);
+    }
     return metaRuleset;
   }
   protected void onComponentCreated(FaceletContext context, UIComponent component,