JBoss Rich Faces SVN: r9874 - trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable.
by richfaces-svn-commits@lists.jboss.org
Author: piotr.buda
Date: 2008-08-04 04:21:47 -0400 (Mon, 04 Aug 2008)
New Revision: 9874
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
Log:
Fixed multiple updateLayout calls after rerendering
Modified: trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-08-04 07:41:36 UTC (rev 9873)
+++ trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-08-04 08:21:47 UTC (rev 9874)
@@ -73,6 +73,7 @@
this.scrollingDiv = null;
this.groupRows = null;
this.groups = null;
+ Event.stopObserving(window, 'resize', this.eventContainerResize);
},
/**
@@ -327,6 +328,7 @@
},
updateLayout: function() {
+ ClientUILib.log(ClientUILogger.INFO, "updateLayout");
var table = this.table.getElement();
var outerDiv = this.outerDiv.getElement();
var cols = this.getColumns();
16 years, 4 months
JBoss Rich Faces SVN: r9873 - in trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces: renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: pgolawski
Date: 2008-08-04 03:41:36 -0400 (Mon, 04 Aug 2008)
New Revision: 9873
Added:
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/ExtendedDataTableState.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDraggableRendererContributor.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDropzoneRendererContributor.java
Removed:
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTableState.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DraggableRendererContributor.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DropzoneRendererContributor.java
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableDragDropRenderer.java
Log:
bugfix
Copied: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/ExtendedDataTableState.java (from rev 9871, trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTableState.java)
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/ExtendedDataTableState.java (rev 0)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/ExtendedDataTableState.java 2008-08-04 07:41:36 UTC (rev 9873)
@@ -0,0 +1,699 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.util.HtmlDimensions;
+import org.richfaces.model.Ordering;
+
+/**
+ * @author pawelgo
+ *
+ */
+public class ExtendedDataTableState implements Serializable {
+
+ private static final long serialVersionUID = -3103664821855261335L;
+
+ public static final String TABLE_STATE_ATTR_NAME = "tableState";
+
+ protected static final String SEP = ":";
+
+ protected ColumnsOrder columnsOrder;
+ protected ColumnsVisibility columnsVisibility;
+ protected ColumnsSizeState columnsSizeState;
+ protected ColumnGroupingState columnGroupingState;
+
+ public static ExtendedDataTableState getExtendedDataTableState(UIExtendedDataTable extendedDataTable){
+ ExtendedDataTableState state = new ExtendedDataTableState();
+ state.init(extendedDataTable);
+ return state;
+ }//init
+
+ /**
+ * Converts its state based on table attribute value or create default state if it is not set.
+ */
+ protected void init(UIExtendedDataTable extendedDataTable){
+ //get state value from components attributes
+ String value = (String)extendedDataTable.getAttributes().get(TABLE_STATE_ATTR_NAME);
+ //split state value into parts
+ String[] values = fromString(value);
+ //initialize columns order part
+ String val = (values != null && values.length>0) ? values[0] : null;
+ columnsOrder = ColumnsOrder.getColumnsOrder(extendedDataTable, val);
+ //initialize columns visibility part
+ val = (values != null && values.length>1) ? values[1] : null;
+ columnsVisibility = ColumnsVisibility.getColumnsVisibility(extendedDataTable, val);
+ //initialize columns size part
+ val = (values != null && values.length>2) ? values[2] : null;
+ columnsSizeState = ColumnsSizeState.getColumnsSize(extendedDataTable, val);
+ //initialize column grouping part
+ val = (values != null && values.length>3) ? values[3] : null;
+ columnGroupingState = ColumnGroupingState.getColumnGropingState(extendedDataTable, val);
+ }//init
+
+ /**
+ * Puts own state into component state.
+ */
+ public void publishChanges(FacesContext context, UIExtendedDataTable extendedDataTable){
+ ValueExpression ve = extendedDataTable.getValueExpression(TABLE_STATE_ATTR_NAME);
+ if ((null != ve) && (!ve.isReadOnly(context.getELContext()))) {
+ ve.setValue(context.getELContext(), toString());
+ }
+ }//publishChanges
+
+ /**
+ * Converts its state to String representation.
+ */
+ public String toString(){
+ String[] values = new String[4];
+ values[0] = columnsOrder.toString();
+ values[1] = columnsVisibility.toString();
+ values[2] = columnsSizeState.toString();
+ values[3] = columnGroupingState.toString();
+ StringBuilder builder = new StringBuilder();
+ for (String str : values){
+ builder.append(str).append(SEP);
+ }//for
+ return builder.toString();
+ }//toString
+
+ public String[] fromString(String value){
+ return (value == null) ? null : value.split(SEP);
+ }//fromString
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnsOrder#changeOrder(String, String)
+ */
+ public void changeColumnsOrder(String sourceColumnId, String targetColumnId, boolean dropBefore) {
+ columnsOrder.changeOrder(sourceColumnId, targetColumnId, dropBefore);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnsOrder#sortColumns(FacesContext, List)
+ */
+ public List<UIComponent> sortColumns(FacesContext context,
+ List<UIComponent> children) {
+ return columnsOrder.sortColumns(context, children);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnsVisibility#isVisible(String)
+ */
+ public boolean isColumnVisible(String columnId) {
+ return columnsVisibility.isVisible(columnId);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnsVisibility#toggleVisibility(UIExtendedDataTable, String)
+ */
+ public void toggleColumnVisibility(UIExtendedDataTable extendedDataTable,
+ String columnId) {
+ columnsVisibility.toggleVisibility(extendedDataTable, columnId);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnsSizeState#changeColumnSize(UIExtendedDataTable, String)
+ */
+ public void changeColumnSize(UIExtendedDataTable extendedDataTable,
+ String newValue) {
+ columnsSizeState.changeColumnSize(extendedDataTable, newValue);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnsSizeState#getColumnSize(UIComponent)
+ */
+ public String getColumnSize(UIComponent column) {
+ return columnsSizeState.getColumnSize(column);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnGroupingState#isGroupingOn()
+ */
+ public boolean isGroupingOn(){
+ return columnGroupingState.isGroupingOn();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnGroupingState#getGroupingColumnId()
+ */
+ public String getGroupingColumnId(){
+ return columnGroupingState.getGroupingColumnId();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnGroupingState#groupBy(String, Ordering)
+ */
+ public void groupBy(String colId, Ordering ordering) {
+ columnGroupingState.groupBy(colId, ordering);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnGroupingState#resetGroupVisibilityState()
+ */
+ public void resetGroupVisibilityState(){
+ columnGroupingState.resetGroupVisibilityState();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnGroupingState#disableGrouping()
+ */
+ public void disableGrouping(){
+ columnGroupingState.disableGrouping();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnGroupingState#groupIsExpanded(int)
+ */
+ public boolean groupIsExpanded(int index) {
+ return columnGroupingState.groupIsExpanded(index);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ColumnGroupingState#toggleGroup(int)
+ */
+ public void toggleGroup(int index) {
+ columnGroupingState.toggleGroup(index);
+ }
+
+
+}
+
+class ColumnsSizeState implements Serializable{
+
+ private static final long serialVersionUID = 8724163192351491340L;
+
+ private static final String SEP = ";";
+
+ private static final String DEFAULT_WIDTH = "100";
+
+ private String value;
+
+ private ColumnsSizeState() {
+ super();
+ }
+
+ static ColumnsSizeState getColumnsSize(UIExtendedDataTable extendedDataTable, String val){
+ ColumnsSizeState columnsSize = new ColumnsSizeState();
+ columnsSize.init(extendedDataTable, val);
+ return columnsSize;
+ }
+
+ /**
+ * Converts its state from String representation or create default state if it is not set.
+ */
+ private void init(UIExtendedDataTable extendedDataTable, String val){
+ value = val;
+ if ((value == null) || (value.length() == 0))
+ createDefaultColumnsSizeState(extendedDataTable);
+ }
+
+ /**
+ * Converts its state to String representation.
+ */
+ public String toString(){
+ return value;
+ }
+
+ /**
+ * Create default column order based on component children.
+ */
+ private void createDefaultColumnsSizeState(UIExtendedDataTable extendedDataTable){
+ StringBuilder builder = new StringBuilder();
+
+ for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
+ UIColumn col = iter.next();
+ builder.append(col.getId().toUpperCase()).append("-").append(getDefaultColumnSize(col)).append(SEP);
+ }
+ value = builder.toString();
+ }
+
+ private String getDefaultColumnSize(UIComponent column){
+ String widthStr = (String) column.getAttributes().get("width");
+ return formatWidth((widthStr == null || widthStr.length() == 0) ? DEFAULT_WIDTH : widthStr);
+ }
+
+ public String getColumnSize(UIComponent column){
+ if (value == null)
+ return getDefaultColumnSize(column);
+ String[] widths = value.split(SEP);
+ if (widths != null){
+ String colId = column.getId().toUpperCase();
+ for (String val : widths){
+ if (val.toUpperCase().startsWith(colId+"-")){
+ return formatWidth(val.split("-")[1]);
+ }
+ }//for
+ }
+ return getDefaultColumnSize(column);
+ }
+
+ private String formatWidth(String value){
+ return String.valueOf(HtmlDimensions.decode(value).intValue());
+ }
+
+ public void changeColumnSize(UIExtendedDataTable extendedDataTable, String newValue){
+ if (value == null)
+ return;
+ Set<String> widths = new HashSet<String>(Arrays.asList(value.toUpperCase().split(SEP)));
+ String[] newWidths = newValue.split(";");
+ int index = 0;
+ for (Iterator<UIColumn> iter = extendedDataTable.getSortedColumns(); iter.hasNext();) {
+ UIComponent col = (UIComponent) iter.next();
+ if (col.isRendered()){
+ String colId = col.getId().toUpperCase();
+ //remove existing item
+ Set<String> toDel = new HashSet<String>();
+ for (String val : widths){
+ if (val.toUpperCase().startsWith(colId+"-")){
+ toDel.add(val);
+ }
+ }//for
+ widths.removeAll(toDel);
+ //create new item
+ String newWidth = newWidths[index++];
+ String item = colId + "-" + newWidth;;
+ widths.add(item);
+ }//if
+ }//for
+ //build new value
+ StringBuilder builder = new StringBuilder();
+ for (String val : widths){
+ builder.append(val).append(SEP);
+ }
+ value = builder.toString();
+ }//changeColumnSize
+
+}//ColumnsSizeState
+
+class ColumnsOrder implements Serializable{
+
+ private static final long serialVersionUID = 907700564445889954L;
+
+ private static final String SEP = ";";
+
+ private String value;
+
+ private ColumnsOrder() {
+ super();
+ }
+
+ static ColumnsOrder getColumnsOrder(UIExtendedDataTable extendedDataTable, String val){
+ ColumnsOrder columnsOrder = new ColumnsOrder();
+ columnsOrder.init(extendedDataTable, val);
+ return columnsOrder;
+ }
+
+ /**
+ * Converts its state from String representation or create default state if it is not set.
+ */
+ private void init(UIExtendedDataTable extendedDataTable, String val){
+ value = val;
+ if ((value == null) || (value.length() == 0))
+ createDefaultColumnsOrder(extendedDataTable);
+ }
+
+ /**
+ * Converts its state to String representation.
+ */
+ public String toString(){
+ return value;
+ }
+
+ /**
+ * Create default column order based on component children.
+ */
+ private void createDefaultColumnsOrder(UIExtendedDataTable extendedDataTable){
+ StringBuilder builder = new StringBuilder();
+ for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
+ UIColumn child = iter.next();
+ builder.append(child.getId().toUpperCase()).append(SEP);
+ }
+ value = builder.toString();
+ }
+
+ /**
+ * Get column index in order.
+ * @param columnId column id to be found
+ * @return column index or null if not found
+ */
+ private Integer getColumnIndex(String columnId){
+ if (value == null)
+ return null;
+ List<String> list = Arrays.asList(value.toUpperCase().split(SEP));
+ if (list.contains(columnId.toUpperCase()))
+ return list.indexOf(columnId.toUpperCase());
+ return null;
+ }//getColumnIndex
+
+ /**
+ * Changes column order. Moves source column to be next to target column.
+ * @param sourceColumnId source column id to be moved
+ * @param targetColumnId target column id
+ * @param dropBefore
+ */
+ void changeOrder(String sourceColumnId, String targetColumnId, boolean dropBefore){
+ if (value == null)
+ return;
+ if (sourceColumnId.equals(targetColumnId))
+ return;
+ List<String> list = new ArrayList<String>(Arrays.asList(value.toUpperCase().split(SEP)));
+ //get index of source column
+ int sourceIndex = list.indexOf(sourceColumnId.toUpperCase());
+ //remove from order if exist
+ if (sourceIndex != -1)
+ list.remove(sourceIndex);
+ //get index of target column
+ int targetIndex = list.indexOf(targetColumnId.toUpperCase());
+ //add source column after or before target column
+ if (targetIndex == -1)//add to end
+ list.add(sourceColumnId.toUpperCase());
+ else{
+ //add at proper position
+ list.add((targetIndex + (dropBefore ? 0 : 1)), sourceColumnId.toUpperCase());
+ }
+ //convert from List to String
+ StringBuilder builder = new StringBuilder();
+ for (String str : list)
+ builder.append(str).append(SEP);
+ value = builder.toString();
+ }
+
+ /**
+ * Sort column by given order.
+ * @param context faces context
+ * @param children list of unsorted columns
+ * @return list of sorted columns
+ */
+ List<UIComponent> sortColumns(final FacesContext context, List<UIComponent> children){
+ List<UIComponent> childs = new ArrayList<UIComponent>(children);
+ Collections.sort(childs, new Comparator<UIComponent>() {
+ public int compare(UIComponent o1, UIComponent o2) {
+ Integer index1 = getColumnIndex(o1.getId());
+ Integer index2 = getColumnIndex(o2.getId());
+ if (index1 == null) {
+ return ((index2 == null) ? 0 : 1);
+ }
+ return ((index2 == null) ? -1 : index1.compareTo(index2));
+ }
+ });
+ return childs;
+ }
+
+}//ColumnsOrder
+
+class ColumnsVisibility implements Serializable{
+
+ private static final long serialVersionUID = -3923409650272094713L;
+
+ private static final String SEP = ";";
+
+ private String value;
+
+ private ColumnsVisibility() {
+ super();
+ }
+
+ static ColumnsVisibility getColumnsVisibility(UIExtendedDataTable extendedDataTable, String val){
+ ColumnsVisibility columnsVisibility = new ColumnsVisibility();
+ columnsVisibility.init(extendedDataTable, val);
+ return columnsVisibility;
+ }
+
+ /**
+ * Converts its state from String representation or create default state if it is not set.
+ */
+ private void init(UIExtendedDataTable extendedDataTable, String val){
+ value = val;
+ if ((value == null) || (value.length() == 0))
+ createDefaultColumnsVisibility(extendedDataTable);
+ //set visibility flag for all columns
+ for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
+ UIColumn child = iter.next();
+ if (child instanceof UIColumn) {
+ UIColumn dataColumn = (UIColumn) child;
+ dataColumn.setVisible(isVisible(dataColumn.getId()));
+ }//if
+ }//for
+ }//init
+
+ /**
+ * Converts its state to String representation.
+ */
+ public String toString(){
+ return value;
+ }
+
+ /**
+ * Create default column visibility based on component children.
+ */
+ private void createDefaultColumnsVisibility(UIExtendedDataTable extendedDataTable){
+ StringBuilder builder = new StringBuilder();
+ for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
+ UIColumn kid = iter.next();
+ builder.append(kid.getId().toUpperCase()).append(SEP);
+ }
+ value = builder.toString();
+ }//createDefaultColumnsVisibility
+
+ /**
+ * Get column visibility.
+ * @param columnId column id to be found
+ * @return true if column is visible, otherwise false
+ */
+ boolean isVisible(String columnId){
+ if (value == null)
+ return true;
+ Set<String> visibleIds = new HashSet<String>(Arrays.asList(value.toUpperCase().split(SEP)));
+ return visibleIds.contains(columnId.toUpperCase());
+ }//isVisible
+
+ /**
+ * Toggle column visibility.
+ * @param extendedDataTable table component
+ * @param columnId column id
+ */
+ void toggleVisibility(UIExtendedDataTable extendedDataTable, String columnId){
+ if (value == null)
+ return;
+ UIColumn column = null;
+ //find column by id
+ for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
+ UIColumn col = iter.next();
+ if (col.getId().equalsIgnoreCase(columnId)){
+ if (col instanceof UIColumn){
+ column = (UIColumn) col;
+ }
+ break;
+ }//if
+ }//for
+ if (column == null)
+ return;
+ boolean visible = column.isVisible();
+ //toggle visibility
+ visible = !visible;
+ //set visibility flag for column
+ column.setVisible(visible);
+ Set<String> visibleIds = new HashSet<String>(Arrays.asList(value.toUpperCase().split(SEP)));
+ if (visible){
+ //add id to set
+ visibleIds.add(columnId.toUpperCase());
+ }
+ else{
+ //remove id from list
+ visibleIds.remove(columnId.toUpperCase());
+ }
+ //convert from Set to String
+ StringBuilder builder = new StringBuilder();
+ for (String str : visibleIds)
+ builder.append(str).append(SEP);
+ value = builder.toString();
+ }//changeVisibility
+
+}//ColumnsVisibility
+
+class ColumnGroupingState implements Serializable{
+
+ private static final long serialVersionUID = -3923409650272094713L;
+
+ private static final String SEP = ";";
+ //private static final String TRUE = "1";
+ //private static final String FALSE = "0";
+ private static final Boolean DEF = Boolean.TRUE;//expanded
+
+ private String columnId;
+ private List<Boolean> groupExpanded;
+ private Ordering ordering;
+ //private String value;
+
+ private ColumnGroupingState() {
+ super();
+ }
+
+ static ColumnGroupingState getColumnGropingState(UIExtendedDataTable extendedDataTable, String val){
+ ColumnGroupingState groupingState = new ColumnGroupingState();
+ groupingState.init(extendedDataTable, val);
+ return groupingState;
+ }
+
+ /**
+ * Converts its state from String representation or create default state if it is not set.
+ */
+ private void init(UIExtendedDataTable extendedDataTable, String val){
+ columnId = null;
+ ordering = Ordering.UNSORTED;
+ groupExpanded = new ArrayList<Boolean>();
+ if ((val == null) || (val.length() == 0))
+ return;
+ List<String> tmp = Arrays.asList(val.split(SEP));
+ if (!tmp.isEmpty()){
+ columnId = tmp.get(0); //column id
+ ordering = Ordering.valueOf(tmp.get(1)); //sort order
+ if (ordering == null)
+ ordering = Ordering.UNSORTED;
+// tmp = tmp.subList(2, tmp.size());//remove fist and second item
+// for (String s : tmp){
+// groupExpanded.add(Boolean.valueOf(s.equals(TRUE)));
+// }//for
+ }
+ //get column by id and set sort order
+ for (Iterator<UIColumn> columns = extendedDataTable.getChildColumns(); columns.hasNext(); ){
+ UIColumn child = columns.next();
+ if (columnId.equalsIgnoreCase(child.getId())) {
+ child.setSortOrder(ordering);
+ break;
+ }
+ }
+ }//init
+
+ /**
+ * Converts its state to String representation.
+ */
+ public String toString(){
+ if (columnId == null)
+ return "";
+ StringBuilder builder = new StringBuilder();
+ builder.append(columnId).append(SEP); //add column id
+ builder.append(ordering).append(SEP); //add sort order
+// for (Boolean b : groupExpanded){
+// builder.append(b ? TRUE : FALSE).append(SEP);
+// }
+ return builder.toString();
+ }
+
+ /**
+ * Gets grouped column id.
+ * @return grouped column id if grouping is on, otherwise false
+ */
+ String getGroupingColumnId(){
+ return columnId;
+ }
+
+ /**
+ * Checks if grouping is on.
+ * @return true if grouping is on, otherwise false
+ */
+ boolean isGroupingOn(){
+ return (columnId != null);
+ }
+
+ /**
+ * Turn on grouping for column.
+ * @param colId id of column to be grouped
+ * @param ordering sort order
+ */
+ void groupBy(String colId, Ordering ordering){
+ columnId = colId;
+ this.ordering = ordering;
+ resetGroupVisibilityState();
+ }
+
+ /**
+ * Resets information about group visibility state.
+ * All group will be mark as expanded.
+ */
+ void resetGroupVisibilityState(){
+ groupExpanded.clear();
+ }
+
+ /**
+ * Turn off grouping.
+ */
+ void disableGrouping(){
+ columnId = null;
+ ordering = Ordering.UNSORTED;
+ resetGroupVisibilityState();
+ }
+
+ /**
+ * Toggle group. It means that group will be expanded if is collapsed
+ * and group will be collapsed if is expanded.
+ * @param index index of group to be toggled
+ */
+ void toggleGroup(int index){
+ if (index < 0)
+ throw new IllegalArgumentException("Illegal index value :"+index);
+ if (index >= groupExpanded.size()){
+ //add default values for lower indexes
+ int count = index - groupExpanded.size() + 1;
+ for (int i = 0; i < count; i++){
+ groupExpanded.add(DEF);
+ }///for
+ }
+ groupExpanded.add(index,!groupExpanded.remove(index));
+ }
+
+ /**
+ * Checks if group is expanded.
+ * @param index index of group to be tested
+ * @return true if group is expanded, otherwise false
+ */
+ boolean groupIsExpanded(int index){
+ if (index < 0)
+ throw new IllegalArgumentException("Illegal index value :"+index);
+ if (index >= groupExpanded.size()){
+ return DEF;
+ }
+ return groupExpanded.get(index).booleanValue();
+ }
+
+}//ColumnGroupingState
\ No newline at end of file
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2008-08-04 07:34:47 UTC (rev 9872)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2008-08-04 07:41:36 UTC (rev 9873)
@@ -48,8 +48,7 @@
*/
public static final String COMPONENT_FAMILY = "org.richfaces.ExtendedDataTable";
- //TODO nick - please rename this class to indicate that's not the instance of UIComponent
- protected UIExtendedDataTableState state;
+ protected ExtendedDataTableState state;
public abstract Object getActiveRowKey();
@@ -126,7 +125,7 @@
public void ensureTableStateInitialized() {
if (state == null) {
- state = UIExtendedDataTableState.getUIExtendedDataTableState(this);
+ state = ExtendedDataTableState.getExtendedDataTableState(this);
}
}
@@ -251,7 +250,7 @@
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
- this.state = (UIExtendedDataTableState) values[1];
+ this.state = (ExtendedDataTableState) values[1];
}
public int getVisibleColumnsCount() {
@@ -321,12 +320,14 @@
* Original version of this method is defined in
* {@link org.ajax4jsf.component.UIDataAdaptor} and is called before
* RENDER_RESPONSE phase. In that version data model is reseted which causes
- * need to sort and filter every time component is rendered. In this
+ * need to sort and filter every time component is rendered.
*/
- //TODO nick - that's needed because component can be switched to another data model
// @Override
protected void resetDataModel() {
- // Do nothing!
+ // Do not reset only for ExtendedTableDataModel model
+ if (!(getDataModel() instanceof ExtendedTableDataModel<?>)) {
+ super.resetDataModel();
+ }
}
/**
Deleted: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTableState.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTableState.java 2008-08-04 07:34:47 UTC (rev 9872)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTableState.java 2008-08-04 07:41:36 UTC (rev 9873)
@@ -1,701 +0,0 @@
-/**
- *
- */
-package org.richfaces.component;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.el.ValueExpression;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.model.Ordering;
-
-/**
- * @author pawelgo
- *
- */
-public class UIExtendedDataTableState implements Serializable {
-
- private static final long serialVersionUID = -3103664821855261335L;
-
- public static final String TABLE_STATE_ATTR_NAME = "tableState";
-
- protected static final String SEP = ":";
-
- protected ColumnsOrder columnsOrder;
- protected ColumnsVisibility columnsVisibility;
- protected ColumnsSizeState columnsSizeState;
- protected ColumnGroupingState columnGroupingState;
-
- public static UIExtendedDataTableState getUIExtendedDataTableState(UIExtendedDataTable extendedDataTable){
- UIExtendedDataTableState state = new UIExtendedDataTableState();
- state.init(extendedDataTable);
- return state;
- }//init
-
- /**
- * Converts its state based on table attribute value or create default state if it is not set.
- */
- protected void init(UIExtendedDataTable extendedDataTable){
- //get state value from components attributes
- String value = (String)extendedDataTable.getAttributes().get(TABLE_STATE_ATTR_NAME);
- //split state value into parts
- String[] values = fromString(value);
- //initialize columns order part
- String val = (values != null && values.length>0) ? values[0] : null;
- columnsOrder = ColumnsOrder.getColumnsOrder(extendedDataTable, val);
- //initialize columns visibility part
- val = (values != null && values.length>1) ? values[1] : null;
- columnsVisibility = ColumnsVisibility.getColumnsVisibility(extendedDataTable, val);
- //initialize columns size part
- val = (values != null && values.length>2) ? values[2] : null;
- columnsSizeState = ColumnsSizeState.getColumnsSize(extendedDataTable, val);
- //initialize column grouping part
- val = (values != null && values.length>3) ? values[3] : null;
- columnGroupingState = ColumnGroupingState.getColumnGropingState(extendedDataTable, val);
- }//init
-
- /**
- * Puts own state into component state.
- */
- public void publishChanges(FacesContext context, UIExtendedDataTable extendedDataTable){
- ValueExpression ve = extendedDataTable.getValueExpression(TABLE_STATE_ATTR_NAME);
- if ((null != ve) && (!ve.isReadOnly(context.getELContext()))) {
- ve.setValue(context.getELContext(), toString());
- }
- }//publishChanges
-
- /**
- * Converts its state to String representation.
- */
- public String toString(){
- String[] values = new String[4];
- values[0] = columnsOrder.toString();
- values[1] = columnsVisibility.toString();
- values[2] = columnsSizeState.toString();
- values[3] = columnGroupingState.toString();
- StringBuilder builder = new StringBuilder();
- for (String str : values){
- builder.append(str).append(SEP);
- }//for
- return builder.toString();
- }//toString
-
- public String[] fromString(String value){
- return (value == null) ? null : value.split(SEP);
- }//fromString
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnsOrder#changeOrder(String, String)
- */
- public void changeColumnsOrder(String sourceColumnId, String targetColumnId, boolean dropBefore) {
- columnsOrder.changeOrder(sourceColumnId, targetColumnId, dropBefore);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnsOrder#sortColumns(FacesContext, List)
- */
- public List<UIComponent> sortColumns(FacesContext context,
- List<UIComponent> children) {
- return columnsOrder.sortColumns(context, children);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnsVisibility#isVisible(String)
- */
- public boolean isColumnVisible(String columnId) {
- return columnsVisibility.isVisible(columnId);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnsVisibility#toggleVisibility(UIExtendedDataTable, String)
- */
- public void toggleColumnVisibility(UIExtendedDataTable extendedDataTable,
- String columnId) {
- columnsVisibility.toggleVisibility(extendedDataTable, columnId);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnsSizeState#changeColumnSize(UIExtendedDataTable, String)
- */
- public void changeColumnSize(UIExtendedDataTable extendedDataTable,
- String newValue) {
- columnsSizeState.changeColumnSize(extendedDataTable, newValue);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnsSizeState#getColumnSize(UIComponent)
- */
- public String getColumnSize(UIComponent column) {
- return columnsSizeState.getColumnSize(column);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnGroupingState#isGroupingOn()
- */
- public boolean isGroupingOn(){
- return columnGroupingState.isGroupingOn();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnGroupingState#getGroupingColumnId()
- */
- public String getGroupingColumnId(){
- return columnGroupingState.getGroupingColumnId();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnGroupingState#groupBy(String, Ordering)
- */
- public void groupBy(String colId, Ordering ordering) {
- columnGroupingState.groupBy(colId, ordering);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnGroupingState#resetGroupVisibilityState()
- */
- public void resetGroupVisibilityState(){
- columnGroupingState.resetGroupVisibilityState();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnGroupingState#disableGrouping()
- */
- public void disableGrouping(){
- columnGroupingState.disableGrouping();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnGroupingState#groupIsExpanded(int)
- */
- public boolean groupIsExpanded(int index) {
- return columnGroupingState.groupIsExpanded(index);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ColumnGroupingState#toggleGroup(int)
- */
- public void toggleGroup(int index) {
- columnGroupingState.toggleGroup(index);
- }
-
-
-}
-
-class ColumnsSizeState implements Serializable{
-
- private static final long serialVersionUID = 8724163192351491340L;
-
- private static final String SEP = ";";
-
- private static final String DEFAULT_WIDTH = "100";
-
- private String value;
-
- private ColumnsSizeState() {
- super();
- }
-
- static ColumnsSizeState getColumnsSize(UIExtendedDataTable extendedDataTable, String val){
- ColumnsSizeState columnsSize = new ColumnsSizeState();
- columnsSize.init(extendedDataTable, val);
- return columnsSize;
- }
-
- /**
- * Converts its state from String representation or create default state if it is not set.
- */
- private void init(UIExtendedDataTable extendedDataTable, String val){
- value = val;
- if ((value == null) || (value.length() == 0))
- createDefaultColumnsSizeState(extendedDataTable);
- }
-
- /**
- * Converts its state to String representation.
- */
- public String toString(){
- return value;
- }
-
- /**
- * Create default column order based on component children.
- */
- private void createDefaultColumnsSizeState(UIExtendedDataTable extendedDataTable){
- StringBuilder builder = new StringBuilder();
-
- for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
- UIColumn col = iter.next();
- builder.append(col.getId().toUpperCase()).append("-").append(getDefaultColumnSize(col)).append(SEP);
- }
- value = builder.toString();
- }
-
- private String getDefaultColumnSize(UIComponent column){
- String widthStr = (String) column.getAttributes().get("width");
- return formatWidth((widthStr == null || widthStr.length() == 0) ? DEFAULT_WIDTH : widthStr);
- }
-
- public String getColumnSize(UIComponent column){
- if (value == null)
- return getDefaultColumnSize(column);
- String[] widths = value.split(SEP);
- if (widths != null){
- String colId = column.getId().toUpperCase();
- for (String val : widths){
- if (val.toUpperCase().startsWith(colId+"-")){
- return formatWidth(val.split("-")[1]);
- }
- }//for
- }
- return getDefaultColumnSize(column);
- }
-
- private String formatWidth(String value){
- //TODO nick - use org.ajax4jsf.util.HtmlDimensions.decode(String)
- if(value.endsWith("px"))
- return value.substring(0,value.indexOf("px"));
- return value;
- }
-
- public void changeColumnSize(UIExtendedDataTable extendedDataTable, String newValue){
- if (value == null)
- return;
- Set<String> widths = new HashSet<String>(Arrays.asList(value.toUpperCase().split(SEP)));
- String[] newWidths = newValue.split(";");
- int index = 0;
- for (Iterator<UIColumn> iter = extendedDataTable.getSortedColumns(); iter.hasNext();) {
- UIComponent col = (UIComponent) iter.next();
- if (col.isRendered()){
- String colId = col.getId().toUpperCase();
- //remove existing item
- Set<String> toDel = new HashSet<String>();
- for (String val : widths){
- if (val.toUpperCase().startsWith(colId+"-")){
- toDel.add(val);
- }
- }//for
- widths.removeAll(toDel);
- //create new item
- String newWidth = newWidths[index++];
- String item = colId + "-" + newWidth;;
- widths.add(item);
- }//if
- }//for
- //build new value
- StringBuilder builder = new StringBuilder();
- for (String val : widths){
- builder.append(val).append(SEP);
- }
- value = builder.toString();
- }//changeColumnSize
-
-}//ColumnsSizeState
-
-class ColumnsOrder implements Serializable{
-
- private static final long serialVersionUID = 907700564445889954L;
-
- private static final String SEP = ";";
-
- private String value;
-
- private ColumnsOrder() {
- super();
- }
-
- static ColumnsOrder getColumnsOrder(UIExtendedDataTable extendedDataTable, String val){
- ColumnsOrder columnsOrder = new ColumnsOrder();
- columnsOrder.init(extendedDataTable, val);
- return columnsOrder;
- }
-
- /**
- * Converts its state from String representation or create default state if it is not set.
- */
- private void init(UIExtendedDataTable extendedDataTable, String val){
- value = val;
- if ((value == null) || (value.length() == 0))
- createDefaultColumnsOrder(extendedDataTable);
- }
-
- /**
- * Converts its state to String representation.
- */
- public String toString(){
- return value;
- }
-
- /**
- * Create default column order based on component children.
- */
- private void createDefaultColumnsOrder(UIExtendedDataTable extendedDataTable){
- StringBuilder builder = new StringBuilder();
- for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
- UIColumn child = iter.next();
- builder.append(child.getId().toUpperCase()).append(SEP);
- }
- value = builder.toString();
- }
-
- /**
- * Get column index in order.
- * @param columnId column id to be found
- * @return column index or null if not found
- */
- private Integer getColumnIndex(String columnId){
- if (value == null)
- return null;
- List<String> list = Arrays.asList(value.toUpperCase().split(SEP));
- if (list.contains(columnId.toUpperCase()))
- return list.indexOf(columnId.toUpperCase());
- return null;
- }//getColumnIndex
-
- /**
- * Changes column order. Moves source column to be next to target column.
- * @param sourceColumnId source column id to be moved
- * @param targetColumnId target column id
- * @param dropBefore
- */
- void changeOrder(String sourceColumnId, String targetColumnId, boolean dropBefore){
- if (value == null)
- return;
- if (sourceColumnId.equals(targetColumnId))
- return;
- List<String> list = new ArrayList<String>(Arrays.asList(value.toUpperCase().split(SEP)));
- //get index of source column
- int sourceIndex = list.indexOf(sourceColumnId.toUpperCase());
- //remove from order if exist
- if (sourceIndex != -1)
- list.remove(sourceIndex);
- //get index of target column
- int targetIndex = list.indexOf(targetColumnId.toUpperCase());
- //add source column after or before target column
- if (targetIndex == -1)//add to end
- list.add(sourceColumnId.toUpperCase());
- else{
- //add at proper position
- list.add((targetIndex + (dropBefore ? 0 : 1)), sourceColumnId.toUpperCase());
- }
- //convert from List to String
- StringBuilder builder = new StringBuilder();
- for (String str : list)
- builder.append(str).append(SEP);
- value = builder.toString();
- }
-
- /**
- * Sort column by given order.
- * @param context faces context
- * @param children list of unsorted columns
- * @return list of sorted columns
- */
- List<UIComponent> sortColumns(final FacesContext context, List<UIComponent> children){
- List<UIComponent> childs = new ArrayList<UIComponent>(children);
- Collections.sort(childs, new Comparator<UIComponent>() {
- public int compare(UIComponent o1, UIComponent o2) {
- Integer index1 = getColumnIndex(o1.getId());
- Integer index2 = getColumnIndex(o2.getId());
- if (index1 == null) {
- return ((index2 == null) ? 0 : 1);
- }
- return ((index2 == null) ? -1 : index1.compareTo(index2));
- }
- });
- return childs;
- }
-
-}//ColumnsOrder
-
-class ColumnsVisibility implements Serializable{
-
- private static final long serialVersionUID = -3923409650272094713L;
-
- private static final String SEP = ";";
-
- private String value;
-
- private ColumnsVisibility() {
- super();
- }
-
- static ColumnsVisibility getColumnsVisibility(UIExtendedDataTable extendedDataTable, String val){
- ColumnsVisibility columnsVisibility = new ColumnsVisibility();
- columnsVisibility.init(extendedDataTable, val);
- return columnsVisibility;
- }
-
- /**
- * Converts its state from String representation or create default state if it is not set.
- */
- private void init(UIExtendedDataTable extendedDataTable, String val){
- value = val;
- if ((value == null) || (value.length() == 0))
- createDefaultColumnsVisibility(extendedDataTable);
- //set visibility flag for all columns
- for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
- UIColumn child = iter.next();
- if (child instanceof UIColumn) {
- UIColumn dataColumn = (UIColumn) child;
- dataColumn.setVisible(isVisible(dataColumn.getId()));
- }//if
- }//for
- }//init
-
- /**
- * Converts its state to String representation.
- */
- public String toString(){
- return value;
- }
-
- /**
- * Create default column visibility based on component children.
- */
- private void createDefaultColumnsVisibility(UIExtendedDataTable extendedDataTable){
- StringBuilder builder = new StringBuilder();
- for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
- UIColumn kid = iter.next();
- builder.append(kid.getId().toUpperCase()).append(SEP);
- }
- value = builder.toString();
- }//createDefaultColumnsVisibility
-
- /**
- * Get column visibility.
- * @param columnId column id to be found
- * @return true if column is visible, otherwise false
- */
- boolean isVisible(String columnId){
- if (value == null)
- return true;
- Set<String> visibleIds = new HashSet<String>(Arrays.asList(value.toUpperCase().split(SEP)));
- return visibleIds.contains(columnId.toUpperCase());
- }//isVisible
-
- /**
- * Toggle column visibility.
- * @param extendedDataTable table component
- * @param columnId column id
- */
- void toggleVisibility(UIExtendedDataTable extendedDataTable, String columnId){
- if (value == null)
- return;
- UIColumn column = null;
- //find column by id
- for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
- UIColumn col = iter.next();
- if (col.getId().equalsIgnoreCase(columnId)){
- if (col instanceof UIColumn){
- column = (UIColumn) col;
- }
- break;
- }//if
- }//for
- if (column == null)
- return;
- boolean visible = column.isVisible();
- //toggle visibility
- visible = !visible;
- //set visibility flag for column
- column.setVisible(visible);
- Set<String> visibleIds = new HashSet<String>(Arrays.asList(value.toUpperCase().split(SEP)));
- if (visible){
- //add id to set
- visibleIds.add(columnId.toUpperCase());
- }
- else{
- //remove id from list
- visibleIds.remove(columnId.toUpperCase());
- }
- //convert from Set to String
- StringBuilder builder = new StringBuilder();
- for (String str : visibleIds)
- builder.append(str).append(SEP);
- value = builder.toString();
- }//changeVisibility
-
-}//ColumnsVisibility
-
-class ColumnGroupingState implements Serializable{
-
- private static final long serialVersionUID = -3923409650272094713L;
-
- private static final String SEP = ";";
- //private static final String TRUE = "1";
- //private static final String FALSE = "0";
- private static final Boolean DEF = Boolean.TRUE;//expanded
-
- private String columnId;
- private List<Boolean> groupExpanded;
- private Ordering ordering;
- //private String value;
-
- private ColumnGroupingState() {
- super();
- }
-
- static ColumnGroupingState getColumnGropingState(UIExtendedDataTable extendedDataTable, String val){
- ColumnGroupingState groupingState = new ColumnGroupingState();
- groupingState.init(extendedDataTable, val);
- return groupingState;
- }
-
- /**
- * Converts its state from String representation or create default state if it is not set.
- */
- private void init(UIExtendedDataTable extendedDataTable, String val){
- columnId = null;
- ordering = Ordering.UNSORTED;
- groupExpanded = new ArrayList<Boolean>();
- if ((val == null) || (val.length() == 0))
- return;
- List<String> tmp = Arrays.asList(val.split(SEP));
- if (!tmp.isEmpty()){
- columnId = tmp.get(0); //column id
- ordering = Ordering.valueOf(tmp.get(1)); //sort order
- if (ordering == null)
- ordering = Ordering.UNSORTED;
-// tmp = tmp.subList(2, tmp.size());//remove fist and second item
-// for (String s : tmp){
-// groupExpanded.add(Boolean.valueOf(s.equals(TRUE)));
-// }//for
- }
- //get column by id and set sort order
- for (Iterator<UIColumn> columns = extendedDataTable.getChildColumns(); columns.hasNext(); ){
- UIColumn child = columns.next();
- if (columnId.equalsIgnoreCase(child.getId())) {
- child.setSortOrder(ordering);
- break;
- }
- }
- }//init
-
- /**
- * Converts its state to String representation.
- */
- public String toString(){
- if (columnId == null)
- return "";
- StringBuilder builder = new StringBuilder();
- builder.append(columnId).append(SEP); //add column id
- builder.append(ordering).append(SEP); //add sort order
-// for (Boolean b : groupExpanded){
-// builder.append(b ? TRUE : FALSE).append(SEP);
-// }
- return builder.toString();
- }
-
- /**
- * Gets grouped column id.
- * @return grouped column id if grouping is on, otherwise false
- */
- String getGroupingColumnId(){
- return columnId;
- }
-
- /**
- * Checks if grouping is on.
- * @return true if grouping is on, otherwise false
- */
- boolean isGroupingOn(){
- return (columnId != null);
- }
-
- /**
- * Turn on grouping for column.
- * @param colId id of column to be grouped
- * @param ordering sort order
- */
- void groupBy(String colId, Ordering ordering){
- columnId = colId;
- this.ordering = ordering;
- resetGroupVisibilityState();
- }
-
- /**
- * Resets information about group visibility state.
- * All group will be mark as expanded.
- */
- void resetGroupVisibilityState(){
- groupExpanded.clear();
- }
-
- /**
- * Turn off grouping.
- */
- void disableGrouping(){
- columnId = null;
- ordering = Ordering.UNSORTED;
- resetGroupVisibilityState();
- }
-
- /**
- * Toggle group. It means that group will be expanded if is collapsed
- * and group will be collapsed if is expanded.
- * @param index index of group to be toggled
- */
- void toggleGroup(int index){
- if (index < 0)
- throw new IllegalArgumentException("Illegal index value :"+index);
- if (index >= groupExpanded.size()){
- //add default values for lower indexes
- int count = index - groupExpanded.size() + 1;
- for (int i = 0; i < count; i++){
- groupExpanded.add(DEF);
- }///for
- }
- groupExpanded.add(index,!groupExpanded.remove(index));
- }
-
- /**
- * Checks if group is expanded.
- * @param index index of group to be tested
- * @return true if group is expanded, otherwise false
- */
- boolean groupIsExpanded(int index){
- if (index < 0)
- throw new IllegalArgumentException("Illegal index value :"+index);
- if (index >= groupExpanded.size()){
- return DEF;
- }
- return groupExpanded.get(index).booleanValue();
- }
-
-}//ColumnGroupingState
\ No newline at end of file
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java 2008-08-04 07:34:47 UTC (rev 9872)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java 2008-08-04 07:41:36 UTC (rev 9873)
@@ -112,12 +112,7 @@
// protected TableMenuRenderer menuRenderer = new RichTableMenuRenderer();
protected CompositeRendererEnabler composite = new CompositeRendererEnabler();
-
- // protected Object lastData = null;
- // protected Object lastKey = null;
- // TODO move this property to holder
- // protected int groupIndex = -1;
-
+
/*
* (non-Javadoc)
*
@@ -256,8 +251,7 @@
protected void encodeStyleClass(ResponseWriter writer,
Object parentPredefined, Object predefined, Object parent,
Object custom) throws IOException {
- //TODO nick - StringBuilder is more performant
- StringBuffer styleClass = new StringBuffer();
+ StringBuilder styleClass = new StringBuilder();
// Construct predefined classes
if (null != parentPredefined) {
styleClass.append(parentPredefined).append(" ");
Deleted: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DraggableRendererContributor.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DraggableRendererContributor.java 2008-08-04 07:34:47 UTC (rev 9872)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DraggableRendererContributor.java 2008-08-04 07:41:36 UTC (rev 9873)
@@ -1,114 +0,0 @@
-/**
- *
- */
-package org.richfaces.renderkit.html;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.renderkit.CompositeRenderer;
-import org.richfaces.renderkit.RendererContributor;
-import org.richfaces.renderkit.ScriptOptions;
-
-/**
- * Renderer contributor for drag support based on
- * {@link org.richfaces.renderkit.DraggableRendererContributor}. Used only with
- * {@link org.richfaces.component.UIExtendedDataTable} component. All
- * functionality from wrapped
- * {@link org.richfaces.renderkit.DraggableRendererContributor} are available
- * and special method
- * {@link DraggableRendererContributor#buildOptions(FacesContext, UIComponent, String, String)}
- * is added.
- *
- * @author pawelgo
- *
- */
-
-//TODO nick - please rename classes & resources to prevent collisions with RF classes!!
-public class DraggableRendererContributor implements RendererContributor {
-
- private static DraggableRendererContributor instance;
-
- private static RendererContributor wrappedContributor;
-
- private DraggableRendererContributor() {
- super();
- }
-
- public static synchronized DraggableRendererContributor getInstance() {
- if (instance == null) {
- instance = new DraggableRendererContributor();
- wrappedContributor = org.richfaces.renderkit.DraggableRendererContributor
- .getInstance();
- }
- return instance;
- }
-
- public void decode(FacesContext context, UIComponent component,
- CompositeRenderer compositeRenderer) {
- wrappedContributor.decode(context, component, compositeRenderer);
- }
-
- public Class<?> getAcceptableClass() {
- return wrappedContributor.getAcceptableClass();
- }
-
- public String getScriptContribution(FacesContext context,
- UIComponent component) {
- return wrappedContributor.getScriptContribution(context, component);
- }
-
- public String[] getScriptDependencies() {
- return wrappedContributor.getScriptDependencies();
- }
-
- public String[] getStyleDependencies() {
- return wrappedContributor.getStyleDependencies();
- }
-
- public ScriptOptions buildOptions(FacesContext context,
- UIComponent component) {
- return wrappedContributor.buildOptions(context, component);
- }
-
- /**
- * Builds options for DnD.ExtSimpleDraggable JavaScript object. These options
- * are specialized for drag source used to start changing table columns
- * order event.
- *
- * @param context
- * faces context
- * @param column
- * table column
- * @param dragSourceScriptId
- * drag source HTML element id
- * @param indicatorId
- * drag indicator id
- * @return all options needed for drag JavaScript object to work
- */
- public ScriptOptions buildOptions(FacesContext context, UIComponent column,
- String dragSourceScriptId, String indicatorId) {
-
- ScriptOptions options = new ScriptOptions(column);
- options.addOption("dragType", "COLUMN_ORDER_"
- + column.getParent().getClientId(context));
-
- Map<String, Object> parameters = new HashMap<String, Object>();
- parameters
- .put(
- org.richfaces.renderkit.DraggableRendererContributor.DRAG_SOURCE_ID,
- dragSourceScriptId);
- parameters.put(dragSourceScriptId, dragSourceScriptId);
- options.addOption("parameters", parameters);
-
- if (indicatorId != null) {
- options.addOption("dragIndicator", indicatorId);
- }
-
- return options;
- }
-
-}
Deleted: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DropzoneRendererContributor.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DropzoneRendererContributor.java 2008-08-04 07:34:47 UTC (rev 9872)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DropzoneRendererContributor.java 2008-08-04 07:41:36 UTC (rev 9873)
@@ -1,145 +0,0 @@
-/**
- *
- */
-package org.richfaces.renderkit.html;
-
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.renderkit.CompositeRenderer;
-import org.richfaces.renderkit.RendererContributor;
-import org.richfaces.renderkit.ScriptOptions;
-
-/**
- * Renderer contributor for drop support based on {@link org.richfaces.renderkit.DropzoneRendererContributor}.
- * Used only with {@link org.richfaces.component.UIExtendedDataTable} component.
- * All functionality from wrapped {@link org.richfaces.renderkit.DropzoneRendererContributor} are available.
- * Also special methods {@link DropzoneRendererContributor#buildOptions(FacesContext, UIComponent)}
- * and {@link DropzoneRendererContributor#getScriptContribution(FacesContext, UIComponent, String, JSFunctionDefinition)}
- * are added.
- *
- * @author pawelgo
- *
- */
-public class DropzoneRendererContributor implements RendererContributor {
-
- private DropzoneRendererContributor() {
- super();
- }
-
- private static DropzoneRendererContributor instance;
-
- private static RendererContributor wrappedContributor;
-
- public static synchronized DropzoneRendererContributor getInstance() {
- if (instance == null) {
- instance = new DropzoneRendererContributor();
- wrappedContributor = org.richfaces.renderkit.DropzoneRendererContributor.getInstance();
- }
-
- return instance;
- }
-
- public void decode(FacesContext context, UIComponent component, CompositeRenderer compositeRenderer) {
- wrappedContributor.decode(context, component, compositeRenderer);
- }
-
- public Class<?> getAcceptableClass() {
- return wrappedContributor.getAcceptableClass();
- }
-
- public String getScriptContribution(FacesContext context, UIComponent component) {
- return wrappedContributor.getScriptContribution(context, component);
- }
-
- /**
- * Build JavaScript code for drag'n drop support specialized for change table column order event.
- * @param context faces context
- * @param column table column
- * @param dropTargetScriptId id of HTML script element that contains defined DnD.ExtSimpleDropZone object
- * @param onAjaxCompleteFunction JavaScript function to be called on AJAX request complete
- * @return JavaScript code
- */
- public String getScriptContribution(FacesContext context, UIComponent column, String dropTargetScriptId, JSFunction preSendAjaxRequestFunction, JSFunctionDefinition onAjaxCompleteFunction) {
- StringBuffer result = new StringBuffer();
-
- result.append(".drop = ");
-
- JSFunctionDefinition definition = new JSFunctionDefinition();
- definition.addParameter("event");
- definition.addParameter("drag");
-
- Map<String, Object> requestOpts = AjaxRendererUtils.buildEventOptions(context, column);
- //replace parameters
- String clientId = column.getClientId(context);
- @SuppressWarnings("unchecked")
- Map<String, Object> parameters = (Map<String, Object>) requestOpts.get("parameters");
- if (parameters != null){
- if (parameters.containsKey(clientId)){
- parameters.remove(clientId);
- parameters.put(dropTargetScriptId, dropTargetScriptId);
- }
- }
-
- if (preSendAjaxRequestFunction != null){
- definition.addToBody(preSendAjaxRequestFunction.toScript()).addToBody(";");
- }
- definition.addToBody("var options = ").addToBody(ScriptUtils.toScript(requestOpts)).addToBody(";");
- definition.addToBody("options.parameters['" + org.richfaces.renderkit.DropzoneRendererContributor.DROP_TARGET_ID + "'] = '" + dropTargetScriptId + "';");
-
- if (onAjaxCompleteFunction != null)
- definition.addToBody("options['" + AjaxRendererUtils.ONCOMPLETE_ATTR_NAME + "'] = " + onAjaxCompleteFunction.toScript() + ";");
- //TODO nick - remove as legacy
- definition.addToBody("Object.extend(options.parameters,drag.getParameters());");
- definition.addToBody("var dzOptions = this.getDropzoneOptions(); if (dzOptions.ondrop) { if (!dzOptions.ondrop.call(this, event)) return; };");
-
- JSFunction dropFunction = AjaxRendererUtils.buildAjaxFunction(column, context);
- dropFunction.addParameter(new JSReference("options"));
-
- definition.addToBody(dropFunction.toScript()).addToBody(";");
- definition.appendScript(result);
- result.append(";");
-
- return result.toString();
- }
-
- /**
- * Build JavaScript code for drag'n drop support specialized for change table column order event.
- * @param context faces context
- * @param column table column
- * @param dropTargetScriptId id of HTML script element that contains defined DnD.ExtSimpleDropZone object
- * @return JavaScript code
- */
- public String getScriptContribution(FacesContext context, UIComponent column, String dropTargetScriptId) {
- return getScriptContribution(context, column, dropTargetScriptId, null, null);
- }
-
- public String[] getScriptDependencies() {
- return wrappedContributor.getScriptDependencies();
- }
-
- public String[] getStyleDependencies() {
- return wrappedContributor.getStyleDependencies();
- }
-
- /**
- * Builds options for DnD.ExtSimpleDropZone JavaScript object.
- * These options are specialized for drop target used to end changing table columns order event.
- * @param context faces context
- * @param column table column
- * @return all options needed for drop JavaScript object to work
- */
- public ScriptOptions buildOptions(FacesContext context, UIComponent column) {
- ScriptOptions options = new ScriptOptions(column);
- options.addOption("acceptedTypes", "COLUMN_ORDER_"+column.getParent().getClientId(context));
- return options;
- }
-
-}
Added: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDraggableRendererContributor.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDraggableRendererContributor.java (rev 0)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDraggableRendererContributor.java 2008-08-04 07:41:36 UTC (rev 9873)
@@ -0,0 +1,111 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.renderkit.CompositeRenderer;
+import org.richfaces.renderkit.RendererContributor;
+import org.richfaces.renderkit.ScriptOptions;
+
+/**
+ * Renderer contributor for drag support based on
+ * {@link org.richfaces.renderkit.DraggableRendererContributor}. Used only with
+ * {@link org.richfaces.component.UIExtendedDataTable} component. All
+ * functionality from wrapped
+ * {@link org.richfaces.renderkit.DraggableRendererContributor} are available
+ * and special method
+ * {@link ExtDraggableRendererContributor#buildOptions(FacesContext, UIComponent, String, String)}
+ * is added.
+ *
+ * @author pawelgo
+ *
+ */
+public class ExtDraggableRendererContributor implements RendererContributor {
+
+ private static ExtDraggableRendererContributor instance;
+
+ private static RendererContributor wrappedContributor;
+
+ private ExtDraggableRendererContributor() {
+ super();
+ }
+
+ public static synchronized ExtDraggableRendererContributor getInstance() {
+ if (instance == null) {
+ instance = new ExtDraggableRendererContributor();
+ wrappedContributor = org.richfaces.renderkit.DraggableRendererContributor.getInstance();
+ }
+ return instance;
+ }
+
+ public void decode(FacesContext context, UIComponent component,
+ CompositeRenderer compositeRenderer) {
+ wrappedContributor.decode(context, component, compositeRenderer);
+ }
+
+ public Class<?> getAcceptableClass() {
+ return wrappedContributor.getAcceptableClass();
+ }
+
+ public String getScriptContribution(FacesContext context,
+ UIComponent component) {
+ return wrappedContributor.getScriptContribution(context, component);
+ }
+
+ public String[] getScriptDependencies() {
+ return wrappedContributor.getScriptDependencies();
+ }
+
+ public String[] getStyleDependencies() {
+ return wrappedContributor.getStyleDependencies();
+ }
+
+ public ScriptOptions buildOptions(FacesContext context,
+ UIComponent component) {
+ return wrappedContributor.buildOptions(context, component);
+ }
+
+ /**
+ * Builds options for DnD.ExtSimpleDraggable JavaScript object. These options
+ * are specialized for drag source used to start changing table columns
+ * order event.
+ *
+ * @param context
+ * faces context
+ * @param column
+ * table column
+ * @param dragSourceScriptId
+ * drag source HTML element id
+ * @param indicatorId
+ * drag indicator id
+ * @return all options needed for drag JavaScript object to work
+ */
+ public ScriptOptions buildOptions(FacesContext context, UIComponent column,
+ String dragSourceScriptId, String indicatorId) {
+
+ ScriptOptions options = new ScriptOptions(column);
+ options.addOption("dragType", "COLUMN_ORDER_"
+ + column.getParent().getClientId(context));
+
+ Map<String, Object> parameters = new HashMap<String, Object>();
+ parameters
+ .put(
+ org.richfaces.renderkit.DraggableRendererContributor.DRAG_SOURCE_ID,
+ dragSourceScriptId);
+ parameters.put(dragSourceScriptId, dragSourceScriptId);
+ options.addOption("parameters", parameters);
+
+ if (indicatorId != null) {
+ options.addOption("dragIndicator", indicatorId);
+ }
+
+ return options;
+ }
+
+}
Added: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDropzoneRendererContributor.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDropzoneRendererContributor.java (rev 0)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDropzoneRendererContributor.java 2008-08-04 07:41:36 UTC (rev 9873)
@@ -0,0 +1,145 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html;
+
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.renderkit.CompositeRenderer;
+import org.richfaces.renderkit.RendererContributor;
+import org.richfaces.renderkit.ScriptOptions;
+
+/**
+ * Renderer contributor for drop support based on {@link org.richfaces.renderkit.DropzoneRendererContributor}.
+ * Used only with {@link org.richfaces.component.UIExtendedDataTable} component.
+ * All functionality from wrapped {@link org.richfaces.renderkit.DropzoneRendererContributor} are available.
+ * Also special methods {@link ExtDropzoneRendererContributor#buildOptions(FacesContext, UIComponent)}
+ * and {@link ExtDropzoneRendererContributor#getScriptContribution(FacesContext, UIComponent, String, JSFunctionDefinition)}
+ * are added.
+ *
+ * @author pawelgo
+ *
+ */
+public class ExtDropzoneRendererContributor implements RendererContributor {
+
+ private ExtDropzoneRendererContributor() {
+ super();
+ }
+
+ private static ExtDropzoneRendererContributor instance;
+
+ private static RendererContributor wrappedContributor;
+
+ public static synchronized ExtDropzoneRendererContributor getInstance() {
+ if (instance == null) {
+ instance = new ExtDropzoneRendererContributor();
+ wrappedContributor = org.richfaces.renderkit.DropzoneRendererContributor.getInstance();
+ }
+
+ return instance;
+ }
+
+ public void decode(FacesContext context, UIComponent component, CompositeRenderer compositeRenderer) {
+ wrappedContributor.decode(context, component, compositeRenderer);
+ }
+
+ public Class<?> getAcceptableClass() {
+ return wrappedContributor.getAcceptableClass();
+ }
+
+ public String getScriptContribution(FacesContext context, UIComponent component) {
+ return wrappedContributor.getScriptContribution(context, component);
+ }
+
+ /**
+ * Build JavaScript code for drag'n drop support specialized for change table column order event.
+ * @param context faces context
+ * @param column table column
+ * @param dropTargetScriptId id of HTML script element that contains defined DnD.ExtSimpleDropZone object
+ * @param onAjaxCompleteFunction JavaScript function to be called on AJAX request complete
+ * @return JavaScript code
+ */
+ public String getScriptContribution(FacesContext context, UIComponent column, String dropTargetScriptId, JSFunction preSendAjaxRequestFunction, JSFunctionDefinition onAjaxCompleteFunction) {
+ StringBuffer result = new StringBuffer();
+
+ result.append(".drop = ");
+
+ JSFunctionDefinition definition = new JSFunctionDefinition();
+ definition.addParameter("event");
+ definition.addParameter("drag");
+
+ Map<String, Object> requestOpts = AjaxRendererUtils.buildEventOptions(context, column);
+ //replace parameters
+ String clientId = column.getClientId(context);
+ @SuppressWarnings("unchecked")
+ Map<String, Object> parameters = (Map<String, Object>) requestOpts.get("parameters");
+ if (parameters != null){
+ if (parameters.containsKey(clientId)){
+ parameters.remove(clientId);
+ parameters.put(dropTargetScriptId, dropTargetScriptId);
+ }
+ }
+
+ if (preSendAjaxRequestFunction != null){
+ definition.addToBody(preSendAjaxRequestFunction.toScript()).addToBody(";");
+ }
+ definition.addToBody("var options = ").addToBody(ScriptUtils.toScript(requestOpts)).addToBody(";");
+ definition.addToBody("options.parameters['" + org.richfaces.renderkit.DropzoneRendererContributor.DROP_TARGET_ID + "'] = '" + dropTargetScriptId + "';");
+
+ if (onAjaxCompleteFunction != null)
+ definition.addToBody("options['" + AjaxRendererUtils.ONCOMPLETE_ATTR_NAME + "'] = " + onAjaxCompleteFunction.toScript() + ";");
+ //TODO remove as legacy
+ definition.addToBody("Object.extend(options.parameters,drag.getParameters());");
+ definition.addToBody("var dzOptions = this.getDropzoneOptions(); if (dzOptions.ondrop) { if (!dzOptions.ondrop.call(this, event)) return; };");
+
+ JSFunction dropFunction = AjaxRendererUtils.buildAjaxFunction(column, context);
+ dropFunction.addParameter(new JSReference("options"));
+
+ definition.addToBody(dropFunction.toScript()).addToBody(";");
+ definition.appendScript(result);
+ result.append(";");
+
+ return result.toString();
+ }
+
+ /**
+ * Build JavaScript code for drag'n drop support specialized for change table column order event.
+ * @param context faces context
+ * @param column table column
+ * @param dropTargetScriptId id of HTML script element that contains defined DnD.ExtSimpleDropZone object
+ * @return JavaScript code
+ */
+ public String getScriptContribution(FacesContext context, UIComponent column, String dropTargetScriptId) {
+ return getScriptContribution(context, column, dropTargetScriptId, null, null);
+ }
+
+ public String[] getScriptDependencies() {
+ return wrappedContributor.getScriptDependencies();
+ }
+
+ public String[] getStyleDependencies() {
+ return wrappedContributor.getStyleDependencies();
+ }
+
+ /**
+ * Builds options for DnD.ExtSimpleDropZone JavaScript object.
+ * These options are specialized for drop target used to end changing table columns order event.
+ * @param context faces context
+ * @param column table column
+ * @return all options needed for drop JavaScript object to work
+ */
+ public ScriptOptions buildOptions(FacesContext context, UIComponent column) {
+ ScriptOptions options = new ScriptOptions(column);
+ options.addOption("acceptedTypes", "COLUMN_ORDER_"+column.getParent().getClientId(context));
+ return options;
+ }
+
+}
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableDragDropRenderer.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableDragDropRenderer.java 2008-08-04 07:34:47 UTC (rev 9872)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableDragDropRenderer.java 2008-08-04 07:41:36 UTC (rev 9873)
@@ -123,7 +123,7 @@
function.addParameter(dragSourceId);
String dragSourceScriptId = column.getClientId(context) + ":"
+ DRAG_SOURCE_SCRIPT_ID;
- DraggableRendererContributor contributor = DraggableRendererContributor
+ ExtDraggableRendererContributor contributor = ExtDraggableRendererContributor
.getInstance();
ScriptOptions dragOptions = contributor.buildOptions(context, column,
dragSourceScriptId, indicatorId);
@@ -168,7 +168,7 @@
boolean before) throws IOException {
// RendererContributor contributor =
// DropzoneRendererContributor.getInstance();
- DropzoneRendererContributor contributor = DropzoneRendererContributor
+ ExtDropzoneRendererContributor contributor = ExtDropzoneRendererContributor
.getInstance();
String varName = "DnD_ExtSimpleDropZone_"+column.getId().replaceAll("[^A-Za-z0-9_]", "_") + (before?"L":"R");
StringBuffer buffer = new StringBuffer("delete " + varName + ";\nvar " + varName + " = ");
16 years, 4 months
JBoss Rich Faces SVN: r9872 - trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: pkawiak
Date: 2008-08-04 03:34:47 -0400 (Mon, 04 Aug 2008)
New Revision: 9872
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/ExtendedTableHolder.java
Log:
moving firstRow to holder
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java 2008-08-03 21:50:24 UTC (rev 9871)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java 2008-08-04 07:34:47 UTC (rev 9872)
@@ -47,10 +47,6 @@
HeaderResourcesRendererBase implements DataVisitor {
protected static final String MENU_ID = "_TABLE_MENU_ID_";
-
- //TODO nick - renderer classes are singletons by nature, they should not have
- // non-static/non-final fields
- protected boolean firstRow = true;
protected class CompositeRendererEnabler extends CompositeRenderer {
public CompositeRendererEnabler() {
@@ -157,7 +153,7 @@
*/
protected void encodeRows(FacesContext context, UIComponent component,
ExtendedTableHolder tableHolder) throws IOException {
- this.firstRow = true;
+ tableHolder.setFirstRow(true);
UIDataAdaptor table = (UIDataAdaptor) component;
Object key = table.getRowKey();
table.captureOrigValue(context);
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java 2008-08-03 21:50:24 UTC (rev 9871)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java 2008-08-04 07:34:47 UTC (rev 9872)
@@ -591,12 +591,12 @@
int currentColumn = 0;
UIColumn column = null;
if (holder.isGroupingOn() && (rowGroupChanged(context, holder))) {
- if (this.firstRow) {
+ if (holder.isFirstRow()) {
encodeFakeIeRow(context, table, holder);
}
encodeGroupRow(context, table, holder);
}
- this.firstRow = false;
+ holder.setFirstRow(false);
while (iter.hasNext()) {
column = iter.next();
// Start new row for first column - expect a case of the detail
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/ExtendedTableHolder.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/ExtendedTableHolder.java 2008-08-03 21:50:24 UTC (rev 9871)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/ExtendedTableHolder.java 2008-08-04 07:34:47 UTC (rev 9872)
@@ -20,6 +20,7 @@
private int groupRowCounter = -1;
private boolean groupingOn = false;
+ private boolean firstRow = true;
private UIColumn groupingColumn = null;
private String groupingColumnLabel = null;
@@ -42,7 +43,17 @@
}
}
- public UIExtendedDataTable getTable() {
+ public boolean isFirstRow() {
+ return firstRow;
+ }
+
+ public void setFirstRow(boolean firstRow) {
+ this.firstRow = firstRow;
+ }
+
+
+
+ public UIExtendedDataTable getTable() {
return (UIExtendedDataTable)super.getTable();
}
16 years, 4 months
JBoss Rich Faces SVN: r9871 - trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-08-03 17:50:24 -0400 (Sun, 03 Aug 2008)
New Revision: 9871
Modified:
trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
Log:
https://jira.jboss.org/jira/browse/RF-4061
Modified: trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
===================================================================
--- trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java 2008-08-03 21:29:54 UTC (rev 9870)
+++ trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java 2008-08-03 21:50:24 UTC (rev 9871)
@@ -35,8 +35,8 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.JavaScriptParameter;
+import org.ajax4jsf.javascript.JSBind;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
@@ -254,17 +254,19 @@
if (isImmediate) {
attachContextMenuBuffer.append(attachContextMenuFunction.toScript());
- } else if (isOnAvailable) {
- JSFunction availableFunction = new JSFunction("Richfaces.onAvailable");
- availableFunction.addParameter(clientId);
- availableFunction.addParameter(new JSFunctionDefinition().addToBody(attachContextMenuFunction));
+ } else {
+ if (isOnAvailable) {
+ JSFunction availableFunction = new JSFunction("Richfaces.onAvailable");
+ availableFunction.addParameter(clientId);
+ availableFunction.addParameter(new JSBind(attachContextMenuFunction, "contextMenu"));
+ attachContextMenuBuffer.append(availableFunction.toScript());
+
+ } else if (isOnLoad) {
+ JSFunction onloadFunction = new JSFunction("jQuery(document).ready");
+ onloadFunction.addParameter(new JSBind(attachContextMenuFunction, "contextMenu"));
- attachContextMenuBuffer.append(availableFunction.toScript());
- } else if (isOnLoad) {
- JSFunction onloadFunction = new JSFunction("jQuery(document).ready");
- onloadFunction.addParameter(new JSFunctionDefinition().addToBody(attachContextMenuFunction));
-
- attachContextMenuBuffer.append(onloadFunction.toScript());
+ attachContextMenuBuffer.append(onloadFunction.toScript());
+ }
}
attachContextMenuBuffer.append(";");
16 years, 4 months
JBoss Rich Faces SVN: r9870 - trunk/framework/api/src/main/java/org/ajax4jsf/javascript.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-08-03 17:29:54 -0400 (Sun, 03 Aug 2008)
New Revision: 9870
Added:
trunk/framework/api/src/main/java/org/ajax4jsf/javascript/JSBind.java
Log:
https://jira.jboss.org/jira/browse/RF-4061
Added: trunk/framework/api/src/main/java/org/ajax4jsf/javascript/JSBind.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/javascript/JSBind.java (rev 0)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/javascript/JSBind.java 2008-08-03 21:29:54 UTC (rev 9870)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.javascript;
+
+/**
+ * Created 04.08.2008
+ * @author Nick Belaevski
+ * @since 3.2.2
+ */
+
+public class JSBind extends ScriptStringBase {
+
+ private JSFunction function;
+
+ private String[] vars;
+
+ public JSBind(JSFunction function, String... vars) {
+ super();
+ this.function = function;
+ this.vars = vars;
+ }
+
+ public void appendScript(StringBuffer functionString) {
+ functionString.append("function () {");
+ functionString.append("var vars = {");
+ boolean isFirst = true;
+ for (String var : vars) {
+ if (isFirst) {
+ isFirst = false;
+ } else {
+ functionString.append(',');
+ }
+
+ functionString.append(var);
+ functionString.append(':');
+ functionString.append(var);
+ }
+
+ functionString.append("};");
+
+ functionString.append("return function() { with (vars) {");
+ functionString.append(function.toScript());
+ functionString.append("}}}()");
+
+ }
+
+}
16 years, 4 months
JBoss Rich Faces SVN: r9869 - trunk/ui/tree/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2008-08-01 12:35:32 -0400 (Fri, 01 Aug 2008)
New Revision: 9869
Modified:
trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
Log:
RF-3653
Modified: trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2008-08-01 16:35:20 UTC (rev 9868)
+++ trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2008-08-01 16:35:32 UTC (rev 9869)
@@ -65,6 +65,13 @@
boolean showLines = tree.isShowConnectingLines();
String id = treeNode.getClientId(context);
+ String script;
+ if (tree.isExpanded()) {
+ script = (String)tree.getAttributes().get("oncollapse");
+ } else {
+ script = (String)tree.getAttributes().get("onexpand");
+ }
+
if (UITree.SWITCH_AJAX.equals(tree.getSwitchType())) {
UITreeNode nodeFacet = tree.getNodeFacet();
JSFunction function = AjaxRendererUtils.buildAjaxFunction(nodeFacet,
@@ -81,6 +88,8 @@
function.addParameter(eventOptions);
StringBuffer buffer = new StringBuffer();
+ buffer.append(script);
+ buffer.append(";");
function.appendScript(buffer);
buffer.append(";");
return buffer.toString();
@@ -89,6 +98,8 @@
String paramName = id + NODE_EXPANDED_INPUT_SUFFIX;
StringBuffer result = new StringBuffer();
+ result.append(script);
+ result.append(";");
result.append('{');
result.append("var form = A4J.findForm(this);");
result.append("var params = new Object();");
16 years, 4 months
JBoss Rich Faces SVN: r9868 - in trunk/sandbox/ui/extendedDataTable/src/main: java/org/richfaces/renderkit and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-08-01 12:35:20 -0400 (Fri, 01 Aug 2008)
New Revision: 9868
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTableState.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DraggableRendererContributor.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableMenuRenderer.java
trunk/sandbox/ui/extendedDataTable/src/main/templates/org/richfaces/htmlExtendedDataTable.jspx
Log:
TODOs committed
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2008-08-01 15:52:49 UTC (rev 9867)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2008-08-01 16:35:20 UTC (rev 9868)
@@ -48,6 +48,7 @@
*/
public static final String COMPONENT_FAMILY = "org.richfaces.ExtendedDataTable";
+ //TODO nick - please rename this class to indicate that's not the instance of UIComponent
protected UIExtendedDataTableState state;
public abstract Object getActiveRowKey();
@@ -57,6 +58,7 @@
public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
if (event instanceof AjaxEvent) {
+ //TODO nick - add regions from component too
AjaxContext.getCurrentInstance().addComponentToAjaxRender(this);
} else if (event instanceof DragDropEvent) {
processDradDrop((DragDropEvent) event);
@@ -73,6 +75,8 @@
}
public void queueEvent(FacesEvent event) {
+ //TODO nick - queued events can be bubbled from nested component and not generated
+ // by the table itself. Please check source of the event!
if (event instanceof AjaxEvent) {
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
} else if (event instanceof DragDropEvent) {
@@ -223,6 +227,8 @@
if (isGroupingOn()) {// grouping is on
String groupColId = getGroupingColumnId();
// try to add group column id as first
+
+ //TODO nick - is it ok to change user's priorities collection here?
if (priority.contains(groupColId)) {
priority.remove(groupColId);
}
@@ -317,6 +323,7 @@
* RENDER_RESPONSE phase. In that version data model is reseted which causes
* need to sort and filter every time component is rendered. In this
*/
+ //TODO nick - that's needed because component can be switched to another data model
// @Override
protected void resetDataModel() {
// Do nothing!
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTableState.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTableState.java 2008-08-01 15:52:49 UTC (rev 9867)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTableState.java 2008-08-01 16:35:20 UTC (rev 9868)
@@ -287,6 +287,7 @@
}
private String formatWidth(String value){
+ //TODO nick - use org.ajax4jsf.util.HtmlDimensions.decode(String)
if(value.endsWith("px"))
return value.substring(0,value.indexOf("px"));
return value;
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java 2008-08-01 15:52:49 UTC (rev 9867)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedRowsRenderer.java 2008-08-01 16:35:20 UTC (rev 9868)
@@ -36,12 +36,6 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.Row;
-import org.richfaces.renderkit.AbstractRowsRenderer;
-import org.richfaces.renderkit.CompositeRenderer;
-import org.richfaces.renderkit.RendererContributor;
-import org.richfaces.renderkit.ScriptOptions;
-import org.richfaces.renderkit.TableHolder;
-
import org.richfaces.component.UIExtendedDataTable;
import org.richfaces.renderkit.html.TableSelectionRendererContributor;
@@ -53,6 +47,9 @@
HeaderResourcesRendererBase implements DataVisitor {
protected static final String MENU_ID = "_TABLE_MENU_ID_";
+
+ //TODO nick - renderer classes are singletons by nature, they should not have
+ // non-static/non-final fields
protected boolean firstRow = true;
protected class CompositeRendererEnabler extends CompositeRenderer {
@@ -211,7 +208,9 @@
"captionStyle");
writer.startElement("caption", table);
if (captionClass != null) {
- captionClass = "extdt-caption rich-extdt-caption "
+ //TODO nick - dr-* classes are legacy and can be removed safely.
+ // CSS styling can be defined in rich-* classes instead
+ captionClass = "extdt-caption rich-extdt-caption "
+ captionClass;
} else {
captionClass = "extdt-caption rich-extdt-caption";
@@ -261,6 +260,7 @@
protected void encodeStyleClass(ResponseWriter writer,
Object parentPredefined, Object predefined, Object parent,
Object custom) throws IOException {
+ //TODO nick - StringBuilder is more performant
StringBuffer styleClass = new StringBuffer();
// Construct predefined classes
if (null != parentPredefined) {
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DraggableRendererContributor.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DraggableRendererContributor.java 2008-08-01 15:52:49 UTC (rev 9867)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/DraggableRendererContributor.java 2008-08-01 16:35:20 UTC (rev 9868)
@@ -26,6 +26,8 @@
* @author pawelgo
*
*/
+
+//TODO nick - please rename classes & resources to prevent collisions with RF classes!!
public class DraggableRendererContributor implements RendererContributor {
private static DraggableRendererContributor instance;
Modified: trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableMenuRenderer.java
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableMenuRenderer.java 2008-08-01 15:52:49 UTC (rev 9867)
+++ trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableMenuRenderer.java 2008-08-01 16:35:20 UTC (rev 9868)
@@ -107,6 +107,7 @@
protected String getFacesResourceURL(FacesContext context, String Url) {
WebXml webXml = WebXml.getInstance(context);
StringBuffer buf = new StringBuffer();
+ //TODO nick - use InternetResourceBuilder
buf.append(webXml.getResourcePrefix()).append(Url);
// Insert suffix mapping
if (webXml.isPrefixMapping()) {
Modified: trunk/sandbox/ui/extendedDataTable/src/main/templates/org/richfaces/htmlExtendedDataTable.jspx
===================================================================
--- trunk/sandbox/ui/extendedDataTable/src/main/templates/org/richfaces/htmlExtendedDataTable.jspx 2008-08-01 15:52:49 UTC (rev 9867)
+++ trunk/sandbox/ui/extendedDataTable/src/main/templates/org/richfaces/htmlExtendedDataTable.jspx 2008-08-01 16:35:20 UTC (rev 9868)
@@ -52,6 +52,11 @@
]]>
</jsp:scriptlet>
+ <!--
+ TODO nick - enclose all HTML elements into one container element or add them
+ to rendered areas manually in order to be handled correctly by AJAX updates
+ -->
+
<div id="#{clientId}:dataTable_indicator" class="drgind_fly drgind_default drag_indicator" style="display: none;" >
<f:call name="encodeNamespace" />
16 years, 4 months
JBoss Rich Faces SVN: r9867 - trunk/docs/userguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2008-08-01 11:52:49 -0400 (Fri, 01 Aug 2008)
New Revision: 9867
Modified:
trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml
Log:
https://jira.jboss.org/jira/browse/RF-3892 - State Manager API section creation
Modified: trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml 2008-08-01 15:24:19 UTC (rev 9866)
+++ trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml 2008-08-01 15:52:49 UTC (rev 9867)
@@ -2378,7 +2378,7 @@
</listitem>
</itemizedlist>
</section>
- <section>
+ <section id="BiuldInSkinnability">
<title>Built-in skinnability in RichFaces</title>
<para>
RichFaces gives an opportunity to incorporate
@@ -2495,8 +2495,6 @@
classes to particular elements or to container of
elements that nests controls.
</para>
-
-
<para>
Standard controls skinning feature provides 2 levels of
skinning - standard and extended, while skinning is
@@ -2539,10 +2537,8 @@
</listitem>
</itemizedlist>
</listitem>
-
<listitem>
<para>
-
<emphasis>
<property>Extended</property>
</emphasis>
@@ -2569,10 +2565,7 @@
</listitem>
</itemizedlist>
-
-
<para>
-
These are the elements that affected by skinning:
</para>
<itemizedlist>
@@ -2624,10 +2617,7 @@
</property>
</para>
</listitem>
-
</itemizedlist>
-
-
<para>Skinning can be initialized in two ways:</para>
<itemizedlist>
<listitem>
@@ -2662,14 +2652,12 @@
</para>
</listitem>
</itemizedlist>
-
<para>
By setting
<code>org.richfaces.CONTROL_SKINNING_CLASSES</code>
to "enable" you are provided with style
classes applicable to:
</para>
-
<itemizedlist>
<listitem>
<para>
@@ -2716,15 +2704,10 @@
"link" and pseudo class name,
e.g.: rich-link, rich-link-hover,
rich-link-visited
-
-
-
</para>
</note>
</listitem>
</itemizedlist>
-
-
<para>
Additionally, the predefined rich CSS classes that we
provide can be used not only as classes for basic HTML
@@ -2734,8 +2717,6 @@
<para>
There is a snippet with some of them for example:
</para>
-
-
<programlisting role="XML"><![CDATA[...
<u:selector name=".rich-box-bgcolor-header">
<u:style name="background-color" skin="headerBackgroundColor" />
@@ -2761,20 +2742,14 @@
<u:style name="background-repeat" value="repeat-x" />
</u:selector>
...]]></programlisting>
-
-
<para>
To get a better idea of standard component skinning we
recommend to explore CSS files located in
ui/core/src/main/resources/org/richfaces/ folder of
RichFaces svn.
</para>
-
-
- <section id="Standard">
- <?dbhtml filename="BasicLevel.html"?>
+ <section id="Standard" role="NotInToc">
<title>Standard level</title>
-
<table>
<title>
Html Elements Skin Bindings for input, select,
@@ -2788,7 +2763,6 @@
</row>
</thead>
<tbody>
-
<row>
<entry>font-size</entry>
<entry>generalSizeFont</entry>
@@ -2804,8 +2778,6 @@
</tbody>
</tgroup>
</table>
-
-
<table>
<title>
Html Elements Skin Bindings for fieldset
@@ -2818,8 +2790,6 @@
</row>
</thead>
<tbody>
-
-
<row>
<entry>border-color</entry>
<entry>panelBorderColor</entry>
@@ -2827,9 +2797,6 @@
</tbody>
</tgroup>
</table>
-
-
-
<table>
<title>Html Elements Skin Bindings for hr</title>
<tgroup cols="2">
@@ -2840,7 +2807,6 @@
</row>
</thead>
<tbody>
-
<row>
<entry>border-color</entry>
<entry>panelBorderColor</entry>
@@ -2848,7 +2814,6 @@
</tbody>
</tgroup>
</table>
-
<table>
<title>Html Elements Skin Bindings for a</title>
<tgroup cols="2">
@@ -2859,18 +2824,13 @@
</row>
</thead>
<tbody>
-
-
-
<row>
<entry>color</entry>
<entry>generalLinkColor</entry>
</row>
-
</tbody>
</tgroup>
</table>
-
<table>
<title>
Html Elements Skin Bindings for a:hover
@@ -2883,7 +2843,6 @@
</row>
</thead>
<tbody>
-
<row>
<entry>color</entry>
<entry>
@@ -2893,8 +2852,6 @@
</tbody>
</tgroup>
</table>
-
-
<table>
<title>
Html Elements Skin Bindings for a:visited
@@ -2907,7 +2864,6 @@
</row>
</thead>
<tbody>
-
<row>
<entry>color</entry>
<entry>visitedLinkColor</entry>
@@ -2915,10 +2871,6 @@
</tbody>
</tgroup>
</table>
-
-
-
-
<table>
<title>
Rich Elements Skin Bindings for .rich-input,
@@ -2934,7 +2886,6 @@
</row>
</thead>
<tbody>
-
<row>
<entry>font-size</entry>
<entry>generalSizeFont</entry>
@@ -2950,10 +2901,6 @@
</tbody>
</tgroup>
</table>
-
-
-
-
<table>
<title>
Rich Elements Skin Bindings for .rich-fieldset
@@ -2973,8 +2920,6 @@
</tbody>
</tgroup>
</table>
-
-
<table>
<title>
Rich Elements Skin Bindings for .rich-hr
@@ -2987,19 +2932,14 @@
</row>
</thead>
<tbody>
-
<row>
<entry>border-color</entry>
<entry>panelBorderColor</entry>
</row>
-
-
-
<row>
<entry>border-width</entry>
<entry>1px</entry>
</row>
-
<row>
<entry>border-style</entry>
<entry>solid</entry>
@@ -3007,8 +2947,6 @@
</tbody>
</tgroup>
</table>
-
-
<table>
<title>
Rich Elements Skin Bindings for .rich-link
@@ -3021,7 +2959,6 @@
</row>
</thead>
<tbody>
-
<row>
<entry>color</entry>
<entry>generalLinkColor</entry>
@@ -3029,10 +2966,6 @@
</tbody>
</tgroup>
</table>
-
-
-
-
<table>
<title>
Rich Elements Skin Bindings for .rich-link:hover
@@ -3045,18 +2978,13 @@
</row>
</thead>
<tbody>
-
<row>
<entry>color</entry>
<entry>hoverLinkColor</entry>
</row>
-
</tbody>
</tgroup>
</table>
-
-
-
<table>
<title>
Rich Elements Skin Bindings for
@@ -3070,17 +2998,13 @@
</row>
</thead>
<tbody>
-
-
<row>
<entry>color</entry>
<entry>visitedLinkColor</entry>
</row>
-
</tbody>
</tgroup>
</table>
-
<table>
<title>
Rich Elements Skin Bindings for
@@ -3456,12 +3380,10 @@
</section>
- <section id="AdvancedLevel">
+ <section id="AdvancedLevel" role="NotInToc">
<?dbhtml filename="AdvancedLevel.html"?>
<title>Extended level</title>
-
<table>
-
<title>
Html Elements Skin Bindings for input, select,
textarea, button, keygen, isindex
@@ -3486,15 +3408,9 @@
<entry>color</entry>
<entry>controlTextColor</entry>
</row>
-
-
-
-
</tbody>
</tgroup>
</table>
-
-
<table>
<title>
Html Elements Skin Bindings for *|button
@@ -3507,47 +3423,35 @@
</row>
</thead>
<tbody>
-
-
<row>
<entry>border-color</entry>
<entry>panelBorderColor</entry>
</row>
-
<row>
<entry>font-size</entry>
<entry>generalSizeFont</entry>
</row>
-
<row>
<entry>font-family</entry>
<entry>generalFamilyFont</entry>
</row>
-
<row>
<entry>color</entry>
<entry>headerTextColor</entry>
</row>
-
<row>
<entry>background-color</entry>
<entry>headerBackgroundColor</entry>
</row>
-
<row>
<entry>background-image</entry>
<entry>
org.richfaces.renderkit.html.images.ButtonBackgroundImage
</entry>
</row>
-
-
</tbody>
</tgroup>
</table>
-
-
-
<table>
<title>
Html Elements Skin Bindings for
@@ -3563,35 +3467,26 @@
</row>
</thead>
<tbody>
-
<row>
<entry>border-color</entry>
<entry>panelBorderColor</entry>
</row>
-
<row>
<entry>font-size</entry>
<entry>generalSizeFont</entry>
</row>
-
-
-
<row>
<entry>font-family</entry>
<entry>generalFamilyFont</entry>
</row>
-
<row>
<entry>color</entry>
<entry>headerTextColor</entry>
</row>
-
-
<row>
<entry>background-color</entry>
<entry>headerBackgroundColor</entry>
</row>
-
<row>
<entry>background-image</entry>
<entry>
@@ -3601,8 +3496,6 @@
</tbody>
</tgroup>
</table>
-
-
<table>
<title>
Html Elements Skin Bindings for
@@ -3617,40 +3510,31 @@
</row>
</thead>
<tbody>
-
<row>
<entry>color</entry>
<entry>tabDisabledTextColor</entry>
</row>
-
<row>
<entry>border-color</entry>
<entry>
tableFooterBackgroundColor
</entry>
</row>
-
<row>
<entry>background-color</entry>
<entry>
tableFooterBackgroundColor
</entry>
</row>
-
<row>
<entry>background-image</entry>
<entry>
org.richfaces.renderkit.html.images.ButtonDisabledBackgroundImage
</entry>
</row>
-
</tbody>
</tgroup>
</table>
-
-
-
-
<table>
<title>
Html Elements Skin Bindings for
@@ -3676,43 +3560,31 @@
</row>
</thead>
<tbody>
-
<row>
<entry>color</entry>
<entry>tabDisabledTextColor</entry>
</row>
-
<row>
<entry>background-color</entry>
<entry>
tableFooterBackgroundColor
</entry>
</row>
-
<row>
<entry>border-color</entry>
<entry>
tableFooterBackgroundColor
</entry>
</row>
-
-
<row>
<entry>background-image</entry>
<entry>
org.richfaces.renderkit.html.images.ButtonDisabledBackgroundImage
</entry>
</row>
-
</tbody>
</tgroup>
</table>
-
-
-
-
-
-
<table>
<title>
Html Elements Skin Bindings for
@@ -3731,45 +3603,25 @@
</row>
</thead>
<tbody>
-
-
<row>
<entry>color</entry>
<entry>tabDisabledTextColor</entry>
</row>
-
<row>
<entry>border-color</entry>
<entry>
tableFooterBackgroundColor
</entry>
</row>
-
<row>
<entry>background-color</entry>
<entry>
tableFooterBackgroundColor
</entry>
</row>
-
-
</tbody>
</tgroup>
</table>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<table>
<title>
Html Elements Skin Bindings for *|textarea
@@ -3782,36 +3634,26 @@
</row>
</thead>
<tbody>
-
<row>
<entry>border-color</entry>
<entry>panelBorderColor</entry>
</row>
-
<row>
<entry>font-size</entry>
<entry>generalSizeFont</entry>
</row>
-
<row>
<entry>font-family</entry>
<entry>generalFamilyFont</entry>
</row>
-
-
-
<row>
<entry>color</entry>
<entry>controlTextColor</entry>
</row>
-
<row>
<entry>background-color</entry>
<entry>controlBackgroundColor</entry>
</row>
-
-
-
<row>
<entry>background-image</entry>
<entry>
@@ -3821,7 +3663,6 @@
</tbody>
</tgroup>
</table>
-
<table>
<title>
Html Elements Skin Bindings for
@@ -3840,44 +3681,31 @@
<entry>border-color</entry>
<entry>panelBorderColor</entry>
</row>
-
<row>
<entry>font-size</entry>
<entry>generalSizeFont</entry>
</row>
-
-
-
-
<row>
<entry>font-family</entry>
<entry>generalFamilyFont</entry>
</row>
-
<row>
<entry>color</entry>
<entry>controlTextColor</entry>
</row>
-
-
-
-
<row>
<entry>background-color</entry>
<entry>controlBackgroundColor</entry>
</row>
-
<row>
<entry>background-image</entry>
<entry>
org.richfaces.renderkit.html.images.InputBackgroundImage
</entry>
</row>
-
</tbody>
</tgroup>
</table>
-
<table>
<title>
Html Elements Skin Bindings for
@@ -3892,18 +3720,13 @@
</row>
</thead>
<tbody>
-
<row>
<entry>color</entry>
<entry>tableBorderColor</entry>
</row>
-
</tbody>
</tgroup>
</table>
-
-
-
<table>
<title>
textarea[type="textarea"][disabled],
@@ -3918,21 +3741,13 @@
</row>
</thead>
<tbody>
-
<row>
<entry>color</entry>
<entry>tableBorderColor</entry>
</row>
-
</tbody>
</tgroup>
</table>
-
-
-
-
-
-
<table>
<title>
textarea[type="textarea"][disabled],
@@ -3947,27 +3762,19 @@
</row>
</thead>
<tbody>
-
<row>
<entry>color</entry>
<entry>tableBorderColor</entry>
</row>
-
</tbody>
</tgroup>
</table>
-
-
-
-
</section>
</section>
-
<section id="XCSSfileformat">
<title>XCSS file format</title>
-
<para>
XCSS files are the core of RichFaces components
skinnability.
@@ -3976,18 +3783,12 @@
XCSS is an XML formatted CSS that adds extra
functionality to the skinning process
</para>
-
-
<para>
XCSS extends skinning possibilities by parsing the XCSS
file that contains all look-and-feel parameters of a
particular component into a standard CSS file that a web
browser can recognize.
</para>
-
-
-
-
<para>
XCSS file contains CSS properties and skin parameters
mappings. Mapping of a CSS selector to a skin parameter
@@ -4020,7 +3821,6 @@
}
...
]]></programlisting>
-
<para>
The
<emphasis><property>"name"</property></emphasis>
@@ -4037,8 +3837,6 @@
tag can also be used to assign a value to a CSS
property.
</para>
-
-
<para>
CSS selectors with identical skinning properties can be
set as a comma separated list.
@@ -4049,10 +3847,10 @@
</u:selector>
...
]]></programlisting>
-
</section>
- <section id="StPlug-n-Skin" role="new">
+ <section id="PlugnSkin" role="new">
+ <?dbhtml filename="PlugnSkin.html"?>
<title>Plug-n-Skin</title>
<para>
@@ -4582,4 +4380,121 @@
</section>
</section>
+ <section id="statemanagerapi">
+ <title>State Manager API</title>
+ <para>
+ JSF has an advanced navigation mechanism that allows you to define navigation from view to view.
+ Navigation happens in a Web Application when a user tries to switch from one page to another page
+ either by clicking a button, a hyperlink, or another command component.
+ But there is no switch mechanism between some states/views inside a page.
+ For example in <property>Login/Register dialog</property> an existing user signs in with his user name and password,
+ but if a new user registers an additional field "Confirm" is displayed when the user clicks "To register" link:
+ </para>
+ <figure>
+ <title>
+ Login Dialog
+ </title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/stateapi1.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+ <figure>
+ <title>
+ Register Dialog
+ </title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/stateapi2.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+ <para>
+ <property>RichFaces State API</property> allows easily define some set of states for the pages and any properties for this states.
+ </para>
+ <para>
+ You could imagine one State as a set of named value bindings, method bindings, and some additional properties
+ that are used after the state activation.
+ So you could define input fields values, controls labels, actions, rendering conditions, etc.
+ using the same state variables which have different values for every State.
+ </para>
+ <para>
+ Actually States is a <property>map</property> where the entry key is name of the State and the value is a State map.
+ Concrete State map has entries with some names as keys and any objects as values.
+ So any values, method bindings, or just simple state constants could be saved in the State map.
+ </para>
+ <para>
+ One of the most convenience features of the <property>RichFaces State API</property> is a navigation between states.
+ The <property>RichFaces State API</property> implements states change as the standard JSF navigation.
+ Action component just returns outcome and the <property>RichFaces State API</property> extension for the JSF navigation handler
+ checks if this outcome registered as a <property>state change outcome</property>.
+ If the <property>state change outcome</property> is found corresponding state is activated.
+ Otherwise the standard navigation handling is called.
+ </para>
+ <para>
+ In order to use <property>RichFaces State API</property> you should perform next steps:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Register State Manager EL resolver and navigation handler in the <property>faces-config.xml</property>:
+ </para>
+ <programlisting role="XML"><![CDATA[...
+<application>
+ <navigation-handler>org.richfaces.ui.application.StateNavigationHandler</navigation-handler>
+ <el-resolver>org.richfaces.el.StateELResolver</el-resolver>
+</application>
+...]]></programlisting>
+ </listitem>
+ <listitem>
+ <para>
+ Register an additional application factory in the <property>faces-config.xml</property>:
+ </para>
+ <programlisting role="XML"><![CDATA[...
+<factory>
+ <application-factory>org.richfaces.ui.application.StateApplicationFactory</application-factory>
+</factory>
+...]]></programlisting>
+ </listitem>
+ <listitem>
+ <para>
+ Register two managed beans in the <property>faces-config.xml</property>:
+ </para>
+ <programlisting role="XML"><![CDATA[...
+<managed-bean>
+ <managed-bean-name>state</managed-bean-name>
+ <managed-bean-class>org.richfaces.ui.model.States</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>states</property-name>
+ <property-class>org.richfaces.ui.model.States</property-class>
+ <value>#{config.states}</value>
+ </managed-property>
+</managed-bean>
+<managed-bean>
+ <managed-bean-name>config</managed-bean-name>
+ <managed-bean-class>org.richfaces.demo.stateApi.Config</managed-bean-class>
+ <managed-bean-scope>none</managed-bean-scope>
+</managed-bean>
+...]]></programlisting>
+ <para>
+ One bean (<code>org.richfaces.demo.stateApi.Config</code>) defines and stores states.
+ </para>
+ <para>
+ The other bean (<code>org.richfaces.ui.model.States</code>) with the type <code>org.richfaces.ui.model.States</code> has
+ the "states" managed property that is bound to the "config" bean which defines states.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Use <property>state</property> bindings on the pages.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ <ulink url="http://livedemo.exadel.com/richfaces-demo/richfaces/stateAPI.jsf?c=stateAPI">Here</ulink>
+ you could find the <property>Login/Register dialog</property> example and sources for the given example.
+ </para>
+ </section>
</chapter>
16 years, 4 months
JBoss Rich Faces SVN: r9866 - in trunk/samples/richfaces-demo/src/main/webapp/richfaces: beanValidator and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2008-08-01 11:24:19 -0400 (Fri, 01 Aug 2008)
New Revision: 9866
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/usage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/usage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/usage.xhtml
Log:
https://jira.jboss.org/jira/browse/RF-398- language is corrected for new livedemo components
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/usage.xhtml 2008-08-01 15:15:35 UTC (rev 9865)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/usage.xhtml 2008-08-01 15:24:19 UTC (rev 9866)
@@ -10,13 +10,13 @@
<p>
rich:ajaxValidator is a component designed in order to provide ajax validation
- inside the inputs. It designed like a4j:support component but skips all JSF processing
+ inside the inputs. It is designed like an a4j:support component but skips all JSF processing
except validation.
</p>
<p>
- Look to the first simple example. This component should be added as child component
- to input which should be validated and specify validation event. The component
- is ajaxSingle by default so only current field will be validated.
+ Look to the first simple example. This component should be added as a child component
+ to input that should be validated and specify validation event. The component
+ is ajaxSingle by default so only the current field will be validated.
</p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Title</legend>
@@ -28,10 +28,10 @@
</div>
</fieldset>
<p>
- The component also provide possibility to use Hibernate Validation for the target fileds.
+ The component also provides a possibility to use Hibernate Validation for the target fields.
</p>
<p>
- Look to the next examlpe which is modified in order to use Hibernate Validators:
+ Look to the next example which is modified in order to use Hibernate Validators:
</p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Title</legend>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/usage.xhtml 2008-08-01 15:15:35 UTC (rev 9865)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/usage.xhtml 2008-08-01 15:24:19 UTC (rev 9866)
@@ -10,13 +10,13 @@
<p>
Starting from 3.2.2 GA version Rich Faces provides support for model-based
- constraints defined using Hibernate Validator. So it's possible to use Hibernate
+ constraints defined using Hibernate Validator. Thus it's possible to use Hibernate
Validators the same as for Seam based applications.
</p>
<p>
rich:beanValidator component should be defined in the same way
as any JSF validators.
- Lock through the example below.
+ Look through the example below.
</p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Title</legend>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/usage.xhtml 2008-08-01 15:15:35 UTC (rev 9865)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/usage.xhtml 2008-08-01 15:24:19 UTC (rev 9866)
@@ -9,11 +9,11 @@
<ui:define name="sample">
<p>
- Graph validator component also allow to register Hibernate Validators for the
- input components. As opposite to beanValidator which should be
- child component for the input to be validated this component should wrap
- some subtree with inputs. As result validator for every input in this
- subtree will be added to component.
+ Graph validator component also allows to register Hibernate Validators for the
+ input components. As opposite to beanValidator that should be
+ a child component for the input to be validated this component should wrap
+ some subtree with inputs. As a result validator for every input in this
+ subtree will be added to the component.
</p>
<p>
Look through the next simple example:
@@ -33,13 +33,13 @@
</div>
</fieldset>
<p>
- There is one additional usefull feature in Graph Validator component.
+ There is one additional useful feature in Graph Validator component.
Value attribute could be defined with some value binding to bean. And the
bean properties will be validated again <b>after</b> model update.
</p>
<p>
- Simple example of such usage below. Just write some activities of the day
- and the time you spend to each one in a day.
+ Simple example of such kind of usage is shown below. Just write some activities of the day
+ and the time you spend on each one in a day.
</p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Title</legend>
@@ -51,11 +51,11 @@
</div>
</fieldset>
<p>
- In this case only properties of each passTime(values of the inputs) validated
+ In this case only properties of each passTime(values of the inputs) is validated
at validation phase.
- But after the model updated (Each explicit passtime was validated ok) all the
- properties including "TotalTime" validated again. And total validation could
- fails if the sum of the hours in a day more than 24.
+ But after the model is updated (Each explicit passtime was validated ok) all the
+ properties including "TotalTime" are validated again. And total validation could
+ fail if the sum of the hours in a day more than 24.
</p>
</ui:define>
16 years, 4 months
JBoss Rich Faces SVN: r9865 - trunk/framework/impl/src/main/java/org/ajax4jsf/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-08-01 11:15:35 -0400 (Fri, 01 Aug 2008)
New Revision: 9865
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java
Log:
fix callback function calling
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java 2008-08-01 14:54:54 UTC (rev 9864)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java 2008-08-01 15:15:35 UTC (rev 9865)
@@ -47,7 +47,6 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.context.AjaxContextImpl;
import org.ajax4jsf.context.InvokerCallback;
import org.ajax4jsf.context.ViewIdHolder;
import org.ajax4jsf.event.AjaxListener;
@@ -222,7 +221,7 @@
if (ajaxContext.isAjaxRequest() && submittedRegionClientId != null &&
!submittedRegionClientId.equals(JS_NULL)
&& !submittedRegionClientId.equals(getClientId(context))) {
- invokeOnComponent(context, submittedRegionClientId, callback);
+ invokeOnComponent(context, submittedRegionClientId, new InvokerCallbackWrapper(callback));
} else {
// For a root region, call invokeRoot method, then process all
// facets and children by invoke method.
@@ -239,11 +238,12 @@
callback.invokeContextCallback(context, iter.next());
}
} else {
- invokeOnComponent(context, ajaxSingleClientId, callback);
+ InvokerCallback invokerCallback = new InvokerCallbackWrapper(callback);
+ invokeOnComponent(context, ajaxSingleClientId, invokerCallback);
Set<String> areasToProcess = ajaxContext.getAjaxAreasToProcess();
if(null != areasToProcess){
for (String areaId : areasToProcess) {
- invokeOnComponent(context, areaId, callback);
+ invokeOnComponent(context, areaId, invokerCallback);
}
}
}
@@ -406,7 +406,7 @@
public void processDecodes(FacesContext context) {
if (context == null)
throw new NullPointerException("context");
- processPhase(context, PhaseId.APPLY_REQUEST_VALUES, new InvokerCallbackWrapper(_decodeInvoker));
+ processPhase(context, PhaseId.APPLY_REQUEST_VALUES, _decodeInvoker);
}
private InvokerCallback _updatesInvoker = new InvokerCallback() {
@@ -429,7 +429,7 @@
public void processUpdates(FacesContext context) {
if (context == null)
throw new NullPointerException("context");
- processPhase(context, PhaseId.UPDATE_MODEL_VALUES, new InvokerCallbackWrapper(_updatesInvoker));
+ processPhase(context, PhaseId.UPDATE_MODEL_VALUES, _updatesInvoker);
}
private InvokerCallback _validatorsInvoker = new InvokerCallback() {
@@ -452,7 +452,7 @@
public void processValidators(FacesContext context) {
if (context == null)
throw new NullPointerException("context");
- processPhase(context, PhaseId.PROCESS_VALIDATIONS, new InvokerCallbackWrapper(_validatorsInvoker));
+ processPhase(context, PhaseId.PROCESS_VALIDATIONS, _validatorsInvoker);
}
/*
16 years, 4 months