Author: abelevich
Date: 2009-08-26 10:52:55 -0400 (Wed, 26 Aug 2009)
New Revision: 15316
Removed:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
Log:
add AjaxClientBehavior support to the buildEventOption utility function
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-08-26
13:36:01 UTC (rev 15315)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-08-26
14:52:55 UTC (rev 15316)
@@ -328,9 +328,44 @@
public abstract String getAttributeValue(UIComponent component);
}
+ private static enum BehaviorEventOptionsData {
+ begin {
+ @Override
+ public String getAttributeValue(AjaxClientBehavior behavior) {
+ return behavior.getOnbegin();
+ }
+ },
+
+ beforedomupdate {
+ @Override
+ public String getAttributeValue(AjaxClientBehavior behavior) {
+ return behavior.getOnBeforeDomUpdate();
+ }
+ },
+
+ complete {
+ @Override
+ public String getAttributeValue(AjaxClientBehavior behavior) {
+ return behavior.getOncomplete();
+ }
+ },
+
+ error {
+ @Override
+ public String getAttributeValue(AjaxClientBehavior behavior) {
+ return behavior.getOnerror();
+ }
+ },
+
+ event {
+ @Override
+ public String getAttributeValue(AjaxClientBehavior behavior) {
+ return behavior.getOnevent();
+ }
+ };
+ public abstract String getAttributeValue(AjaxClientBehavior behavior);
+ }
-
-
public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
AjaxClientBehavior ajaxBehavior, UIComponent component) {
AjaxEventOptions ajaxEventOptions = new AjaxEventOptions();
@@ -340,7 +375,7 @@
if(ajaxBehavior != null) {
ajaxStatusName = ajaxBehavior.getStatusId() != null ? ajaxBehavior.getStatusId() :
ajaxStatusName;
-
+ appenAjaxBehaviorParams(facesContext, ajaxBehavior, ajaxEventOptions);
} else {
appendBehaviorParams(facesContext, component, ajaxEventOptions, parametersMap);
}
@@ -355,8 +390,15 @@
return ajaxEventOptions;
}
+ private static void appenAjaxBehaviorParams(FacesContext context, AjaxClientBehavior
behavior, AjaxEventOptions ajaxEventOptions) {
+ for(BehaviorEventOptionsData optionsData : BehaviorEventOptionsData.values()) {
+ String eventHandlerValue = optionsData.getAttributeValue(behavior);
+ if(isNonEmpty(eventHandlerValue)) {
+ ajaxEventOptions.set(optionsData.toString(), eventHandlerValue);
+ }
+ }
+ }
-
private static void appendBehaviorParams(FacesContext facesContext, UIComponent
component, AjaxEventOptions ajaxEventOptions, Map<String, Object> parametersMap)
{
Collection<Parameter> behaviorParametersList = null;
Map<String, List<ClientBehavior>> behaviorsMap = Collections.EMPTY_MAP; /*
null object */
Deleted:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java 2009-08-26
13:36:01 UTC (rev 15315)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java 2009-08-26
14:52:55 UTC (rev 15316)
@@ -1,115 +0,0 @@
-package org.ajax4jsf.renderkit;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.component.AjaxClientBehavior;
-
-
-/**
- * @author Anton Belevich
- *
- * @param <A>
- * @param <T>
- *
- * interface for accessors implementation
- */
-public interface CommonAttributesAccessor <A,T> {
-
-
- public String getOnComplete(A a, T t);
-
- public String getOnError(A a, T t);
-
- public String getOnBegin(A a, T t);
-
- public String getOnBeforeDomUpdate(A a, T t);
-
- public String getOnEvent(A a, T t);
-
- public String getStatusId(A a, T t);
-
-
- public static final CommonAttributesAccessor<AjaxClientBehavior, UIComponent> C =
new CommonAttributesAccessor<AjaxClientBehavior, UIComponent>() {
-
- public String getOnBeforeDomUpdate(AjaxClientBehavior a, UIComponent t) {
- String value = null;
-
- if(t != null) {
- value = AjaxRendererUtils.getAjaxOnBeforeDomUpdate(t);
- }
-
- if(a != null) {
- value = a.getOnBeforeDomUpdate();
- }
-
- return value;
- }
-
- public String getOnBegin(AjaxClientBehavior a, UIComponent t) {
- String value = null;
-
- if(t != null) {
- value = AjaxRendererUtils.getAjaxOncomplete(t);
- }
-
- if(a != null) {
- value = a.getOncomplete();
- }
-
- return value;
- }
-
- public String getOnComplete(AjaxClientBehavior a, UIComponent t) {
- String value = null;
-
- if(t != null) {
- value = AjaxRendererUtils.getAjaxOncomplete(t);
- }
-
- if(a != null) {
- value = a.getOncomplete();
- }
-
- return value;
- }
-
- public String getOnError(AjaxClientBehavior a, UIComponent t) {
- String value = null;
- if(t != null) {
- // TODO AjaxRenderUtils add getAjaxOnError(UIComponent component) method ??
- }
-
- if(a != null) {
- value = a.getOnerror();
- }
-
- return value;
- }
-
- public String getOnEvent(AjaxClientBehavior a, UIComponent t) {
- String value = null;
- if(t != null) {
- // TODO AjaxRenderUtils add getAjaxOnEvent(UIComponent component) method ??
- }
-
- if(a != null) {
- value = a.getOnevent();
- }
-
- return value;
- }
-
- public String getStatusId(AjaxClientBehavior a, UIComponent t) {
- String value = null;
- if(t != null) {
- AjaxRendererUtils.getAjaxStatus(t);
- }
-
- if(a != null) {
- a.getStatusId();
- }
-
- return value;
- }
- };
-}
Show replies by date