Author: maksimkaszynski
Date: 2008-03-18 12:32:49 -0400 (Tue, 18 Mar 2008)
New Revision: 6920
Modified:
trunk/ui/scrollableDataTable/src/main/config/component/scrollable-data-table.xml
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/model/internal/ComponentSortableDataModel.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/model/selection/ClientSelection.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableBaseRenderer.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableOptions.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/JSFComponentTest.java
trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableRendererStateTest.java
Log:
some code cleanup
Modified:
trunk/ui/scrollableDataTable/src/main/config/component/scrollable-data-table.xml
===================================================================
---
trunk/ui/scrollableDataTable/src/main/config/component/scrollable-data-table.xml 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/config/component/scrollable-data-table.xml 2008-03-18
16:32:49 UTC (rev 6920)
@@ -58,7 +58,7 @@
<defaultvalue>"500px"</defaultvalue>
</property>
- <property>
+ <property elonly="true">
<name>componentState</name>
<classname>org.ajax4jsf.model.DataComponentState</classname>
<description>It defines EL-binding for a component state for saving or
redefinition</description>
@@ -137,7 +137,7 @@
</description>
</property>
- <property attachedstate="true">
+ <property attachedstate="true" elonly="true">
<name>sortOrder</name>
<classname>org.richfaces.model.SortOrder</classname>
<description>
@@ -145,7 +145,7 @@
</description>
</property>
- <property attachedstate="true">
+ <property attachedstate="true" elonly="true">
<name>selection</name>
<classname>org.richfaces.model.selection.Selection</classname>
<description>Value binding representing selected rows</description>
@@ -168,7 +168,7 @@
</description>
</property>
- <property>
+ <property el="false">
<name>rowKeyVar</name>
<classname>java.lang.String</classname>
<description>The attribute provides access to a row key in a Request
scope</description>
@@ -189,7 +189,7 @@
<description>The attribute is a representation of an identifier for a specific
data row</description>
</property>
- <property>
+ <property el="false">
<name>scriptVar</name>
<classname>java.lang.String</classname>
<description>Name of JavaScript variable corresponding to component
@@ -215,7 +215,7 @@
</description>
</property>
- <property>
+ <property el="false">
<name>stateVar</name>
<classname>java.lang.String</classname>
<description>
@@ -223,7 +223,7 @@
</description>
</property>
- <property hidden="true">
+ <property hidden="true" elonly="true">
<name>sortListener</name>
<classname>org.richfaces.event.sort.SortListener</classname>
@@ -232,7 +232,7 @@
</description>
</property>
- <property>
+ <property elonly="true">
<name>ajaxKeys</name>
<classname>java.util.Set</classname>
<description>This attribute defines row keys that are updated after an AJAX
request</description>
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -63,9 +63,9 @@
/**
* hold list of ranges previously accessed until updates are fully done for them
*/
- private List ranges;
+ private List<Range> ranges;
- private Collection responseData = new ArrayList();
+ private Collection<String> responseData = new ArrayList<String>();
private int reqRowsCount = -1;
@@ -77,11 +77,11 @@
public abstract void setSortOrder(SortOrder sortOrder) ;
- public Collection getResponseData() {
+ public Collection<String> getResponseData() {
return responseData;
}
- public void setResponseData(Collection responseData) {
+ public void setResponseData(Collection<String> responseData) {
this.responseData = responseData;
}
@@ -168,14 +168,14 @@
Object value = getValue();
- ScrollableTableDataModel model = null;
+ ScrollableTableDataModel<?> model = null;
if (value instanceof ScrollableTableDataModel) {
if (log.isDebugEnabled()) {
log.debug("Found instanceof " + value.getClass() + " will use it
unwrapped");
}
- model = (ScrollableTableDataModel) value;
+ model = (ScrollableTableDataModel<?>) value;
} else {
model = new ComponentSortableDataModel(getVar(), value);
@@ -209,19 +209,22 @@
}
+
+ @SuppressWarnings("unchecked")
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[])state;
super.restoreState(context, values[0]);
- ranges = ((List)values[1]);
+ ranges = ((List<Range>)values[1]);
scrollPos = (String)values[2];
sortListener = (SortListener) restoreAttachedState(context, values[3]);
}
- protected Iterator dataChildren() {
+ @SuppressWarnings("unchecked")
+ protected Iterator<UIComponent> dataChildren() {
IteratorChain chain = new IteratorChain();
chain.addIterator(getFacets().values().iterator());
- for (Iterator i = getChildren().iterator(); i.hasNext(); ) {
+ for (Iterator<UIComponent> i = getChildren().iterator(); i.hasNext(); ) {
UIComponent kid = (UIComponent)i.next();
if (kid instanceof Column) {
chain.addIterator(kid.getChildren().iterator());
@@ -231,10 +234,11 @@
return chain;
}
- protected Iterator fixedChildren() {
+ @SuppressWarnings("unchecked")
+ protected Iterator<UIComponent> fixedChildren() {
IteratorChain chain = new IteratorChain(getFacets().values().iterator());
- for (Iterator i = getChildren().iterator(); i.hasNext(); ) {
+ for (Iterator<UIComponent> i = getChildren().iterator(); i.hasNext(); ) {
UIComponent kid = (UIComponent)i.next();
if (kid instanceof Column) {
chain.addIterator(kid.getFacets().values().iterator());
@@ -311,7 +315,7 @@
Range visitedRange = getComponentState().getRange();
if(ranges == null){
- ranges = new ArrayList();
+ ranges = new ArrayList<Range>();
}
if(!ranges.contains(visitedRange)){
@@ -320,7 +324,7 @@
if(useSavedRanges){
- for (Iterator iter = ranges.iterator(); iter.hasNext();) {
+ for (Iterator<Range> iter = ranges.iterator(); iter.hasNext();) {
ScrollableTableDataRange range = (ScrollableTableDataRange) iter.next();
if (log.isDebugEnabled()) {
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -45,8 +45,8 @@
sortOrder = new SortOrder();
grid.setSortOrder(sortOrder);
- if (grid.getValueBinding("sortOrder") != null) {
- grid.getValueBinding("sortOrder").setValue(FacesContext.getCurrentInstance(),
sortOrder);
+ if (grid.getValueExpression("sortOrder") != null) {
+ grid.getValueExpression("sortOrder").setValue(FacesContext.getCurrentInstance().getELContext(),
sortOrder);
}
}
@@ -60,10 +60,10 @@
fields = new SortField[] {new SortField(name, columnIndex, nextSortOrder(null,
suggested))};
} else {
- List newFields = new LinkedList(Arrays.asList(fields));
+ List<SortField> newFields = new
LinkedList<SortField>(Arrays.asList(fields));
SortField newField = null;
- for (Iterator iterator = newFields.iterator(); iterator.hasNext() && newField
== null; ) {
+ for (Iterator<SortField> iterator = newFields.iterator(); iterator.hasNext()
&& newField == null; ) {
SortField sortField = (SortField) iterator.next();
if (sortField.getIndex() == columnIndex ||
(sortField.getName() != null &&
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -38,8 +38,8 @@
sortOrder = new SortOrder();
grid.setSortOrder(sortOrder);
- if (grid.getValueBinding("sortOrder") != null) {
- grid.getValueBinding("sortOrder").setValue(FacesContext.getCurrentInstance(),
sortOrder);
+ if (grid.getValueExpression("sortOrder") != null) {
+ grid.getValueExpression("sortOrder").setValue(FacesContext.getCurrentInstance().getELContext(),
sortOrder);
}
}
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/model/internal/ComponentSortableDataModel.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/model/internal/ComponentSortableDataModel.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/model/internal/ComponentSortableDataModel.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -39,7 +39,7 @@
* @author Maksim Kaszynski
*
*/
-public class ComponentSortableDataModel extends ScrollableTableDataModel {
+public class ComponentSortableDataModel extends ScrollableTableDataModel<Object> {
/**
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/model/selection/ClientSelection.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/model/selection/ClientSelection.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/model/selection/ClientSelection.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -26,7 +26,7 @@
private int activeRowIndex = -1;
- private List ranges = new ArrayList();
+ private List<SelectionRange> ranges = new ArrayList<SelectionRange>();
public ClientSelection() {
}
@@ -38,14 +38,14 @@
public boolean isSelected(int i) {
boolean result = false;
- Iterator iterator = ranges.iterator();
+ Iterator<SelectionRange> iterator = ranges.iterator();
while (iterator.hasNext() && !result) {
result |= ((SelectionRange) iterator.next()).within(i);
}
return result;
}
- public List getRanges() {
+ public List<SelectionRange> getRanges() {
return ranges;
}
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -35,7 +35,7 @@
try {
if(component instanceof UIScrollableDataTable){
- for (Iterator iter = component.getChildren().iterator(); iter.hasNext(); ) {
+ for (Iterator<UIComponent> iter = component.getChildren().iterator();
iter.hasNext(); ) {
UIComponent kid = (UIComponent) iter.next();
if (kid.isRendered()) {
if (kid instanceof Column){
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableBaseRenderer.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableBaseRenderer.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableBaseRenderer.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -319,7 +319,7 @@
ajaxContext.getResponseData();
UIScrollableDataTable grid = state.getGrid();
- Collection collection = grid.getResponseData();
+ Collection<String> collection = grid.getResponseData();
grid.setRowKey(rowKey);
ResponseWriter writer = context.getResponseWriter();
@@ -329,7 +329,7 @@
String baseClientId = grid.getBaseClientId(context);
- for (Iterator iter = grid.getChildren().iterator(); iter.hasNext(); ) {
+ for (Iterator<UIComponent> iter = grid.getChildren().iterator(); iter.hasNext();
) {
UIComponent kid = (UIComponent) iter.next();
if (kid.isRendered()) {
@@ -385,7 +385,7 @@
private void writeNormalTr(boolean frozenTRRendered,
ScrollableDataTableRendererState state,
- UIScrollableDataTable grid, Collection collection,
+ UIScrollableDataTable grid, Collection<String> collection,
ResponseWriter writer, String baseClientId) throws IOException {
String row_id;
if(frozenTRRendered){
@@ -571,13 +571,15 @@
ScrollableDataTableRendererState.restoreState(context);
}
-
public String getRowsAjaxUpdate(FacesContext context, UIScrollableDataTable grid){
JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
- Map options = AjaxRendererUtils.buildEventOptions(context, grid);
+ Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context,
grid);
options.put("oncomplete", AjaxFunctionBuilder.getOnComplete(context, grid,
AjaxFunctionBuilder.SCROLL));
- Map parametersMap = (Map)options.get("parameters");
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> parametersMap = (Map<String, Object>)
options.get("parameters");
+
parametersMap.put(grid.getBaseClientId(context) + ":scroll", "");
function.addParameter(options);
String completeFunction = function.toScript()+"; return false;";
@@ -603,7 +605,7 @@
ExternalContext externalContext = context.getExternalContext();
String clientId = grid.getClientId(context);
boolean sorted = false;
- Map parameters = externalContext.getRequestParameterMap();
+ Map<String, String> parameters = externalContext.getRequestParameterMap();
String s_id = clientId + ":si";
grid.resetReqRowsCount();
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableOptions.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableOptions.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableOptions.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -75,9 +75,10 @@
JSReference sortStartRow = new JSReference("event.startRow");
JSReference sortIndex = new JSReference("event.index");
- Map options = AjaxRendererUtils.buildEventOptions(context, grid);
+ Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context,
grid);
- Map parametersMap = (Map)options.get("parameters");
+ @SuppressWarnings("unchecked")
+ Map<String, Object> parametersMap = (Map)options.get("parameters");
String id = grid.getClientId(context);
parametersMap.put(id + ":sortColumn", sortColumn);
parametersMap.put(id + ":sortOrder", sortOrder);
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -3,8 +3,8 @@
*/
package org.richfaces.renderkit.html;
-import java.util.Collection;
import java.util.HashSet;
+import java.util.Set;
import javax.faces.FacesException;
import javax.faces.component.NamingContainer;
@@ -30,7 +30,7 @@
private boolean fake;
- private HashSet ids = new HashSet();
+ private Set<String> ids = new HashSet<String>();
private String rowClasses[];
@@ -46,8 +46,6 @@
private int _columns = 0;
- private Collection collection;
-
private Integer sepOffset;
private String _cell_id_prefix;
@@ -373,14 +371,7 @@
this.sepOffset = sepOffset;
}
- public Collection getCollection() {
- return collection;
- }
-
- public void setCollection(Collection collection) {
- this.collection = collection;
- }
-
+
public boolean isFake() {
return fake;
}
@@ -432,7 +423,7 @@
}
}
- public HashSet getIds() {
+ public Set<String> getIds() {
return ids;
}
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -6,6 +6,7 @@
import java.io.IOException;
import java.util.Map;
+import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
@@ -13,7 +14,6 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
-import javax.faces.el.ValueBinding;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.model.DataVisitor;
@@ -48,7 +48,7 @@
final UIScrollableDataTable grid = (UIScrollableDataTable) component;
ExternalContext externalContext = context.getExternalContext();
- Map requestParamMap = externalContext.getRequestParameterMap();
+ Map<String, String> requestParamMap = externalContext.getRequestParameterMap();
Application application = context.getApplication();
String id = getSelectionInputName(context, grid);
@@ -117,9 +117,9 @@
grid.setSelection(simpleSelection);
- ValueBinding selectionBinding = grid.getValueBinding("selection");
+ ValueExpression selectionBinding = grid.getValueExpression("selection");
if (selectionBinding != null) {
- selectionBinding.setValue(context, simpleSelection);
+ selectionBinding.setValue(context.getELContext(), simpleSelection);
}
ScrollableDataTableRendererState.restoreState(context);
@@ -130,7 +130,7 @@
*
* @see org.richfaces.renderkit.RendererContributor#getAcceptableClass()
*/
- public Class getAcceptableClass() {
+ public Class<?> getAcceptableClass() {
return UIScrollableDataTable.class;
}
@@ -168,7 +168,7 @@
ScriptOptions scriptOptions = new ScriptOptions(component);
scriptOptions.addOption("selectionInput", getSelectionInputName(
context, (UIScrollableDataTable) component));
- Map attributes = component.getAttributes();
+ Map<String, Object> attributes = component.getAttributes();
Object attribut = attributes.get("selectedClass");
if (attribut == null) {
attribut = "";
Modified:
trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/JSFComponentTest.java
===================================================================
---
trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/JSFComponentTest.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/JSFComponentTest.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -1,9 +1,6 @@
package org.richfaces.renderkit.html;
-import junit.framework.Test;
import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import javax.faces.component.UIComponent;
/**
* Unit test for simple Component.
Modified:
trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableRendererStateTest.java
===================================================================
---
trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableRendererStateTest.java 2008-03-18
16:25:42 UTC (rev 6919)
+++
trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableRendererStateTest.java 2008-03-18
16:32:49 UTC (rev 6920)
@@ -1,12 +1,7 @@
package org.richfaces.renderkit.html;
-import java.util.ArrayList;
-import java.util.Collection;
-
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.context.AjaxContextImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.richfaces.component.UIScrollableDataTable;
@@ -170,12 +165,6 @@
assertEquals(i, state.getSepOffset());
}
- public void testGetCollection() {
- Collection collection = new ArrayList();
- state.setCollection(collection);
- assertEquals(collection, state.getCollection());
- }
-
public void testIsFake() {
boolean fake = true;
state.setFake(fake);