Author: nbelaevski
Date: 2010-12-09 09:07:18 -0500 (Thu, 09 Dec 2010)
New Revision: 20478
Added:
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxFunction.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxOptions.java
Removed:
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java
Modified:
trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js
trunk/core/impl/src/test/resources/javascript/4_0_0.html
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/samples/simpleTable-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/simpleTable.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/subTableToggleControl/samples/subTableToggleControl-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/subTableToggleControl/subTableToggleControl.xhtml
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/HandlersChain.java
trunk/ui/core/ui/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
Log:
https://issues.jboss.org/browse/RF-9809
Removed legacy cofigs from core/ui
Updated showcase for new subtable/toggler tag names
Fixed small mistake in showcase code
Modified: trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-12-09 14:05:21
UTC (rev 20477)
+++ trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-12-09 14:07:18
UTC (rev 20478)
@@ -478,7 +478,12 @@
}());
richfaces.ajax = function(source, event, options) {
- var sourceId = (typeof source == 'object' && source.id) ? source.id :
source;
+ var sourceId;
+ if (options.sourceId) {
+ sourceId = options.sourceId;
+ } else {
+ sourceId = (typeof source == 'object' && source.id) ? source.id :
source;
+ }
options = options || {};
Modified: trunk/core/impl/src/test/resources/javascript/4_0_0.html
===================================================================
--- trunk/core/impl/src/test/resources/javascript/4_0_0.html 2010-12-09 14:05:21 UTC (rev
20477)
+++ trunk/core/impl/src/test/resources/javascript/4_0_0.html 2010-12-09 14:07:18 UTC (rev
20478)
@@ -115,6 +115,21 @@
RichFaces.ajax(ajaxSource, ajaxEvent, ajaxOptions);
});
+ test("RichFaces.ajax behavior test for sourceId option", function() {
+ expect(2);
+
+ var ajaxSource = "source";
+ var ajaxEvent = "event";
+ var ajaxOptions = {parameters: {'param': 'value'}, sourceId:
'someId'};
+ jsf.ajax = {
+ request : function(source, event, options) {
+ equals(source, ajaxSource);
+ equals(options['org.richfaces.ajax.component'], 'someId');
+ }
+ }
+ RichFaces.ajax(ajaxSource, ajaxEvent, ajaxOptions);
+ });
+
test("RichFaces.ajax component test", function() {
expect(7);
var ajaxSource = "source";
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml 2010-12-09
14:07:18 UTC (rev 20478)
@@ -20,7 +20,7 @@
function disablementFunction(day){
if (day.isWeekend) return false;
if (curDt==undefined){
- curDt = day.date.getDate;
+ curDt = day.date.getDate();
}
if (curDt.getTime() - day.date.getTime() < 0) return true; else return
false;
}
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/samples/simpleTable-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/samples/simpleTable-sample.xhtml 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/samples/simpleTable-sample.xhtml 2010-12-09
14:07:18 UTC (rev 20478)
@@ -33,7 +33,7 @@
<h:outputText value="#{record.city}" />
</rich:column>
- <rich:subTable var="expense" value="#{record.items}">
+ <rich:collapsibleSubTable var="expense"
value="#{record.items}">
<rich:column>
<h:outputText value="#{expense.day}"></h:outputText>
<f:facet name="footer">
@@ -80,7 +80,7 @@
</f:facet>
</rich:column>
- </rich:subTable>
+ </rich:collapsibleSubTable>
<f:facet name="footer">
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/simpleTable.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/simpleTable.xhtml 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dataTable/simpleTable.xhtml 2010-12-09
14:07:18 UTC (rev 20478)
@@ -6,7 +6,7 @@
<ui:composition>
<p>This sample shows simple master-detail table implemented using<b>
- tbl:dataTable</b> and<b> tbl:subtable</b> components</p>
+ tbl:dataTable</b> and<b> tbl:collapsibleSubTable</b>
components</p>
<ui:include src="#{demoNavigator.sampleIncludeURI}" />
<ui:include src="/templates/includes/source-view.xhtml">
<ui:param name="src" value="#{demoNavigator.sampleIncludeURI}"
/>
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/subTableToggleControl/samples/subTableToggleControl-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/subTableToggleControl/samples/subTableToggleControl-sample.xhtml 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/subTableToggleControl/samples/subTableToggleControl-sample.xhtml 2010-12-09
14:07:18 UTC (rev 20478)
@@ -33,10 +33,10 @@
</rich:columnGroup>
</f:facet>
<rich:column colspan="6">
- <rich:subTableToggleControl for="sbtbl" />
+ <rich:collapsibleSubTableToggler for="sbtbl" />
<h:outputText value="#{list.vendor}" />
</rich:column>
- <rich:subTable value="#{list.vendorItems}" var="item"
id="sbtbl"
+ <rich:collapsibleSubTable value="#{list.vendorItems}"
var="item" id="sbtbl"
expandMode="client">
<rich:column>
<h:outputText value="#{item.model}" />
@@ -59,7 +59,7 @@
<f:facet name="footer">
<h:outputText value="Total of #{list.vendor} Cars: #{list.count}"
/>
</f:facet>
- </rich:subTable>
+ </rich:collapsibleSubTable>
</rich:dataTable>
</h:form>
</ui:composition>
\ No newline at end of file
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/subTableToggleControl/subTableToggleControl.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/subTableToggleControl/subTableToggleControl.xhtml 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/subTableToggleControl/subTableToggleControl.xhtml 2010-12-09
14:07:18 UTC (rev 20478)
@@ -6,9 +6,9 @@
<ui:composition>
<p>This sample shows simple master-detail table implemented using<b>
- rich:dataTable</b> and<b> rich:subtable</b> components</p>
+ rich:dataTable</b> and<b> rich:collapsibleSubtable</b>
components</p>
<p>There is one feature which is completely new for 4.x - subtables
- now could be collapsed/expanded by using new component
<b>rich:subTableToggleControl</b></p>
+ now could be collapsed/expanded by using new component
<b>rich:collapsibleSubTableToggler</b></p>
<p>Switching customization:</p>
<ul>
<li>subTable's could be collapsed/expanded in different modes
Deleted: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java
===================================================================
---
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -1,120 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.ajax4jsf.javascript.ScriptStringBase;
-import org.ajax4jsf.javascript.ScriptUtils;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class AjaxEventOptions extends ScriptStringBase {
-
- public static final String PARAMETERS = "parameters";
-
- public static final String CLIENT_PARAMETERS = "clientParameters";
-
- private Map<String, Object> options = new HashMap<String, Object>();
-
- public void appendScript(Appendable target) throws IOException {
- ScriptUtils.appendScript(target, options);
- }
-
- public boolean isEmpty() {
- return options.isEmpty();
- }
-
- public Object get(String optionName) {
- return options.get(optionName);
- }
-
- public void set(String optionName, Object optionValue) {
- options.put(optionName, optionValue);
- }
-
- public void remove(String optionName) {
- options.remove(optionName);
- }
-
- public boolean hasParameters() {
- @SuppressWarnings("unchecked") Map<String, Object> parameters =
(Map<String, Object>) options.get(PARAMETERS);
-
- return (parameters != null) && !parameters.isEmpty();
- }
-
- // TODO: optimize rendered data
- public Map<String, Object> getParameters() {
- @SuppressWarnings("unchecked") Map<String, Object> parameters =
(Map<String, Object>) options.get(PARAMETERS);
-
- if (parameters == null) {
- parameters = new LinkedHashMap<String, Object>();
- options.put(PARAMETERS, parameters);
- }
-
- return parameters;
- }
-
- public Object getParameter(String parameterName) {
- Object result = null;
- @SuppressWarnings("unchecked") Map<String, Object> parameters =
(Map<String, Object>) options.get(PARAMETERS);
-
- if (parameters != null) {
- result = parameters.get(parameterName);
- }
-
- return result;
- }
-
- public void setParameter(String parameterName, Object parameterValue) {
- getParameters().put(parameterName, parameterValue);
- }
-
- public void removeParameter(String parameterName) {
- @SuppressWarnings("unchecked") Map<String, Object> parameters =
(Map<String, Object>) options.get(PARAMETERS);
-
- if (parameters != null) {
- parameters.remove(parameterName);
- }
- }
-
- public Object getClientParameters() {
- return options.get(CLIENT_PARAMETERS);
- }
-
- public void setClientParameters(Object value) {
- options.put(CLIENT_PARAMETERS, value);
- }
-
- public Object getAjaxComponent() {
- return getParameter(AjaxConstants.AJAX_COMPONENT_ID_PARAMETER);
- }
-
- public void setAjaxComponent(Object ajaxComponent) {
- getParameters().put(AjaxConstants.AJAX_COMPONENT_ID_PARAMETER, ajaxComponent);
- }
-}
Added: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxFunction.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxFunction.java
(rev 0)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxFunction.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.ScriptStringBase;
+import org.ajax4jsf.javascript.ScriptUtils;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class AjaxFunction extends ScriptStringBase {
+
+ public static final String FUNCTION_NAME = "RichFaces.ajax";
+
+ private Object source;
+
+ private Object event = JSReference.EVENT;
+
+ private AjaxOptions options;
+
+ public AjaxFunction(Object source, AjaxOptions options) {
+ super();
+ this.source = source;
+ this.options = options;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+
+ public void setSource(Object source) {
+ this.source = source;
+ }
+
+ public Object getEvent() {
+ return event;
+ }
+
+ public void setEvent(Object event) {
+ this.event = event;
+ }
+
+ public AjaxOptions getOptions() {
+ return options;
+ }
+
+ public void setOptions(AjaxOptions eventOptions) {
+ this.options = eventOptions;
+ }
+
+ public void appendScript(Appendable target) throws IOException {
+ target.append(FUNCTION_NAME);
+ target.append('(');
+
+ ScriptUtils.appendScript(target, source);
+ target.append(',');
+ ScriptUtils.appendScript(target, event);
+
+ if (!options.isEmpty()) {
+ target.append(',');
+ ScriptUtils.appendScript(target, options);
+ }
+
+ target.append(")");
+ }
+
+
+}
Copied: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxOptions.java (from
rev 20403,
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java)
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxOptions.java
(rev 0)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxOptions.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -0,0 +1,128 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.ajax4jsf.javascript.ScriptStringBase;
+import org.ajax4jsf.javascript.ScriptUtils;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class AjaxOptions extends ScriptStringBase {
+
+ public static final String PARAMETERS = "parameters";
+
+ public static final String CLIENT_PARAMETERS = "clientParameters";
+
+ private Map<String, Object> options = new HashMap<String, Object>();
+
+ public void appendScript(Appendable target) throws IOException {
+ ScriptUtils.appendScript(target, options);
+ }
+
+ public boolean isEmpty() {
+ return options.isEmpty();
+ }
+
+ public Object get(String optionName) {
+ return options.get(optionName);
+ }
+
+ public void set(String optionName, Object optionValue) {
+ options.put(optionName, optionValue);
+ }
+
+ public void remove(String optionName) {
+ options.remove(optionName);
+ }
+
+ public boolean hasParameters() {
+ @SuppressWarnings("unchecked") Map<String, Object> parameters =
(Map<String, Object>) options.get(PARAMETERS);
+
+ return (parameters != null) && !parameters.isEmpty();
+ }
+
+ // TODO: optimize rendered data
+ public Map<String, Object> getParameters() {
+ @SuppressWarnings("unchecked") Map<String, Object> parameters =
(Map<String, Object>) options.get(PARAMETERS);
+
+ if (parameters == null) {
+ parameters = new LinkedHashMap<String, Object>();
+ options.put(PARAMETERS, parameters);
+ }
+
+ return parameters;
+ }
+
+ public Object getParameter(String parameterName) {
+ Object result = null;
+ @SuppressWarnings("unchecked") Map<String, Object> parameters =
(Map<String, Object>) options.get(PARAMETERS);
+
+ if (parameters != null) {
+ result = parameters.get(parameterName);
+ }
+
+ return result;
+ }
+
+ public void setParameter(String parameterName, Object parameterValue) {
+ getParameters().put(parameterName, parameterValue);
+ }
+
+ public void addParameters(Map<String, Object> params) {
+ if (params == null || params.isEmpty()) {
+ return;
+ }
+
+ getParameters().putAll(params);
+ }
+
+ public void removeParameter(String parameterName) {
+ @SuppressWarnings("unchecked") Map<String, Object> parameters =
(Map<String, Object>) options.get(PARAMETERS);
+
+ if (parameters != null) {
+ parameters.remove(parameterName);
+ }
+ }
+
+ public Object getClientParameters() {
+ return options.get(CLIENT_PARAMETERS);
+ }
+
+ public void setClientParameters(Object value) {
+ options.put(CLIENT_PARAMETERS, value);
+ }
+
+ public Object getAjaxComponent() {
+ return getParameter(AjaxConstants.AJAX_COMPONENT_ID_PARAMETER);
+ }
+
+ public void setAjaxComponent(Object ajaxComponent) {
+ getParameters().put(AjaxConstants.AJAX_COMPONENT_ID_PARAMETER, ajaxComponent);
+ }
+}
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
===================================================================
---
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -24,16 +24,20 @@
import java.util.Map;
import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxClientBehavior;
import org.ajax4jsf.component.AjaxComponent;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
-import org.richfaces.renderkit.AjaxEventOptions;
+import org.richfaces.renderkit.AjaxConstants;
+import org.richfaces.renderkit.AjaxFunction;
+import org.richfaces.renderkit.AjaxOptions;
import org.richfaces.renderkit.HtmlConstants;
+
+import com.google.common.base.Strings;
/**
* @author shura
* <p/>
@@ -45,10 +49,6 @@
public static final String AJAX_AREAS_RENDERED =
"org.ajax4jsf.areas.rendered";
public static final String AJAX_DELAY_ATTR = "requestDelay";
- /**
- * Name Javasript function for submit AJAX request
- */
- public static final String AJAX_FUNCTION_NAME = "RichFaces.ajax";
public static final String AJAX_QUEUE_ATTR = "eventsQueue";
public static final String AJAX_SINGLE_ATTR = "ajaxSingle";
@@ -79,7 +79,7 @@
private AjaxRendererUtils() {
}
- private static enum BehaviorEventOptionsData {
+ private static enum BehaviorOptionsData {
begin {
@Override
public String getAttributeValue(AjaxClientBehavior behavior) {
@@ -199,50 +199,58 @@
return onEvent;
}
- public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
UIComponent component) {
- return buildEventOptions(facesContext, component, null);
+ //TODO make this function private
+ public static AjaxOptions buildEventOptions(FacesContext facesContext, UIComponent
component) {
+ AjaxOptions ajaxOptions = new AjaxOptions();
+ appendComponentOptions(facesContext, component, ajaxOptions);
+
+ Map<String, Object> parametersMap =
RENDERER_UTILS.createParametersMap(facesContext, component);
+ ajaxOptions.addParameters(parametersMap);
+
+ return ajaxOptions;
}
- public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
UIComponent component,
+ private static AjaxOptions buildAjaxOptions(ClientBehaviorContext behaviorContext,
AjaxClientBehavior ajaxBehavior) {
- AjaxEventOptions ajaxEventOptions = new AjaxEventOptions();
+ FacesContext facesContext = behaviorContext.getFacesContext();
+ UIComponent component = behaviorContext.getComponent();
+
+ AjaxOptions ajaxOptions = new AjaxOptions();
+
Map<String, Object> parametersMap =
RENDERER_UTILS.createParametersMap(facesContext, component);
- String ajaxStatusName = getAjaxStatus(component);
-
- if (ajaxBehavior != null) {
- ajaxStatusName = (ajaxBehavior.getStatus() != null) ?
ajaxBehavior.getStatus() : ajaxStatusName;
- appenAjaxBehaviorOptions(ajaxBehavior, ajaxEventOptions);
- } else {
- appendComponentOptions(facesContext, component, ajaxEventOptions);
+ ajaxOptions.addParameters(parametersMap);
+
+ String ajaxStatusName = ajaxBehavior.getStatus();
+ if (Strings.isNullOrEmpty(ajaxStatusName)) {
+ ajaxStatusName = getAjaxStatus(component);
}
-
- if ((ajaxStatusName != null) && (ajaxStatusName.length() != 0)) {
- ajaxEventOptions.set(STATUS_ATTR_NAME, ajaxStatusName);
+ if (!Strings.isNullOrEmpty(ajaxStatusName)) {
+ ajaxOptions.set(STATUS_ATTR_NAME, ajaxStatusName);
}
- if (!parametersMap.isEmpty()) {
- ajaxEventOptions.getParameters().putAll(parametersMap);
- }
+ appenAjaxBehaviorOptions(behaviorContext, ajaxBehavior, ajaxOptions);
- return ajaxEventOptions;
+ return ajaxOptions;
}
private static boolean isNotEmpty(String value) {
return (value != null) && (value.length() != 0);
}
- private static void appenAjaxBehaviorOptions(AjaxClientBehavior behavior,
AjaxEventOptions ajaxEventOptions) {
- for (BehaviorEventOptionsData optionsData : BehaviorEventOptionsData.values()) {
- String eventHandlerValue = optionsData.getAttributeValue(behavior);
+ private static void appenAjaxBehaviorOptions(ClientBehaviorContext behaviorContext,
AjaxClientBehavior behavior, AjaxOptions ajaxOptions) {
+ ajaxOptions.setParameter(AjaxConstants.BEHAVIOR_EVENT_PARAMETER,
behaviorContext.getEventName());
+
+ for (BehaviorOptionsData optionsData : BehaviorOptionsData.values()) {
+ String optionValue = optionsData.getAttributeValue(behavior);
- if (isNotEmpty(eventHandlerValue)) {
- ajaxEventOptions.set(optionsData.toString(), eventHandlerValue);
+ if (isNotEmpty(optionValue)) {
+ ajaxOptions.set(optionsData.toString(), optionValue);
}
}
}
private static void appendComponentOptions(FacesContext facesContext, UIComponent
component,
- AjaxEventOptions ajaxEventOptions) {
+ AjaxOptions ajaxOptions) {
String behaviorName = "begin";
HandlersChain handlersChain = new HandlersChain(facesContext, component);
String inlineHandler = getAjaxOnBegin(component);
@@ -253,15 +261,20 @@
String handlerScript = handlersChain.toScript();
if (isNotEmpty(handlerScript)) {
- ajaxEventOptions.set(behaviorName, handlerScript);
+ ajaxOptions.set(behaviorName, handlerScript);
}
String queueId = getQueueId(component);
if (isNotEmpty(queueId)) {
- ajaxEventOptions.set(QUEUE_ID_ATTRIBUTE, queueId);
+ ajaxOptions.set(QUEUE_ID_ATTRIBUTE, queueId);
}
- ajaxEventOptions.set("incId", "1");
+ ajaxOptions.set("incId", "1");
+
+ String status = getAjaxStatus(component);
+ if (!Strings.isNullOrEmpty(status)) {
+ ajaxOptions.set(STATUS_ATTR_NAME, status);
+ }
}
// public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
@@ -456,16 +469,29 @@
* @param functionName
* @return
*/
- public static JSFunction buildAjaxFunction(FacesContext facesContext, UIComponent
uiComponent,
- String functionName) {
- JSFunction ajaxFunction = new JSFunction(functionName);
+ public static AjaxFunction buildAjaxFunction(FacesContext facesContext, UIComponent
component) {
+ return new AjaxFunction(component.getClientId(facesContext),
buildEventOptions(facesContext, component));
+ }
- ajaxFunction.addParameter(uiComponent.getClientId(facesContext));
- ajaxFunction.addParameter(JSReference.EVENT);
+ public static AjaxFunction buildAjaxFunction(ClientBehaviorContext behaviorContext,
AjaxClientBehavior behavior) {
+ Object source;
+
+ AjaxOptions options = buildAjaxOptions(behaviorContext, behavior);
- return ajaxFunction;
+ if (behaviorContext.getSourceId() != null) {
+ source = behaviorContext.getSourceId();
+ } else {
+ source = JSReference.THIS;
+
+ FacesContext facesContext = behaviorContext.getFacesContext();
+ UIComponent component = behaviorContext.getComponent();
+
+ options.set("sourceId", component.getClientId(facesContext));
+ }
+
+ return new AjaxFunction(source, options);
}
-
+
/**
* Append common parameters ( array of affected areas, status area id, on
* complete function ) to JavaScript event string.
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/HandlersChain.java
===================================================================
---
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/HandlersChain.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/HandlersChain.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -21,9 +21,7 @@
package org.richfaces.renderkit.util;
-import static org.richfaces.renderkit.util.AjaxRendererUtils.AJAX_FUNCTION_NAME;
import static org.richfaces.renderkit.util.AjaxRendererUtils.buildAjaxFunction;
-import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
import java.util.ArrayList;
import java.util.Collection;
@@ -41,7 +39,7 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSReference;
-import org.richfaces.renderkit.AjaxEventOptions;
+import org.ajax4jsf.javascript.ScriptString;
/**
* @author Nick Belaevski
@@ -169,13 +167,7 @@
if (!this.hasSubmittingBehavior()) {
hasSubmittingBehavior = true;
- JSFunction ajaxFunction = buildAjaxFunction(facesContext, component,
AJAX_FUNCTION_NAME);
- AjaxEventOptions eventOptions = buildEventOptions(facesContext, component);
-
- if (!eventOptions.isEmpty()) {
- ajaxFunction.addParameter(eventOptions);
- }
-
+ ScriptString ajaxFunction = buildAjaxFunction(facesContext, component);
this.addInlineHandlerAsValue(ajaxFunction.toScript());
}
}
Modified: trunk/ui/core/ui/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
===================================================================
---
trunk/ui/core/ui/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/core/ui/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -22,8 +22,6 @@
package org.ajax4jsf.renderkit;
-import static org.richfaces.renderkit.AjaxConstants.BEHAVIOR_EVENT_PARAMETER;
-
import javax.faces.application.ResourceDependency;
import javax.faces.component.ActionSource;
import javax.faces.component.EditableValueHolder;
@@ -37,10 +35,7 @@
import javax.faces.render.FacesBehaviorRenderer;
import javax.faces.render.RenderKitFactory;
-import org.ajax4jsf.component.AjaxClientBehavior;
import org.ajax4jsf.component.behavior.AjaxBehavior;
-import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.renderkit.AjaxEventOptions;
import org.richfaces.renderkit.util.AjaxRendererUtils;
import org.richfaces.renderkit.util.RendererUtils;
@@ -126,21 +121,7 @@
}
public String buildAjaxCommand(ClientBehaviorContext bContext, AjaxBehavior behavior)
{
- UIComponent parent = bContext.getComponent();
- FacesContext context = bContext.getFacesContext();
- JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(context, parent,
- AjaxRendererUtils.AJAX_FUNCTION_NAME);
- AjaxEventOptions options = buildOptions(context, bContext, behavior);
- ajaxFunction.addParameter(options);
- return ajaxFunction.toString();
+ return AjaxRendererUtils.buildAjaxFunction(bContext, behavior).toString();
}
- public AjaxEventOptions buildOptions(FacesContext context, ClientBehaviorContext
bContext,
- AjaxClientBehavior behavior) {
- UIComponent parent = bContext.getComponent();
- String eventName = bContext.getEventName();
- AjaxEventOptions options = AjaxRendererUtils.buildEventOptions(context, parent,
behavior);
- options.setParameter(BEHAVIOR_EVENT_PARAMETER, eventName);
- return options;
- }
}
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
===================================================================
---
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -31,7 +31,6 @@
import javax.faces.component.UIParameter;
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;
@@ -54,17 +53,13 @@
// func.setName(component.getName());
// Create AJAX Submit function.
- JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(context,
component,
- AjaxRendererUtils.AJAX_FUNCTION_NAME);
- AjaxEventOptions options = AjaxRendererUtils.buildEventOptions(context,
component);
+ AjaxFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(context,
component);
+ ajaxFunction.setEvent(null);
+ AjaxOptions options = ajaxFunction.getOptions();
if (options.hasParameters()) {
Map<String, Object> parameters = options.getParameters();
-// if (null == parameters) {
-// parameters = new HashMap<String, Object>();
-// options.put("parameters", parameters);
-// }
// Fill parameters.
for (Iterator<UIComponent> it = component.getChildren().iterator();
it.hasNext(); ) {
UIComponent child = it.next();
@@ -88,12 +83,7 @@
}
}
- if (!options.isEmpty()) {
- ajaxFunction.addParameter(options);
- }
-
// TODO - added in 4.0 - ?
- func.addParameter(JSReference.EVENT);
func.addToBody(ajaxFunction.toScript());
func.appendScriptToStringBuilder(script);
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -312,18 +312,12 @@
JSFunctionDefinition definition = new JSFunctionDefinition(JSReference.EVENT, new
JSReference("element"),
new JSReference("data"));
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(facesContext,
component,
- AjaxRendererUtils.AJAX_FUNCTION_NAME);
- AjaxEventOptions options = AjaxRendererUtils.buildEventOptions(facesContext,
component);
+ AjaxFunction function = AjaxRendererUtils.buildAjaxFunction(facesContext,
component);
- Map<String, Object> parameters = options.getParameters();
+ Map<String, Object> parameters = function.getOptions().getParameters();
parameters.put(component.getClientId(facesContext) + ":page", new
JSLiteral("data.page"));
- function.addParameter(options);
-
- StringBuilder sb = new StringBuilder();
- function.appendScriptToStringBuilder(sb);
- definition.addToBody(sb);
+ definition.addToBody(function.toScript());
return definition;
}
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -295,10 +295,10 @@
JSFunction function = new JSFunction("new RichFaces.ui.DataTable");
function.addParameter(dataTable.getClientId(facesContext));
- AjaxEventOptions ajaxEventOptions =
AjaxRendererUtils.buildEventOptions(facesContext, dataTable);
+ AjaxOptions ajaxOptions = AjaxRendererUtils.buildEventOptions(facesContext,
dataTable);
Map<String, Object> options = new HashMap<String, Object>();
- options.put("ajaxEventOptions", ajaxEventOptions.getParameters());
+ options.put("ajaxEventOptions", ajaxOptions.getParameters());
function.addParameter(options);
writer.writeText(function.toScript(), null);
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -23,9 +23,7 @@
import static org.richfaces.renderkit.RenderKitUtils.addToScriptHash;
import static org.richfaces.renderkit.RenderKitUtils.renderAttribute;
-import static org.richfaces.renderkit.util.AjaxRendererUtils.AJAX_FUNCTION_NAME;
import static org.richfaces.renderkit.util.AjaxRendererUtils.buildAjaxFunction;
-import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
import java.io.IOException;
import java.util.ArrayList;
@@ -76,6 +74,8 @@
})
public class ExtendedDataTableRenderer extends SelectionRenderer implements
MetaComponentRenderer {
+ private static final JSReference CLIENT_PARAMS = new
JSReference("clientParams");
+
private static enum PartName {
frozen, normal;
@@ -664,14 +664,11 @@
writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.INPUT_TYPE_HIDDEN,
null);
writer.endElement(HtmlConstants.INPUT_ELEM);
encodeSelectionInput(writer, context, component);
- JSFunction ajaxFunction = buildAjaxFunction(context, component,
AJAX_FUNCTION_NAME);
- AjaxEventOptions eventOptions = buildEventOptions(context, component);
- Map<String, Object> parameters = eventOptions.getParameters();
- eventOptions.set(AjaxEventOptions.PARAMETERS, new
JSReference("parameters"));
- ajaxFunction.addParameter(eventOptions);
+ AjaxFunction ajaxFunction = buildAjaxFunction(context, component);
+ ajaxFunction.getOptions().setClientParameters(CLIENT_PARAMS);
+
Map<String, Object> attributes = component.getAttributes();
Map<String, Object> options = new HashMap<String, Object>();
- addToScriptHash(options, "parameters", parameters);
addToScriptHash(options, "selectionMode",
attributes.get("selectionMode"),
SelectionMode.multiple);
addToScriptHash(options, "onbeforeselectionchange",
RenderKitUtils.getAttributeAndBehaviorsValue(context,
@@ -680,7 +677,7 @@
component, EVENT_ATTRIBUTES.get("onselectionchange")), null,
ScriptHashVariableWrapper.eventHandler);
StringBuilder builder = new StringBuilder("new
RichFaces.ExtendedDataTable('");
builder.append(component.getClientId(context)).append("',
").append(getRowCount(component))
- .append(", function(event, parameters)
{").append(ajaxFunction.toScript()).append(";}");
+ .append(", function(event, clientParams)
{").append(ajaxFunction.toScript()).append(";}");
if (!options.isEmpty()) {
builder.append(",").append(ScriptUtils.toScript(options));
}
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -22,8 +22,6 @@
package org.richfaces.renderkit;
import static org.richfaces.component.AbstractTree.SELECTION_META_COMPONENT_ID;
-import static org.richfaces.renderkit.util.AjaxRendererUtils.AJAX_FUNCTION_NAME;
-import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
import java.io.IOException;
import java.util.Collection;
@@ -48,6 +46,7 @@
import org.richfaces.event.TreeSelectionChangeEvent;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
@@ -100,20 +99,14 @@
return null;
}
- JSFunction ajaxFunction = new JSFunction(AJAX_FUNCTION_NAME);
+ AjaxFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(context,
component);
+ ajaxFunction.setSource(SOURCE_JS_REF);
- ajaxFunction.addParameter(SOURCE_JS_REF);
- ajaxFunction.addParameter(JSReference.EVENT);
+ AjaxOptions options = ajaxFunction.getOptions();
- AjaxEventOptions eventOptions = buildEventOptions(context, component);
+ options.set("complete", COMPLETE_JS_REF);
+ options.setClientParameters(PARAMS_JS_REF);
- eventOptions.set("complete", COMPLETE_JS_REF);
-
- eventOptions.setClientParameters(PARAMS_JS_REF);
-
- if (!eventOptions.isEmpty()) {
- ajaxFunction.addParameter(eventOptions);
- }
return ajaxFunction.toScript();
}
Modified:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js
===================================================================
---
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js 2010-12-09
14:07:18 UTC (rev 20478)
@@ -160,11 +160,6 @@
var timeoutId = null;
var sendAjax = function(event, map) {
- for (key in options.parameters) {
- if(!map[key]) {
- map[key] = options.parameters[key];
- }
- }
ajaxFunction(event, map);
};
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -38,13 +38,13 @@
import javax.faces.context.PartialViewContext;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSReference;
import org.richfaces.component.AbstractProgressBar;
import org.richfaces.component.MetaComponentResolver;
import org.richfaces.component.NumberUtils;
import org.richfaces.component.SwitchType;
-import org.richfaces.renderkit.AjaxEventOptions;
+import org.richfaces.renderkit.AjaxFunction;
+import org.richfaces.renderkit.AjaxOptions;
import org.richfaces.renderkit.MetaComponentRenderer;
import org.richfaces.renderkit.RendererBase;
import org.richfaces.renderkit.util.AjaxRendererUtils;
@@ -140,12 +140,14 @@
return null;
}
- JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(facesContext,
component, AjaxRendererUtils.AJAX_FUNCTION_NAME);
- AjaxEventOptions eventOptions = AjaxRendererUtils.buildEventOptions(facesContext,
component);
- eventOptions.set("beforedomupdate", BEFORE_UPDATE_HANDLER);
- eventOptions.set("complete", AFTER_UPDATE_HANDLER);
- eventOptions.setClientParameters(PARAMS);
- ajaxFunction.addParameter(eventOptions);
+ AjaxFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(facesContext,
component);
+
+ AjaxOptions options = ajaxFunction.getOptions();
+
+ options.set("beforedomupdate", BEFORE_UPDATE_HANDLER);
+ options.set("complete", AFTER_UPDATE_HANDLER);
+ options.setClientParameters(PARAMS);
+
return ajaxFunction.toScript();
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-12-09
14:05:21 UTC (rev 20477)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-12-09
14:07:18 UTC (rev 20478)
@@ -41,7 +41,7 @@
import org.richfaces.component.AbstractTogglePanel;
import org.richfaces.component.AbstractTogglePanelItem;
import org.richfaces.component.util.HtmlUtil;
-import org.richfaces.renderkit.AjaxEventOptions;
+import org.richfaces.renderkit.AjaxOptions;
import org.richfaces.renderkit.HtmlConstants;
import org.richfaces.renderkit.util.AjaxRendererUtils;
import org.richfaces.renderkit.util.FormUtil;
@@ -168,7 +168,7 @@
}
}
- public static AjaxEventOptions getAjaxOptions(FacesContext context, UIComponent
panel) {
+ public static AjaxOptions getAjaxOptions(FacesContext context, UIComponent panel) {
return AjaxRendererUtils.buildEventOptions(context, panel);
}