Author: abelevich
Date: 2009-08-25 17:10:30 -0400 (Tue, 25 Aug 2009)
New Revision: 15303
Added:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAtributesAccessorImpl.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java
Log:
accessor
Added:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAtributesAccessorImpl.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAtributesAccessorImpl.java
(rev 0)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAtributesAccessorImpl.java 2009-08-25
21:10:30 UTC (rev 15303)
@@ -0,0 +1,103 @@
+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;
+ }
+
+}
Added:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java
(rev 0)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/CommonAttributesAccessor.java 2009-08-25
21:10:30 UTC (rev 15303)
@@ -0,0 +1,28 @@
+package org.ajax4jsf.renderkit;
+
+
+/**
+ * @author Anton Belevich
+ *
+ * @param <A>
+ * @param <T>
+ *
+ * interface for accessors implementation
+ */
+public interface CommonAttributesAccessor <A,T> {
+
+ public String getOnComplete(T t);
+
+ public String getOnError(T t);
+
+ public String getOnBegin(T t);
+
+ public String getOnBeforeDomUpdate(T t);
+
+ public String getOnEvent(T t);
+
+ public String getStatusId(T t);
+
+ public A getContext();
+
+}
Show replies by date