Author: abelevich
Date: 2009-08-26 06:53:57 -0400 (Wed, 26 Aug 2009)
New Revision: 15307
Removed:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAtributesAccessorImpl.java
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java
Log:
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
01:13:23 UTC (rev 15306)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-08-26
10:53:57 UTC (rev 15307)
@@ -50,6 +50,7 @@
import javax.servlet.http.HttpServletResponse;
import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.AjaxClientBehavior;
import org.ajax4jsf.component.AjaxComponent;
import org.ajax4jsf.component.AjaxContainer;
import org.ajax4jsf.component.AjaxLoadBundleComponent;
@@ -288,30 +289,21 @@
}
}
- public static <A,T> AjaxEventOptions buildEventOptions(T t ,
CommonAttributesAccessor<A, T> accessor) {
+ public static <A,T> AjaxEventOptions buildEventOptions(A a, T t ,
CommonAttributesAccessor<A, T> accessor) {
AjaxEventOptions ajaxEventOptions = new AjaxEventOptions();
- String ajaxStatusName = accessor.getStatusId(t);
+ String ajaxStatusName = accessor.getStatusId(a,t);
if(ajaxStatusName != null && ajaxStatusName.trim().length() != 0) {
ajaxEventOptions.set(STATUS_ATTR_NAME, ajaxStatusName);
}
-
- Map<String, Object> parameters = ajaxEventOptions.getParameters();
- A context = accessor.getContext();
-
- if(context instanceof ClientBehaviorContext) {
- UIComponent parent = ((ClientBehaviorContext) context).getComponent();
- FacesContext facesContext = ((ClientBehaviorContext) context).getFacesContext();
- appendParameters(facesContext, parent, parameters);
- } else if(context instanceof FacesContext){
- FacesContext facesContext = (FacesContext)context;
- appendParameters(facesContext, (UIComponent)t, parameters);
- }
+ appendParameters(FacesContext.getCurrentInstance(), (UIComponent)t,
ajaxEventOptions.getParameters());
return ajaxEventOptions;
}
- private static enum EventOptionsData {
+
+
+ private static enum EventOptionsData {
begin {
@Override
public String getAttributeValue(UIComponent component) {
@@ -336,20 +328,36 @@
public abstract String getAttributeValue(UIComponent component);
}
- public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
- UIComponent component) {
+
+
+
+ public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
AjaxClientBehavior ajaxBehavior, UIComponent component) {
AjaxEventOptions ajaxEventOptions = new AjaxEventOptions();
+ Map<String, Object> parametersMap = new LinkedHashMap<String, Object>();
String ajaxStatusName = getAjaxStatus(component);
+
+ if(ajaxBehavior != null) {
+ ajaxStatusName = ajaxBehavior.getStatusId() != null ? ajaxBehavior.getStatusId() :
ajaxStatusName;
+
+ } else {
+ appendBehaviorParams(facesContext, component, ajaxEventOptions, parametersMap);
+ }
+
if (ajaxStatusName != null && ajaxStatusName.length() != 0) {
ajaxEventOptions.set(STATUS_ATTR_NAME, ajaxStatusName);
}
-
- Map<String, Object> parametersMap = new LinkedHashMap<String, Object>();
+
appendParameters(facesContext, component, parametersMap);
ajaxEventOptions.getParameters().putAll(parametersMap);
+ return ajaxEventOptions;
+ }
+
+
+
+ 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 */
@@ -378,8 +386,6 @@
ajaxEventOptions.set(behaviorName, behaviorsChain);
}
}
-
- return ajaxEventOptions;
}
// public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
Deleted:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAtributesAccessorImpl.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAtributesAccessorImpl.java 2009-08-26
01:13:23 UTC (rev 15306)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAtributesAccessorImpl.java 2009-08-26
10:53:57 UTC (rev 15307)
@@ -1,103 +0,0 @@
-package org.ajax4jsf.renderkit;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.component.AjaxClientBehavior;
-
-
-/**
- * @author Anton Belevich
- *
- * @param <T>
- * accessor implementation for the component/behavior common attributes
- */
-public class CommonAtributesAccessorImpl <A,T> implements
CommonAttributesAccessor<A,T> {
-
- private A wrappedContext;
-
- public enum types {
- component, behavior;
-
- public static types type(Object obj) {
- if (obj instanceof UIComponent) {
- return component;
- } else if(obj instanceof AjaxClientBehavior) {
- return behavior;
- } else {
- return null;
- }
- }
- }
-
- public CommonAtributesAccessorImpl(A wrappedContext) {
- this.wrappedContext = wrappedContext;
- }
-
- public String getOnBeforeDomUpdate(T t) {
- switch (types.type(t)) {
- case component: return getComponentOnBeforeDomUpdate((UIComponent)t);
- case behavior: return getBehaviorOnBeforeDomUpdate((AjaxClientBehavior)t);
- default: return null;
- }
- }
-
- public String getOnBegin(T t) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getOnComplete(T t) {
- switch (types.type(t)) {
- case component: return getComponentOnComplete((UIComponent)t);
- case behavior: return getBehaviorOnComplete((AjaxClientBehavior)t);
- default: return null;
- }
- }
-
- public String getOnError(T t) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getOnEvent(T t) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getStatusId(T t) {
- switch (types.type(t)) {
- case component: return getComponentAjaxStatus((UIComponent)t);
- case behavior: return getBehaviorAjaxStatus((AjaxClientBehavior)t);
- default: return null;
- }
- }
-
- private String getComponentAjaxStatus(UIComponent component) {
- return AjaxRendererUtils.getAjaxStatus(component);
- }
-
- private String getBehaviorAjaxStatus(AjaxClientBehavior behavior) {
- return behavior.getStatusId();
- }
-
- private String getComponentOnComplete(UIComponent component) {
- return AjaxRendererUtils.getAjaxOncomplete(component);
- }
-
- private String getBehaviorOnComplete(AjaxClientBehavior behavior) {
- return behavior.getOncomplete();
- }
-
- private String getComponentOnBeforeDomUpdate(UIComponent component) {
- return AjaxRendererUtils.getAjaxOnBeforeDomUpdate(component);
- }
-
- private String getBehaviorOnBeforeDomUpdate(AjaxClientBehavior behavior) {
- return behavior.getOnBeforeDomUpdate();
- }
-
- public A getContext() {
- return wrappedContext;
- }
-
-}
Modified:
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
01:13:23 UTC (rev 15306)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java 2009-08-26
10:53:57 UTC (rev 15307)
@@ -1,6 +1,10 @@
package org.ajax4jsf.renderkit;
+import javax.faces.component.UIComponent;
+import org.ajax4jsf.component.AjaxClientBehavior;
+
+
/**
* @author Anton Belevich
*
@@ -10,19 +14,102 @@
* interface for accessors implementation
*/
public interface CommonAttributesAccessor <A,T> {
-
- public String getOnComplete(T t);
+
- public String getOnError(T t);
+ public String getOnComplete(A a, T t);
- public String getOnBegin(T t);
+ public String getOnError(A a, T t);
- public String getOnBeforeDomUpdate(T t);
+ public String getOnBegin(A a, T t);
- public String getOnEvent(T t);
+ public String getOnBeforeDomUpdate(A a, T t);
+
+ public String getOnEvent(A a, T t);
- public String getStatusId(T t);
+ public String getStatusId(A a, T t);
- public A getContext();
+
+ 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;
+ }
+ };
}