Author: blabno
Date: 2011-11-23 13:54:55 -0500 (Wed, 23 Nov 2011)
New Revision: 22993
Modified:
sandbox/trunk/ui/dashboard/ui/src/main/java/org/richfaces/component/AbstractDashboard.java
sandbox/trunk/ui/dashboard/ui/src/main/java/org/richfaces/renderkit/html/DashboardRenderer.java
Log:
Support for immediate attribute and fix to rendering children other then columns.
Modified:
sandbox/trunk/ui/dashboard/ui/src/main/java/org/richfaces/component/AbstractDashboard.java
===================================================================
---
sandbox/trunk/ui/dashboard/ui/src/main/java/org/richfaces/component/AbstractDashboard.java 2011-11-23
17:56:45 UTC (rev 22992)
+++
sandbox/trunk/ui/dashboard/ui/src/main/java/org/richfaces/component/AbstractDashboard.java 2011-11-23
18:54:55 UTC (rev 22993)
@@ -36,10 +36,12 @@
import org.richfaces.renderkit.html.DashboardRenderer;
import javax.el.MethodExpression;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
@JsfComponent(tag = @Tag(name = "dashboard", handler =
"org.richfaces.view.facelets.html.DashboardTagHandler", generate = true, type =
TagType.Facelets),
fires = {@Event(value = PositionChangeEvent.class, listener =
PositionChangeListener.class)},
@@ -59,8 +61,7 @@
// -------------------------- OTHER METHODS --------------------------
@Override
- public void broadcast(FacesEvent event) throws AbortProcessingException
- {
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
if (event instanceof PositionChangeEvent) {
super.broadcast(event);
FacesContext facesContext = getFacesContext();
@@ -95,8 +96,29 @@
@Attribute(defaultValue = "true")
public abstract boolean isForcePlaceholderSize();
- private void setResponseData(Object data)
- {
+ @Override
+ public void queueEvent(FacesEvent event) {
+ UIComponent c = event.getComponent();
+ if (event instanceof PositionChangeEvent && c instanceof
AbstractDashboard) {
+ if (((AbstractDashboard) c).isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+ super.queueEvent(event);
+ }
+
+ /**
+ * If you are moving any object that is nested inside somethin iterable like
a4j:repeat and you set this to true
+ * then reordering of components will be done before applying request values which
means that values may get to wrong places.
+ *
+ * @return true if listener is to be notified during APPLY_REQUEST_VALUES phase;
false if in INVOKE_APPLICATION
+ */
+ @Attribute(defaultValue = "false")
+ protected abstract boolean isImmediate();
+
+ private void setResponseData(Object data) {
ExtendedPartialViewContext.getInstance(getFacesContext()).getResponseComponentDataMap().put(getClientId(getFacesContext()),
data);
}
}
Modified:
sandbox/trunk/ui/dashboard/ui/src/main/java/org/richfaces/renderkit/html/DashboardRenderer.java
===================================================================
---
sandbox/trunk/ui/dashboard/ui/src/main/java/org/richfaces/renderkit/html/DashboardRenderer.java 2011-11-23
17:56:45 UTC (rev 22992)
+++
sandbox/trunk/ui/dashboard/ui/src/main/java/org/richfaces/renderkit/html/DashboardRenderer.java 2011-11-23
18:54:55 UTC (rev 22993)
@@ -85,8 +85,7 @@
// -------------------------- OTHER METHODS --------------------------
@Override
- public void decode(FacesContext context, UIComponent component)
- {
+ public void decode(FacesContext context, UIComponent component) {
super.decode(context, component);
if (!component.isRendered()) {
return;
@@ -106,21 +105,18 @@
}
@Override
- public boolean getRendersChildren()
- {
+ public boolean getRendersChildren() {
return true;
}
- protected void addOptionIfSetAndNotDefault(String optionName, Object value,
Map<String, Object> options)
- {
+ protected void addOptionIfSetAndNotDefault(String optionName, Object value,
Map<String, Object> options) {
if (value != null && !"".equals(value) &&
!value.equals(DEFAULTS.get(optionName)) && !(value instanceof Collection
&& ((Collection) value).size() == 0)
&& !(value instanceof Map && ((Map) value).size() == 0)) {
options.put(optionName, value);
}
}
- protected Object createSubmitEventFunction(FacesContext context, AbstractDashboard
component)
- {
+ protected Object createSubmitEventFunction(FacesContext context, AbstractDashboard
component) {
ScriptString jsFunction;
Map<String, Object> params = new HashMap<String, Object>();
params.put(getFieldId(context, component, START_X_PARAM), new
JSReference(START_X_PARAM));
@@ -141,8 +137,7 @@
}
@Override
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException
- {
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
if (!(component instanceof AbstractDashboard)) {
return;
}
@@ -156,8 +151,7 @@
}
@Override
- protected void doEncodeChildren(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException
- {
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException {
for (UIComponent child : component.getChildren()) {
if (child instanceof UIColumn) {
if (!child.isRendered()) {
@@ -184,14 +178,13 @@
}
writer.endElement(HtmlConstants.DIV_ELEM);
} else {
- component.encodeAll(context);
+ child.encodeAll(context);
}
}
}
@Override
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException
- {
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
if (!(component instanceof AbstractDashboard)) {
return;
}
@@ -209,13 +202,11 @@
writer.endElement(HtmlConstants.DIV_ELEM);
}
- protected String getFieldId(FacesContext context, AbstractDashboard component, String
attribute)
- {
+ protected String getFieldId(FacesContext context, AbstractDashboard component, String
attribute) {
return RendererUtils.getInstance().clientId(context, component) +
UINamingContainer.getSeparatorChar(context) + attribute;
}
- protected Map<String, Object> getOptions(FacesContext context,
AbstractDashboard dashboard) throws IOException
- {
+ protected Map<String, Object> getOptions(FacesContext context,
AbstractDashboard dashboard) throws IOException {
/**
* Include only attributes that are actually set.
*/
@@ -228,8 +219,7 @@
return options;
}
- protected boolean isAjaxMode(AbstractDashboard component)
- {
+ protected boolean isAjaxMode(AbstractDashboard component) {
SwitchType mode = component.getSwitchType();
return SwitchType.ajax.equals(mode) || null == mode;
}