Author: alexsmirnov
Date: 2008-04-24 17:44:19 -0400 (Thu, 24 Apr 2008)
New Revision: 8144
Added:
trunk/framework/api/src/main/java/org/ajax4jsf/component/IterationStateHolder.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/toolTip/examples/withTable.xhtml
trunk/ui/dataTable/src/main/config/component/dataList.xml
trunk/ui/dataTable/src/main/config/component/dataTable.xml
Log:
fix
http://jira.jboss.com/jira/browse/RF-3054
Added: trunk/framework/api/src/main/java/org/ajax4jsf/component/IterationStateHolder.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/component/IterationStateHolder.java
(rev 0)
+++
trunk/framework/api/src/main/java/org/ajax4jsf/component/IterationStateHolder.java 2008-04-24
21:44:19 UTC (rev 8144)
@@ -0,0 +1,29 @@
+/**
+ *
+ */
+package org.ajax4jsf.component;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIData;
+
+/**
+ * In the original {@link UIData} component, only state for a {@link EditableValueHolder}
component saved for an iteration.
+ * In the Richfaces, we also save state for a components implemented this interface.
+ * @author asmirnov
+ *
+ */
+public interface IterationStateHolder {
+
+ /**
+ * Get component state for a current iteration.
+ * @return request-scope component state. Details are subject for a component
implementation
+ */
+ public Object getIterationState();
+
+ /**
+ * Restore component state from previsious saved value.
+ * @param state request-scope component state. Details are subject for a component
implementation
+ */
+ public void setIterationState( Object state);
+
+}
Property changes on:
trunk/framework/api/src/main/java/org/ajax4jsf/component/IterationStateHolder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2008-04-24
19:13:10 UTC (rev 8143)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2008-04-24
21:44:19 UTC (rev 8144)
@@ -98,14 +98,7 @@
Iterator<UIComponent> childIterator = dataChildren();
while (childIterator.hasNext()) {
UIComponent component = childIterator.next();
- // Special case for a Standard UIColumn component.
- if (component instanceof UIColumn ) {
- for (UIComponent child : component.getChildren() ) {
- processComponent(context, child, argument);
- }
- } else {
processComponent(context, component, argument);
- }
}
}
@@ -909,27 +902,29 @@
private void saveChildState(FacesContext faces, UIComponent c,
Map<String, SavedState> childState) {
- if (c instanceof EditableValueHolder && !c.isTransient()) {
+ if (!c.isTransient() && (c instanceof EditableValueHolder||c instanceof
IterationStateHolder)) {
String clientId = c.getClientId(faces);
SavedState ss = childState.get(clientId);
if (ss == null) {
ss = new SavedState();
childState.put(clientId, ss);
}
- ss.populate((EditableValueHolder) c);
+ if (c instanceof EditableValueHolder) {
+ ss.populate((EditableValueHolder) c);
+ }
+ if(c instanceof IterationStateHolder){
+ ss.populate((IterationStateHolder) c);
+ }
}
-
// continue hack
Iterator<UIComponent> itr = c.getChildren().iterator();
while (itr.hasNext()) {
saveChildState(faces, (UIComponent) itr.next(), childState);
}
- if (!(c instanceof UIColumn || c instanceof Column)) {
itr = c.getFacets().values().iterator();
while (itr.hasNext()) {
saveChildState(faces, (UIComponent) itr.next(), childState);
}
- }
}
/**
@@ -963,15 +958,20 @@
c.setId(id);
// hack
- if (c instanceof EditableValueHolder) {
- EditableValueHolder evh = (EditableValueHolder) c;
+ if (c instanceof EditableValueHolder || c instanceof IterationStateHolder) {
String clientId = c.getClientId(faces);
SavedState ss = childState.get(clientId);
- if (ss != null) {
+ if (ss == null) {
+ ss=NullState;
+ }
+ if (c instanceof EditableValueHolder) {
+ EditableValueHolder evh = (EditableValueHolder) c;
ss.apply(evh);
- } else {
- NullState.apply(evh);
}
+ if (c instanceof IterationStateHolder) {
+ IterationStateHolder ish = (IterationStateHolder) c;
+ ss.apply(ish);
+ }
}
// continue hack
@@ -979,12 +979,10 @@
while (itr.hasNext()) {
restoreChildState(faces, (UIComponent) itr.next(), childState);
}
- if (!(c instanceof UIColumn || c instanceof Column)) {
- itr = c.getFacets().values().iterator();
+ itr = c.getFacets().values().iterator();
while (itr.hasNext()) {
restoreChildState(faces, (UIComponent) itr.next(), childState);
}
- }
}
/**
@@ -1225,6 +1223,8 @@
private final static class SavedState implements Serializable {
private Object submittedValue;
+
+ private Object iterationState;
private static final long serialVersionUID = 2920252657338389849L;
@@ -1266,6 +1266,14 @@
this.localValueSet = localValueSet;
}
+ public Object getIterationState() {
+ return iterationState;
+ }
+
+ public void setIterationState(Object iterationState) {
+ this.iterationState = iterationState;
+ }
+
public String toString() {
return ("submittedValue: " + submittedValue + " value: " + value
+ " localValueSet: " + localValueSet);
@@ -1278,12 +1286,21 @@
this.localValueSet = evh.isLocalValueSet();
}
+
+ public void populate(IterationStateHolder ish) {
+ this.iterationState = ish.getIterationState();
+ }
+
public void apply(EditableValueHolder evh) {
evh.setValue(this.value);
evh.setValid(this.valid);
evh.setSubmittedValue(this.submittedValue);
evh.setLocalValueSet(this.localValueSet);
}
+
+ public void apply(IterationStateHolder ish) {
+ ish.setIterationState(this.iterationState);
+ }
}
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/toolTip/examples/withTable.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/toolTip/examples/withTable.xhtml 2008-04-24
19:13:10 UTC (rev 8143)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/toolTip/examples/withTable.xhtml 2008-04-24
21:44:19 UTC (rev 8144)
@@ -44,8 +44,8 @@
</style>
<h:form>
- <rich:dataTable value="#{toolTipData.vehicles}" width="400"
- var="vehicle" rowKeyVar="row">
+ <rich:dataTable value="#{data.mounths}" width="400"
+ var="item" rowKeyVar="row">
<rich:column>
<f:facet name="header">
<h:outputText value="##" />
@@ -54,56 +54,35 @@
</rich:column>
<rich:column>
<f:facet name="header">
- <h:outputText value="Make" />
+ <h:outputText value="Mounth" />
</f:facet>
<a4j:outputPanel layout="block">
<rich:toolTip direction="top-right" mode="ajax"
showDelay="300"
- styleClass="tooltip" layout="block">
+ styleClass="tooltip" layout="block">
+ <!--
<a4j:actionparam name="key" value="#{row}"
assignTo="#{toolTipData.currentVehicleIndex}" />
-
+ -->
<h:panelGrid columns="4">
<f:facet name="header">
- <h:outputText value="Vehicle details:" />
+ <h:outputText value="details:" />
</f:facet>
- <h:outputText value="make:" />
- <h:outputText value="#{vehicle.make}"
styleClass="tooltipData" />
- <h:outputText value="model:" />
- <h:outputText value="#{vehicle.model}"
styleClass="tooltipData" />
- <h:outputText value="year:" />
- <h:outputText value="#{vehicle.year}"
styleClass="tooltipData" />
- <h:outputText value="milage:" />
- <h:outputText value="#{vehicle.milage}"
styleClass="tooltipData" />
- <h:outputText value="zip:" />
- <h:outputText value="#{vehicle.zip}"
styleClass="tooltipData" />
- <h:outputText value="listed:" />
- <h:outputText value="#{vehicle.listed}"
styleClass="tooltipData">
- <f:convertDateTime dateStyle="short" />
- </h:outputText>
+ <h:outputText value="Mounth:" />
+ <h:outputText value="#{item.mounth}"
styleClass="tooltipData" />
+ <h:outputText value="price:" />
+ <h:outputText value="#{item.price}"
styleClass="tooltipData" />
<f:facet name="footer">
<h:panelGroup>
- <h:outputText value="vin: " />
- <h:outputText value="#{vehicle.vin}"
styleClass="tooltipData" />
+ <h:outputText value="Total: " />
+ <h:outputText value="#{item.total}"
styleClass="tooltipData" />
</h:panelGroup>
</f:facet>
</h:panelGrid>
</rich:toolTip>
- <h:outputText id="make" value="#{vehicle.make}"/>
+ <h:outputText id="make" value="#{item.mounth}"/>
</a4j:outputPanel>
</rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Model" />
- </f:facet>
- <h:outputText value="#{vehicle.model}" />
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Year" />
- </f:facet>
- <h:outputText value="#{vehicle.year}" />
- </rich:column>
</rich:dataTable>
</h:form>
Modified: trunk/ui/dataTable/src/main/config/component/dataList.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/dataList.xml 2008-04-24 19:13:10 UTC (rev
8143)
+++ trunk/ui/dataTable/src/main/config/component/dataList.xml 2008-04-24 21:44:19 UTC (rev
8144)
@@ -129,11 +129,12 @@
&html_universal_attributes;
&spec_table_attributes;
- <property>
- <name>rowKeyConverter</name>
- <classname>java.lang.String</classname>
- <description>Converter for a row key object</description>
- </property>
+ <property>
+ <name>rowKeyConverter</name>
+ <classname>javax.faces.convert.Converter</classname>
+ <description>Converter for a RowKey object.
+ </description>
+ </property>
<property>
<name>rowKey</name>
@@ -261,13 +262,13 @@
<name>headerClass</name>
<classname>java.lang.String</classname>
</property>
+ <property>
+ <name>rowKeyConverter</name>
+ <classname>javax.faces.convert.Converter</classname>
+ <description>Converter for a RowKey object.
+ </description>
+ </property>
<property>
- <name>rowKeyConverter</name>
- <classname>java.lang.String</classname>
- <description>Converter for a row key object</description>
- </property>
-
- <property>
<name>rowKey</name>
<classname>java.lang.Object</classname>
<description>RowKey is a representation of an identifier for a specific data
row</description>
Modified: trunk/ui/dataTable/src/main/config/component/dataTable.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/dataTable.xml 2008-04-24 19:13:10 UTC
(rev 8143)
+++ trunk/ui/dataTable/src/main/config/component/dataTable.xml 2008-04-24 21:44:19 UTC
(rev 8144)
@@ -209,5 +209,11 @@
<name>summary</name>
<classname>java.lang.Object</classname>
</property>
+ <property>
+ <name>rowKeyConverter</name>
+ <classname>javax.faces.convert.Converter</classname>
+ <description>Converter for a RowKey object.
+ </description>
+ </property>
</component>
</components>