Author: konstantin.mishin
Date: 2010-07-01 15:58:07 -0400 (Thu, 01 Jul 2010)
New Revision: 17702
Modified:
root/commons/trunk/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
root/examples/iteration-demo/trunk/src/main/webapp/extendedtable.xhtml
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/html/HtmlExtendedDataTable.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
Log:
RF-8101
Modified:
root/commons/trunk/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
---
root/commons/trunk/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-07-01
19:24:55 UTC (rev 17701)
+++
root/commons/trunk/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-07-01
19:58:07 UTC (rev 17702)
@@ -255,9 +255,8 @@
}
}
- public static void renderAttributeAndBehaviors(FacesContext facesContext, UIComponent
component,
- ComponentAttribute componentAttribute) throws IOException {
-
+ public static Object getAttributeAndBehaviorsValue(FacesContext facesContext,
UIComponent component,
+ ComponentAttribute componentAttribute) {
if (facesContext == null) {
throw new NullPointerException("facesContext");
}
@@ -270,7 +269,6 @@
throw new NullPointerException("componentAttribute");
}
- String htmlAttributeName = componentAttribute.getHtmlAttributeName();
String componentAttributeName = componentAttribute.getComponentAttributeName();
Object attributeValue = component.getAttributes().get(componentAttributeName);
@@ -293,8 +291,13 @@
}
}
}
+ return attributeValue;
+ }
- renderAttribute(facesContext, htmlAttributeName, attributeValue);
+ public static void renderAttributeAndBehaviors(FacesContext facesContext, UIComponent
component,
+ ComponentAttribute componentAttribute) throws IOException {
+ Object attributeValue = getAttributeAndBehaviorsValue(facesContext, component,
componentAttribute);
+ renderAttribute(facesContext, componentAttribute.getHtmlAttributeName(),
attributeValue);
}
public static void renderPassThroughAttributesOptimized(FacesContext context,
UIComponent component,
Modified: root/examples/iteration-demo/trunk/src/main/webapp/extendedtable.xhtml
===================================================================
--- root/examples/iteration-demo/trunk/src/main/webapp/extendedtable.xhtml 2010-07-01
19:24:55 UTC (rev 17701)
+++ root/examples/iteration-demo/trunk/src/main/webapp/extendedtable.xhtml 2010-07-01
19:58:07 UTC (rev 17702)
@@ -79,8 +79,9 @@
value="#{dataBean.state ? dataBean.employeeList : null}"
var="record" noDataLabel="There isn't data."
styleClass="extendedDataTable" rowKeyVar="rkv"
filterVar="fv" sortMode="multi"
selectionMode="#{dataBean.selectionMode}"
selectedRowKeys="#{dataBean.selectedRowKeys}"
- onselectionchange="document.getElementById('submit').click();"
onbeforeselectionchange="if
(document.getElementById('selectionLocker').checked) return false;">
- <f:facet name="header">
+ onbeforeselectionchange="if
(document.getElementById('selectionLocker').checked) {event.preventDefault();
return false;}">
+ <f:ajax render=":form1:selectionOutput" />
+ <f:facet name="header">
<h:outputText value="Current date: #{dataBean.date}"/>
</f:facet>
<f:facet name="footer">
@@ -100,6 +101,9 @@
</f:facet>
</c:if>
</rich:column>
+ <rich:column>
+ <textarea cols="5" rows="5"/>
+ </rich:column>
<rich:column id="column_name"
filterExpression="#{fn:containsIgnoreCase(record.name, fv)}"
sortBy="#{record.name}">
<f:facet name="header">
<h:outputText id="columnHeader1" value="Column Header
Facet"/>
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/html/HtmlExtendedDataTable.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/html/HtmlExtendedDataTable.java 2010-07-01
19:24:55 UTC (rev 17701)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/html/HtmlExtendedDataTable.java 2010-07-01
19:58:07 UTC (rev 17702)
@@ -21,12 +21,21 @@
*/
package org.richfaces.component.html;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.faces.component.behavior.ClientBehaviorHolder;
+
import org.richfaces.component.UIExtendedDataTable;
-public class HtmlExtendedDataTable extends UIExtendedDataTable {
+public class HtmlExtendedDataTable extends UIExtendedDataTable implements
ClientBehaviorHolder {
public static final String COMPONENT_TYPE =
"org.richfaces.ExtendedDataTable";
+ private static final Collection<String> EVENT_NAMES =
Collections.unmodifiableCollection(Arrays.asList(
+ "selectionchange", "beforeselectionchange"));
+
private static enum PropertyKeys {
style, styleClass, frozenColumns
}
@@ -58,4 +67,12 @@
public void setFrozenColumns(Integer frozenColumns) {
getStateHelper().put(PropertyKeys.frozenColumns, frozenColumns);
}
+
+ public Collection<String> getEventNames() {
+ return EVENT_NAMES;
+ }
+
+ public String getDefaultEventName() {
+ return "selectionchange";
+ }
}
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-07-01
19:24:55 UTC (rev 17701)
+++
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-07-01
19:58:07 UTC (rev 17702)
@@ -28,6 +28,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -205,6 +206,11 @@
}
+ private static final Map<java.lang.String,
org.richfaces.renderkit.ComponentAttribute> EVENT_ATTRIBUTES = Collections
+ .unmodifiableMap(ComponentAttribute.createMap(new
ComponentAttribute("onselectionchange")
+ .setEventNames(new String[] {"selectionchange"}), new
ComponentAttribute("onbeforeselectionchange")
+ .setEventNames(new String[] {"beforeselectionchange"})));
+
private void encodeEmptyFooterCell(FacesContext context, ResponseWriter writer,
UIComponent column)
throws IOException {
if (column.isRendered()) {
@@ -643,10 +649,10 @@
utils.addToScriptHash(options, "parameters", parameters);
utils.addToScriptHash(options, "selectionMode",
attributes.get("selectionMode"),
SelectionMode.multiple.toString());
- utils.addToScriptHash(options, "onbeforeselectionchange",
attributes.get("onbeforeselectionchange"), null,
- ScriptHashVariableWrapper.EVENT_HANDLER);
- utils.addToScriptHash(options, "onselectionchange",
attributes.get("onselectionchange"), null,
- ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "onbeforeselectionchange",
RenderKitUtils.getAttributeAndBehaviorsValue(context,
+ component, EVENT_ATTRIBUTES.get("onbeforeselectionchange")), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "onselectionchange",
RenderKitUtils.getAttributeAndBehaviorsValue(context,
+ component, EVENT_ATTRIBUTES.get("onselectionchange")), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
StringBuilder builder = new StringBuilder("new
RichFaces.ExtendedDataTable('");
builder.append(component.getClientId(context)).append("',
").append(getRowCount(component))
.append(", function(event, parameters)
{").append(ajaxFunction.toScript()).append(";}");
Modified:
root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
===================================================================
---
root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-07-01
19:24:55 UTC (rev 17701)
+++
root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-07-01
19:58:07 UTC (rev 17702)
@@ -498,7 +498,7 @@
}
var onbeforeselectionchange = function (event) {
- return !options.onbeforeselectionchange || options.onbeforeselectionchange(event) !==
false;
+ return !options.onbeforeselectionchange ||
options.onbeforeselectionchange.call(element, event) !== false;
}
var onselectionchange = function (event, index, changed) {
@@ -511,7 +511,7 @@
if (changed) {
writeSelection();
if (options.onselectionchange) {
- options.onselectionchange(event);
+ options.onselectionchange.call(element, event);
}
}
}
@@ -555,7 +555,7 @@
selectRows([0, rows]);
selectionFlag = "a";
onselectionchange(event, activeIndex, true); //TODO Is there a way to know that
selection haven't changed?
- return false;
+ event.preventDefault();
}
if (typeof activeIndex == "number") {
var index;
@@ -574,7 +574,7 @@
setActiveRow(index);
//showRow
onselectionchange(event, index, changed);
- return false;
+ event.preventDefault();
}
}
}