Author: abelevich
Date: 2009-08-20 12:32:03 -0400 (Thu, 20 Aug 2009)
New Revision: 15238
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
Log:
a4j:ajax Behavior
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-08-20
16:31:07 UTC (rev 15237)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-08-20
16:32:03 UTC (rev 15238)
@@ -1,8 +1,80 @@
package org.ajax4jsf.component.behavior;
-import javax.faces.component.behavior.ClientBehaviorBase;
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.component.behavior.FacesBehavior;
+import javax.faces.context.FacesContext;
-public class AjaxBehavior extends ClientBehaviorBase {
+/**
+ * @author Anton Belevich
+ *
+ */
+(a)FacesBehavior(value="org.ajax4jsf.behavior.Ajax")
+public class AjaxBehavior extends javax.faces.component.behavior.AjaxBehavior {
+
+ public static final String BEHAVIOR_ID = "org.ajax4jsf.behavior.Ajax";
+ public static final String LIMIT_RENDER = "limitRender";
+
+ private boolean limitRender;
+
+ public boolean isLimitRender() {
+ if(this.limitRender) {
+ return this.limitRender;
+ }
+
+ ValueExpression ex = getValueExpression(LIMIT_RENDER);
+ if(ex != null) {
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+ Boolean value = ((Boolean)ex.getValue(elContext));
+ return value != null ? value.booleanValue() : false;
+ }
+
+ return this.limitRender;
+ }
+
+
+ public void setLimitRender(boolean limitRender) {
+ this.limitRender = limitRender;
+ clearInitialState();
+ }
+
+ @Override
+ public String getRendererType() {
+ return BEHAVIOR_ID;
+ }
+ @Override
+ public Object saveState(FacesContext context) {
+ Object superState = super.saveState(context);
+ Object[] values;
+
+ if (initialStateMarked()) {
+ if (superState == null) {
+ values = null;
+ } else {
+ values = new Object[] { superState };
+ }
+ } else {
+ values = new Object[1];
+ values[0] = superState;
+ values[1] = limitRender;
+ }
+
+ return values;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state) {
+ if (state != null) {
+
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+
+ if (values.length != 1) {
+ limitRender = ((Boolean)values[1]).booleanValue();
+ clearInitialState();
+ }
+ }
+ }
}
Show replies by date