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 2007/09/17 21:45:49 UTC
svn commit: r576566 - in
/myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets:
SuggestMethodRule.java TobagoComponentHandler.java
Author: bommel
Date: Mon Sep 17 12:45:48 2007
New Revision: 576566
URL: http://svn.apache.org/viewvc?rev=576566&view=rev
Log:
(TOBAGO-489) Add suggestMethod support for facelets lib
Added:
myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java
Modified:
myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java
Added: myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java?rev=576566&view=auto
==============================================================================
--- myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java (added)
+++ myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SuggestMethodRule.java Mon Sep 17 12:45:48 2007
@@ -0,0 +1,58 @@
+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.LegacyMethodBinding;
+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.component.UIInput;
+
+/**
+ * Date: Sep 17, 2007
+ * Time: 8:59:29 PM
+ */
+public class SuggestMethodRule extends MetaRule {
+ static final Class[] SUGGEST_METHOD = new Class[]{String.class};
+ public static final SuggestMethodRule INSTANCE = new SuggestMethodRule();
+
+ public Metadata applyRule(String name, TagAttribute attribute,
+ MetadataTarget metadataTarget) {
+ if (metadataTarget.isTargetInstanceOf(UIInput.class)) {
+ if ("suggestMethod".equals(name)) {
+ return new SuggestMethodMapper(attribute);
+ }
+ }
+ return null;
+ }
+
+ static final class SuggestMethodMapper extends Metadata {
+ private final TagAttribute attribute;
+
+ public SuggestMethodMapper(TagAttribute attribute) {
+ this.attribute = attribute;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIInput) instance).setSuggestMethod(new LegacyMethodBinding(attribute.getMethodExpression(ctx,
+ null, SuggestMethodRule.SUGGEST_METHOD)));
+ }
+ }
+}
Modified: myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java?rev=576566&r1=576565&r2=576566&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java (original)
+++ myfaces/tobago/trunk/extension/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java Mon Sep 17 12:45:48 2007
@@ -17,22 +17,22 @@
* limitations under the License.
*/
-import com.sun.facelets.tag.jsf.ComponentHandler;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.MetaRuleset;
import com.sun.facelets.FaceletContext;
-import org.apache.myfaces.tobago.event.SortActionSource;
-import org.apache.myfaces.tobago.event.TabChangeSource;
-import org.apache.myfaces.tobago.event.SheetStateChangeSource;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+import static org.apache.myfaces.tobago.TobagoConstants.TOBAGO_COMPONENT_CREATED;
import org.apache.myfaces.tobago.component.OnComponentCreated;
-import org.apache.myfaces.tobago.component.UIPage;
import org.apache.myfaces.tobago.component.SupportsMarkup;
-import static org.apache.myfaces.tobago.TobagoConstants.TOBAGO_COMPONENT_CREATED;
+import org.apache.myfaces.tobago.component.UIInput;
+import org.apache.myfaces.tobago.component.UIPage;
+import org.apache.myfaces.tobago.event.SheetStateChangeSource;
+import org.apache.myfaces.tobago.event.SortActionSource;
+import org.apache.myfaces.tobago.event.TabChangeSource;
import javax.faces.component.UIComponent;
/*
- * User: bommel
* Date: 15.04.2006
* Time: 13:31:39
*/
@@ -58,6 +58,9 @@
}
if (SupportsMarkup.class.isAssignableFrom(aClass)) {
metaRuleset.addRule(SupportsMarkupRule.INSTANCE);
+ }
+ if (UIInput.class.isAssignableFrom(aClass)) {
+ metaRuleset.addRule(SuggestMethodRule.INSTANCE);
}
return metaRuleset;
}