Author: abelevich
Date: 2009-08-25 08:47:12 -0400 (Tue, 25 Aug 2009)
New Revision: 15294
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/facelets/tag/AjaxHandler.java
Log:
fix setters for queueId, statusId, similarityGroupingId, render, execute
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-25
12:30:48 UTC (rev 15293)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-08-25
12:47:12 UTC (rev 15294)
@@ -1,11 +1,15 @@
package org.ajax4jsf.component.behavior;
+import java.util.Collection;
+import java.util.Set;
+
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.component.behavior.FacesBehavior;
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxClientBehavior;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
/**
* @author Anton Belevich
@@ -16,14 +20,21 @@
public static final String BEHAVIOR_ID = "org.ajax4jsf.behavior.Ajax";
- public static final String LIMIT_RENDER = "limitRender";
+ private static enum Attributes {
+
+ limitRender, queueId, statusId, render, execute, similarityGroupingId, other;
+
+
+ public static Attributes toAttribute(String name) {
+
+ try {
+ return valueOf(name);
+ } catch (Exception ex) {
+ return other;
+ }
+ }
+ };
- public static final String QUEUE_ID = "queueId";
-
- public static final String STATUS_ID = "statusId";
-
- public static final String SIMILARITY_GROPING = "similarityGroupingId";
-
private Boolean limitRender;
private String queueId;
@@ -32,15 +43,57 @@
private String similarityGroupingId;
+ private Set <String> render;
+
+ private Set <String> execute;
+
+
+ protected Set<String> asSet(Object render) {
+ return AjaxRendererUtils.asSet(render);
+ }
+
+ public void setRender(Collection<String> render) {
+ this.render = asSet(render);
+ clearInitialState();
+ }
+
+ public Collection<String> getRender() {
+ return getCollectionValue(render, "RENDER");
+ }
+
+ public void setExecute(Collection<String> execute) {
+ this.execute = asSet(execute);
+ clearInitialState();
+ }
+
+ public Collection<String> getExecute() {
+ return getCollectionValue(execute, Attributes.execute.toString());
+ }
+
+ protected Collection<String> getCollectionValue(Collection<String>
collection, String attribute) {
+ if(collection != null) {
+ return collection;
+ }
+
+ ValueExpression ve = getValueExpression(attribute) ;
+ if(ve != null) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Object value = ve.getValue(context.getELContext());
+ return asSet(value);
+ }
+
+ return this.render;
+ }
+
public String getSimilarityGroupingId() {
if(this.similarityGroupingId != null) {
return this.similarityGroupingId;
}
- ValueExpression ex = getValueExpression(SIMILARITY_GROPING);
- if(ex != null) {
+ ValueExpression ve = getValueExpression(Attributes.similarityGroupingId.toString());
+ if(ve != null) {
ELContext elContext = FacesContext.getCurrentInstance().getELContext();
- String value = ((String)ex.getValue(elContext));
+ String value = ((String)ve.getValue(elContext));
return value;
}
@@ -57,10 +110,10 @@
return this.statusId;
}
- ValueExpression ex = getValueExpression(STATUS_ID);
- if(ex != null) {
+ ValueExpression ve = getValueExpression(Attributes.statusId.toString());
+ if(ve != null) {
ELContext elContext = FacesContext.getCurrentInstance().getELContext();
- String value = ((String)ex.getValue(elContext));
+ String value = ((String)ve.getValue(elContext));
return value;
}
@@ -77,10 +130,10 @@
return this.queueId;
}
- ValueExpression ex = getValueExpression(QUEUE_ID);
- if(ex != null) {
+ ValueExpression ve = getValueExpression(Attributes.queueId.toString());
+ if(ve != null) {
ELContext elContext = FacesContext.getCurrentInstance().getELContext();
- String value = ((String)ex.getValue(elContext));
+ String value = ((String)ve.getValue(elContext));
return value;
}
@@ -99,10 +152,10 @@
return this.limitRender.booleanValue();
}
- ValueExpression ex = getValueExpression(LIMIT_RENDER);
- if(ex != null) {
+ ValueExpression ve = getValueExpression(Attributes.limitRender.toString());
+ if(ve != null) {
ELContext elContext = FacesContext.getCurrentInstance().getELContext();
- Boolean value = ((Boolean)ex.getValue(elContext));
+ Boolean value = ((Boolean)ve.getValue(elContext));
return value != null ? value.booleanValue() : false;
}
@@ -121,6 +174,41 @@
}
@Override
+ public void setValueExpression(String name, ValueExpression expression) {
+ if(expression != null && expression.isLiteralText()) {
+ Object value = getExpressionLiteralValue(expression);
+ switch(Attributes.toAttribute(name)) {
+
+ case limitRender:
+ this.limitRender = value != null ? (Boolean)value : Boolean.FALSE ; break;
+
+ case execute :
+ this.execute = value != null ? asSet(value) : null; break;
+
+ case render :
+ this.render = value != null ? asSet(value) : null; break;
+
+ case queueId :
+ this.queueId = value != null ? (String)value : null; break;
+
+ case statusId :
+ this.statusId = value != null ? (String)value : null; break;
+
+ case similarityGroupingId :
+ this.similarityGroupingId = value != null ? (String)value: null; break;
+
+ default: break;
+
+ }
+ }
+ super.setValueExpression(name, expression);
+ }
+
+ protected Object getExpressionLiteralValue(ValueExpression expression) {
+ return expression != null ?
expression.getValue(FacesContext.getCurrentInstance().getELContext()) : null;
+ }
+
+ @Override
public Object saveState(FacesContext context) {
Object superState = super.saveState(context);
Object[] values;
@@ -132,35 +220,20 @@
values = new Object[] { superState };
}
} else {
- values = new Object[2];
+ values = new Object[7];
values[0] = superState;
values[1] = limitRender;
+ values[2] = execute;
+ values[3] = render;
+ values[4] = queueId;
+ values[5] = statusId;
+ values[6] = similarityGroupingId;
}
return values;
}
-
+
@Override
- public void setValueExpression(String name, ValueExpression expression) {
- if(expression != null && expression.isLiteralText()) {
- if(LIMIT_RENDER.equals(name)) {
- Object value = getExpressionLiteralValue(expression);
- this.limitRender = value != null ? (Boolean)value : Boolean.FALSE ;
- }
- }
- super.setValueExpression(name, expression);
- }
-
- protected Object getExpressionLiteralValue(ValueExpression expression) {
- Object value = null;
- if(expression != null) {
- ELContext elContext = FacesContext.getCurrentInstance().getELContext();
- value = expression.getValue(elContext);
- }
- return value;
- }
-
- @Override
public void restoreState(FacesContext context, Object state) {
if (state != null) {
@@ -168,7 +241,12 @@
super.restoreState(context, values[0]);
if (values.length != 1) {
- limitRender = ((Boolean)values[1]).booleanValue();
+ this.limitRender = ((Boolean)values[1]).booleanValue();
+ this.execute = asSet(values[2]);
+ this.render = asSet(values[3]);
+ this.queueId = (String)values[4];
+ this.statusId = (String)values[5];
+ this.similarityGroupingId = (String)values[6];
clearInitialState();
}
}
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2009-08-25
12:30:48 UTC (rev 15293)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2009-08-25
12:47:12 UTC (rev 15294)
@@ -111,7 +111,7 @@
} else if (parent instanceof ClientBehaviorHolder) {
applyAttachedObject(ctx, parent, eventName);
} else {
- throw new TagException(this.tag,"Unable to attach <f:ajax> to
non-ClientBehaviorHolder parent");
+ throw new TagException(this.tag,"Unable to attach <a4j:ajax> to
non-ClientBehaviorHolder parent");
}
}
Show replies by date