JBoss Rich Faces SVN: r2795 - in trunk/test-applications/jsp/src/main: webapp/PanelMenu and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ayanul
Date: 2007-09-06 10:05:54 -0400 (Thu, 06 Sep 2007)
New Revision: 2795
Modified:
trunk/test-applications/jsp/src/main/java/panelMenu/PanelMenu.java
trunk/test-applications/jsp/src/main/webapp/PanelMenu/PanelMenu.jsp
Log:
http://jira.jboss.com/jira/browse/RF-850
Modified: trunk/test-applications/jsp/src/main/java/panelMenu/PanelMenu.java
===================================================================
--- trunk/test-applications/jsp/src/main/java/panelMenu/PanelMenu.java 2007-09-06 12:33:00 UTC (rev 2794)
+++ trunk/test-applications/jsp/src/main/java/panelMenu/PanelMenu.java 2007-09-06 14:05:54 UTC (rev 2795)
@@ -22,6 +22,7 @@
public PanelMenu() {
width = "500px";
mode = "none";
+ expandMode = "none";
align = "";
rendered = "true";
disabled = false;
Modified: trunk/test-applications/jsp/src/main/webapp/PanelMenu/PanelMenu.jsp
===================================================================
--- trunk/test-applications/jsp/src/main/webapp/PanelMenu/PanelMenu.jsp 2007-09-06 12:33:00 UTC (rev 2794)
+++ trunk/test-applications/jsp/src/main/webapp/PanelMenu/PanelMenu.jsp 2007-09-06 14:05:54 UTC (rev 2795)
@@ -207,11 +207,14 @@
<f:selectItem itemLabel="none" itemValue="none" />
<f:selectItem itemLabel="ajax" itemValue="ajax" />
<f:selectItem itemLabel="server" itemValue="server" />
- <a4j:support event="onclick" reRender="panelMenuID,Mode2ID"></a4j:support>
</h:selectOneRadio>
<h:outputText value="Expand mode"></h:outputText>
- <h:selectBooleanCheckbox value="#{panelMenu.expandMode}"></h:selectBooleanCheckbox>
+ <h:selectOneRadio value="#{panelMenu.expandMode}" onchange="submit();">
+ <f:selectItem itemLabel="none" itemValue="none" />
+ <f:selectItem itemLabel="ajax" itemValue="ajax" />
+ <f:selectItem itemLabel="server" itemValue="server" />
+ </h:selectOneRadio>
<h:outputText value="Align:"></h:outputText>
<h:selectOneMenu value="#{panelMenu.align}">
18 years, 8 months
JBoss Rich Faces SVN: r2794 - trunk/ui/core/src/test/java/org/ajax4jsf/component.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-09-06 08:33:00 -0400 (Thu, 06 Sep 2007)
New Revision: 2794
Modified:
trunk/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java
Log:
JUnit tests for ResourceBundleMap class.
Modified: trunk/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java
===================================================================
--- trunk/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java 2007-09-06 12:15:29 UTC (rev 2793)
+++ trunk/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java 2007-09-06 12:33:00 UTC (rev 2794)
@@ -71,4 +71,26 @@
assertEquals("#000000", loadedMap.get("shadowBackgroundColor"));
}
+
+ public void testSize() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ Map loadedMap = (Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
+ assertNotNull(loadedMap);
+
+ assertEquals(0, loadedMap.size());
+ }
+
+ public void testContainsKey() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ Map loadedMap = (Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
+ assertNotNull(loadedMap);
+
+ assertTrue(loadedMap.containsKey("shadowBackgroundColor"));
+
+ assertFalse(loadedMap.containsKey("non-existent key"));
+ }
}
18 years, 8 months
JBoss Rich Faces SVN: r2793 - trunk/ui/core/src/test/java/org/ajax4jsf/component.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-09-06 08:15:29 -0400 (Thu, 06 Sep 2007)
New Revision: 2793
Added:
trunk/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java
trunk/ui/core/src/test/java/org/ajax4jsf/component/test_skin.properties
Log:
JUnit test for UILoadBundle component.
Added: trunk/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java
===================================================================
--- trunk/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java (rev 0)
+++ trunk/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java 2007-09-06 12:15:29 UTC (rev 2793)
@@ -0,0 +1,74 @@
+/**
+ * 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.component;
+
+import java.util.Map;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class LoadBundleComponentTest extends org.ajax4jsf.tests.AbstractAjax4JsfTestCase {
+ private UIForm form;
+ private UILoadBundle bundle = null;
+ private static final String BUNDLE_NAME = "testBundle";
+
+ public LoadBundleComponentTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ bundle = (UILoadBundle) application.createComponent(UILoadBundle.COMPONENT_TYPE);
+ if (null != bundle) {
+ bundle.setId("loadBundle");
+ bundle.setVar(BUNDLE_NAME);
+ bundle.setBasename("org.ajax4jsf.component.test_skin");
+ form.getChildren().add(bundle);
+ }
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ form = null;
+ bundle = null;
+ }
+
+ public void testLoadBundle() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ Map loadedMap = (Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
+ assertNotNull(loadedMap);
+
+ assertEquals("non-existent key", loadedMap.get("non-existent key"));
+
+ assertEquals("#000000", loadedMap.get("shadowBackgroundColor"));
+ }
+}
Added: trunk/ui/core/src/test/java/org/ajax4jsf/component/test_skin.properties
===================================================================
--- trunk/ui/core/src/test/java/org/ajax4jsf/component/test_skin.properties (rev 0)
+++ trunk/ui/core/src/test/java/org/ajax4jsf/component/test_skin.properties 2007-09-06 12:15:29 UTC (rev 2793)
@@ -0,0 +1,6 @@
+# Fake property file for testing UILoadBundle
+shadowBackgroundColor=#000000
+shadowOpacity=1
+
+panelBorderColor=#C0C0C0
+subBorderColor=#ffffff
18 years, 8 months
JBoss Rich Faces SVN: r2792 - in trunk/test-applications/facelets/src/main: webapp/Tooltip and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ayanul
Date: 2007-09-06 07:19:17 -0400 (Thu, 06 Sep 2007)
New Revision: 2792
Modified:
trunk/test-applications/facelets/src/main/java/tooltip/Tooltip.java
trunk/test-applications/facelets/src/main/webapp/Tooltip/Tooltip.xhtml
Log:
http://jira.jboss.com/jira/browse/RF-677
Modified: trunk/test-applications/facelets/src/main/java/tooltip/Tooltip.java
===================================================================
--- trunk/test-applications/facelets/src/main/java/tooltip/Tooltip.java 2007-09-06 11:19:10 UTC (rev 2791)
+++ trunk/test-applications/facelets/src/main/java/tooltip/Tooltip.java 2007-09-06 11:19:17 UTC (rev 2792)
@@ -28,7 +28,7 @@
disabled = false;
value = "tooltip";
mode = "client";
- direction = "auto";
+ direction = "top-right";
horizontalOffset = 0;
verticalOffset = 0;
delay = 0;
Modified: trunk/test-applications/facelets/src/main/webapp/Tooltip/Tooltip.xhtml
===================================================================
--- trunk/test-applications/facelets/src/main/webapp/Tooltip/Tooltip.xhtml 2007-09-06 11:19:10 UTC (rev 2791)
+++ trunk/test-applications/facelets/src/main/webapp/Tooltip/Tooltip.xhtml 2007-09-06 11:19:17 UTC (rev 2792)
@@ -111,7 +111,6 @@
<f:selectItem itemLabel="top-left" itemValue="top-left" />
<f:selectItem itemLabel="bottom-right" itemValue="bottom-right" />
<f:selectItem itemLabel="bottom-left" itemValue="bottom-left" />
- <f:selectItem itemLabel="auto" itemValue="auto" />
<a4j:support event="onclick" reRender="tooltipID" />
</h:selectOneRadio>
18 years, 8 months
JBoss Rich Faces SVN: r2791 - in trunk/test-applications/jsp/src/main: webapp/Tooltip and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ayanul
Date: 2007-09-06 07:19:10 -0400 (Thu, 06 Sep 2007)
New Revision: 2791
Modified:
trunk/test-applications/jsp/src/main/java/tooltip/Tooltip.java
trunk/test-applications/jsp/src/main/webapp/Tooltip/Tooltip.jsp
Log:
http://jira.jboss.com/jira/browse/RF-677
Modified: trunk/test-applications/jsp/src/main/java/tooltip/Tooltip.java
===================================================================
--- trunk/test-applications/jsp/src/main/java/tooltip/Tooltip.java 2007-09-05 23:11:35 UTC (rev 2790)
+++ trunk/test-applications/jsp/src/main/java/tooltip/Tooltip.java 2007-09-06 11:19:10 UTC (rev 2791)
@@ -20,7 +20,7 @@
disabled = false;
value = "tooltip";
mode = "client";
- direction = "auto";
+ direction = "top-right";
horizontalOffset = 0;
verticalOffset = 0;
style = "none";
Modified: trunk/test-applications/jsp/src/main/webapp/Tooltip/Tooltip.jsp
===================================================================
--- trunk/test-applications/jsp/src/main/webapp/Tooltip/Tooltip.jsp 2007-09-05 23:11:35 UTC (rev 2790)
+++ trunk/test-applications/jsp/src/main/webapp/Tooltip/Tooltip.jsp 2007-09-06 11:19:10 UTC (rev 2791)
@@ -110,7 +110,6 @@
<f:selectItem itemLabel="top-left" itemValue="top-left" />
<f:selectItem itemLabel="bottom-right" itemValue="bottom-right" />
<f:selectItem itemLabel="bottom-left" itemValue="bottom-left" />
- <f:selectItem itemLabel="auto" itemValue="auto" />
<a4j:support event="onclick" reRender="tooltipID" />
</h:selectOneRadio>
18 years, 8 months
JBoss Rich Faces SVN: r2790 - in tags: 3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/application and 18 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-09-05 19:11:35 -0400 (Wed, 05 Sep 2007)
New Revision: 2790
Added:
tags/3.1.0-rc5/
tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java
tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
tags/3.1.0-rc5/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java
tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java
tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml
tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml
tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/form/snippets/commandLinkProblem.xhtml
tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/htmlCommandLink/
tags/3.1.0-rc5/samples/seamEAR/pom.xml
tags/3.1.0-rc5/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java
tags/3.1.0-rc5/test-applications/facelets/src/main/java/
tags/3.1.0-rc5/test-applications/facelets/src/main/webapp/
tags/3.1.0-rc5/ui/calendar/src/main/config/component/calendar.xml
tags/3.1.0-rc5/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/css/dataFilterSlider.xcss
tags/3.1.0-rc5/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
tags/3.1.0-rc5/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java
tags/3.1.0-rc5/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js
tags/3.1.0-rc5/ui/scrollableDataTable/src/main/resources/org/richfaces/renderkit/html/css/scrollable-data-table.xcss
tags/3.1.0-rc5/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/
Removed:
tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java
tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
tags/3.1.0-rc5/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java
tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java
tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml
tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml
tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/form/snippets/commandLinkProblem.xhtml
tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/htmlCommandLink/
tags/3.1.0-rc5/samples/seamEAR/pom.xml
tags/3.1.0-rc5/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java
tags/3.1.0-rc5/test-applications/facelets/src/main/java/
tags/3.1.0-rc5/test-applications/facelets/src/main/webapp/
tags/3.1.0-rc5/ui/calendar/src/main/config/component/calendar.xml
tags/3.1.0-rc5/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/css/dataFilterSlider.xcss
tags/3.1.0-rc5/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
tags/3.1.0-rc5/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java
tags/3.1.0-rc5/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js
tags/3.1.0-rc5/ui/scrollableDataTable/src/main/resources/org/richfaces/renderkit/html/css/scrollable-data-table.xcss
tags/3.1.0-rc5/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/
Log:
Release candidate 5
Copied: tags/3.1.0-rc5 (from rev 2776, trunk)
Deleted: tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,281 +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.ajax4jsf.application;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.application.ViewHandler;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.application.ViewHandlerWrapper;
-import org.ajax4jsf.component.AjaxViewRoot;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.context.ViewIdHolder;
-import org.ajax4jsf.renderkit.AjaxContainerRenderer;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.5 $ $Date: 2007/02/08 15:02:04 $
- *
- */
-public class AjaxViewHandler extends ViewHandlerWrapper {
-
- public static final String STATE_MARKER_KEY = "org.ajax4jsf.view.state";
-
- public static final String SERIALIZED_STATE_KEY = "org.ajax4jsf.view.serializedstate";
-
- private static final Log _log = LogFactory.getLog(AjaxViewHandler.class);
-
- private static final String REDIRECTED = "org.ajax4jsf.view.REDIRECTED";
-
- public static final String VIEW_ID_KEY = "org.ajax4jsf.VIEW_ID";
-
- /**
- * @param parent
- */
- public AjaxViewHandler(ViewHandler parent) {
- super(parent);
- if (_log.isDebugEnabled()) {
- _log.debug("Create instance of Ajax ViewHandler");
- }
- }
-
- /*
- * (non-Javadoc) For creating ViewRoot by Application Instead of new . Not
- * nessesary for MyFaces ( simple copy from it ) or RI 1.2
- *
- * @see javax.faces.application.ViewHandler#createView(javax.faces.context.FacesContext,
- * java.lang.String)
- */
- public UIViewRoot createView(FacesContext facesContext, String viewId) {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
- // Check for simple keep new ViewId in navigation cases.
- ViewIdHolder viewIdHolder = ajaxContext.getViewIdHolder();
- UIViewRoot riRoot;
- if (null != viewIdHolder && viewIdHolder.skipNavigation(viewId)) {
- viewIdHolder.setViewId(viewId);
- riRoot = facesContext.getViewRoot();
- } else {
- UIViewRoot root = super.createView(facesContext, viewId);
- // TODO -setup render-kit where instead of Listener ?
- if (null == root || root instanceof AjaxViewRoot) {
- riRoot = root;
- } else {
- // HACK - since only RI 1.1 use new for create ViewRoot instead
- // of Application.createComponent,
- // we can use it as flag for custom creation.
- riRoot = (UIViewRoot) facesContext.getApplication().createComponent(UIViewRoot.COMPONENT_TYPE);
- // fill properties from default.
- riRoot.setViewId(root.getViewId());
- riRoot.setLocale(root.getLocale());
- String renderKitId = root.getRenderKitId();
- // Fix facelets bug - for debug requests renderKitId is null !
- if (null == renderKitId) {
- renderKitId = calculateRenderKitId(facesContext);
- }
- riRoot.setRenderKitId(renderKitId);
- }
- if (ajaxContext.isAjaxRequest(facesContext)) {
- // Remove ajax status - for navigation states, full page will be
- // send.
- ajaxContext.setAjaxRequest(false);
- }
- }
- return riRoot;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ViewHandlerWrapper#writeState(javax.faces.context.FacesContext)
- */
- public void writeState(FacesContext context) throws IOException {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if (ajaxContext.isAjaxRequest(context)) {
- // TODO - detect case of JSF 1.1 + JSP. for all other we need own
- // state marker for
- // self-rendered regions only.
- // write marker html element - input field. Will be parsed in filter
- // and
- // replaced with real state.
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.SPAN_ELEM, null);
- writer.writeAttribute(HTML.id_ATTRIBUTE, STATE_MARKER_KEY, null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, STATE_MARKER_KEY, null);
-// writer.writeAttribute("style", "display:none;", null);
- if (!ajaxContext.isSelfRender()) {
- super.writeState(context);
- }
- writer.endElement(HTML.SPAN_ELEM);
- } else {
- super.writeState(context);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ViewHandlerWrapper#restoreView(javax.faces.context.FacesContext,
- * java.lang.String)
- */
- public UIViewRoot restoreView(FacesContext context, String viewId) {
- UIViewRoot viewRoot = super.restoreView(context, viewId);
- ExternalContext externalContext = context.getExternalContext();
- Map requestParameterMap = externalContext.getRequestParameterMap();
- Map requestMap = externalContext.getRequestMap();
-/* if (null == viewRoot) {
- if (requestParameterMap
- .containsKey(AjaxContainerRenderer.AJAX_PARAMETER_NAME)
- && !requestMap.containsKey(REDIRECTED)) {
- // New view created for AJAX request - indicate session
- // expiration.
- // We need send special response to client and suggest reload
- // page.
- String actionURL = getActionURL(context, viewId);
- // To avoid double call to redirect, if we have more then one
- // handler in chain.
- requestMap.put(REDIRECTED, Boolean.TRUE);
- if (_log.isDebugEnabled()) {
- _log
- .debug("Detect session expiration in AJAX request - view don't restored, action URL is "
- + actionURL);
- }
- try {
- Object response = externalContext.getResponse();
- if (response instanceof HttpServletResponse) {
- HttpServletResponse httpResponse = (HttpServletResponse) response;
- // TODO - get locale from request ?
- httpResponse.setHeader("Ajax-Expired", Messages
- .getMessage(Messages.AJAX_VIEW_EXPIRED));
- }
- actionURL = externalContext.encodeActionURL(actionURL);
- externalContext.redirect(actionURL);
- context.responseComplete();
- } catch (IOException e) {
- throw new FacesException(
- "Error on redirect for reload expired page", e);
- }
- }
- }
-*/ return viewRoot;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ViewHandlerWrapper#getResourceURL(javax.faces.context.FacesContext,
- * java.lang.String)
- */
- public String getResourceURL(FacesContext context, String url) {
- String resourceURL;
- if (url.startsWith(InternetResource.RESOURCE_URI_PREFIX)) {
- InternetResource resource = InternetResourceBuilder
- .getInstance()
- .createResource(
- null,
- url
- .substring(InternetResource.RESOURCE_URI_PREFIX_LENGTH));
- resourceURL = resource.getUri(context, null);
- } else {
- resourceURL = super.getResourceURL(context, url);
- }
- return resourceURL;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ViewHandlerWrapper#renderView(javax.faces.context.FacesContext,
- * javax.faces.component.UIViewRoot)
- */
- public void renderView(FacesContext context, UIViewRoot root)
- throws IOException, FacesException {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- // Broadcast Ajax events before rendering, to setup areas to update.
- if (root instanceof AjaxViewRoot) {
- AjaxViewRoot ajaxRoot = (AjaxViewRoot) root;
- Map requestMap = context.getExternalContext().getRequestMap();
- // broadcast ajax events before render response.
- if (ajaxContext.isAjaxRequest(context)
- && null == requestMap
- .get(AjaxRendererUtils.AJAX_AREAS_RENDERED)) {
- processAjaxEvents(context, ajaxRoot);
- }
- if (!context.getResponseComplete()) {
- super.renderView(context, root);
- if (ajaxContext.isAjaxRequest(context)
- && null == requestMap
- .get(AjaxRendererUtils.AJAX_AREAS_RENDERED)) {
- // HACK for MyFaces ( <f:view> tag not call renderers )
- if (_log.isDebugEnabled()) {
- _log
- .debug(Messages
- .getMessage(Messages.AJAX_RESPONSE_NOT_RENDERED_INFO));
- }
- ajaxContext.setSelfRender(true);
- //ServletResponse response = (ServletResponse) context
- // .getExternalContext().getResponse();
- Object response = (Object) context
- .getExternalContext().getResponse();
- try {
- response.getClass().getDeclaredMethod("reset",
- new Class[0]).invoke(response, new Object[0]);
- //response.reset();
- } catch (Exception e) {
- // Do nothing - we will use directly and reset
- // wrapper
- }
- ajaxContext.renderSubmittedAjaxRegion(context,true);
- }
- }
- } else {
- super.renderView(context, root);
- }
- ajaxContext.processHeadResources(context);
- }
-
- /**
- * @param context
- * @param ajaxRoot
- */
- private void processAjaxEvents(FacesContext context, AjaxViewRoot ajaxRoot) {
- // First - process reRender from active components.
- if (_log.isDebugEnabled()) {
- _log.debug(Messages.getMessage(Messages.PROCESS_AJAX_EVENTS_INFO));
- }
- ajaxRoot.broadcastAjaxEvents(context);
- }
-
-}
Copied: tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java (from rev 2788, trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java)
===================================================================
--- tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java (rev 0)
+++ tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,260 @@
+/**
+ * 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.ajax4jsf.application;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.application.ViewHandlerWrapper;
+import org.ajax4jsf.component.AjaxViewRoot;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.context.ViewIdHolder;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.5 $ $Date: 2007/02/08 15:02:04 $
+ *
+ */
+public class AjaxViewHandler extends ViewHandlerWrapper {
+
+ public static final String STATE_MARKER_KEY = "org.ajax4jsf.view.state";
+
+ public static final String SERIALIZED_STATE_KEY = "org.ajax4jsf.view.serializedstate";
+
+ private static final Log _log = LogFactory.getLog(AjaxViewHandler.class);
+
+ public static final String VIEW_EXPIRED = "org.ajax4jsf.view.EXPIRED";
+
+ public static final String VIEW_ID_KEY = "org.ajax4jsf.VIEW_ID";
+
+ /**
+ * @param parent
+ */
+ public AjaxViewHandler(ViewHandler parent) {
+ super(parent);
+ if (_log.isDebugEnabled()) {
+ _log.debug("Create instance of Ajax ViewHandler");
+ }
+ }
+
+ /*
+ * (non-Javadoc) For creating ViewRoot by Application Instead of new . Not
+ * nessesary for MyFaces ( simple copy from it ) or RI 1.2
+ *
+ * @see javax.faces.application.ViewHandler#createView(javax.faces.context.FacesContext,
+ * java.lang.String)
+ */
+ public UIViewRoot createView(FacesContext facesContext, String viewId) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
+ // Check for simple keep new ViewId in navigation cases.
+ ViewIdHolder viewIdHolder = ajaxContext.getViewIdHolder();
+ UIViewRoot riRoot;
+ if (null != viewIdHolder && viewIdHolder.skipNavigation(viewId)) {
+ viewIdHolder.setViewId(viewId);
+ riRoot = facesContext.getViewRoot();
+ } else {
+ UIViewRoot root = super.createView(facesContext, viewId);
+ // TODO -setup render-kit where instead of Listener ?
+ if (null == root || root instanceof AjaxViewRoot) {
+ riRoot = root;
+ } else {
+ // HACK - since only RI 1.1 use new for create ViewRoot instead
+ // of Application.createComponent,
+ // we can use it as flag for custom creation.
+ riRoot = (UIViewRoot) facesContext.getApplication()
+ .createComponent(UIViewRoot.COMPONENT_TYPE);
+ // fill properties from default.
+ riRoot.setViewId(root.getViewId());
+ riRoot.setLocale(root.getLocale());
+ String renderKitId = root.getRenderKitId();
+ // Fix facelets bug - for debug requests renderKitId is null !
+ if (null == renderKitId) {
+ renderKitId = calculateRenderKitId(facesContext);
+ }
+ riRoot.setRenderKitId(renderKitId);
+ }
+ // if (null ==
+ // facesContext.getExternalContext().getRequestMap().get(VIEW_EXPIRED))
+ // {
+ // Clear ajax request flag ( except new view creation )- for navigation states, full page will be
+ // send.
+ if(null != facesContext.getViewRoot()){
+ ajaxContext.setAjaxRequest(false);
+ }
+ // }
+ }
+ return riRoot;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ViewHandlerWrapper#writeState(javax.faces.context.FacesContext)
+ */
+ public void writeState(FacesContext context) throws IOException {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if (ajaxContext.isAjaxRequest(context)) {
+ // TODO - detect case of JSF 1.1 + JSP. for all other we need own
+ // state marker for
+ // self-rendered regions only.
+ // write marker html element - input field. Will be parsed in filter
+ // and
+ // replaced with real state.
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.SPAN_ELEM, null);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, STATE_MARKER_KEY, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, STATE_MARKER_KEY, null);
+ // writer.writeAttribute("style", "display:none;", null);
+ if (!ajaxContext.isSelfRender()) {
+ super.writeState(context);
+ }
+ writer.endElement(HTML.SPAN_ELEM);
+ } else {
+ super.writeState(context);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ViewHandlerWrapper#restoreView(javax.faces.context.FacesContext,
+ * java.lang.String)
+ */
+ public UIViewRoot restoreView(FacesContext context, String viewId) {
+ UIViewRoot viewRoot = super.restoreView(context, viewId);
+ ExternalContext externalContext = context.getExternalContext();
+ Map requestMap = externalContext.getRequestMap();
+ if (null == viewRoot) {
+ requestMap.put(VIEW_EXPIRED, Messages
+ .getMessage(Messages.AJAX_VIEW_EXPIRED));
+ if (_log.isDebugEnabled()) {
+ _log
+ .debug("Detect session expiration in AJAX request - view don't restored for a viewId "
+ + viewId);
+ }
+ }
+ return viewRoot;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ViewHandlerWrapper#getResourceURL(javax.faces.context.FacesContext,
+ * java.lang.String)
+ */
+ public String getResourceURL(FacesContext context, String url) {
+ String resourceURL;
+ if (url.startsWith(InternetResource.RESOURCE_URI_PREFIX)) {
+ InternetResource resource = InternetResourceBuilder
+ .getInstance()
+ .createResource(
+ null,
+ url
+ .substring(InternetResource.RESOURCE_URI_PREFIX_LENGTH));
+ resourceURL = resource.getUri(context, null);
+ } else {
+ resourceURL = super.getResourceURL(context, url);
+ }
+ return resourceURL;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ViewHandlerWrapper#renderView(javax.faces.context.FacesContext,
+ * javax.faces.component.UIViewRoot)
+ */
+ public void renderView(FacesContext context, UIViewRoot root)
+ throws IOException, FacesException {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ // Broadcast Ajax events before rendering, to setup areas to update.
+ if (root instanceof AjaxViewRoot) {
+ AjaxViewRoot ajaxRoot = (AjaxViewRoot) root;
+ Map requestMap = context.getExternalContext().getRequestMap();
+ // broadcast ajax events before render response.
+ if (ajaxContext.isAjaxRequest(context)
+ && null == requestMap
+ .get(AjaxRendererUtils.AJAX_AREAS_RENDERED)) {
+ processAjaxEvents(context, ajaxRoot);
+ }
+ if (!context.getResponseComplete()) {
+ super.renderView(context, root);
+ if (ajaxContext.isAjaxRequest(context)
+ && null == requestMap
+ .get(AjaxRendererUtils.AJAX_AREAS_RENDERED)) {
+ // HACK for MyFaces ( <f:view> tag not call renderers )
+ if (_log.isDebugEnabled()) {
+ _log
+ .debug(Messages
+ .getMessage(Messages.AJAX_RESPONSE_NOT_RENDERED_INFO));
+ }
+ ajaxContext.setSelfRender(true);
+ // ServletResponse response = (ServletResponse) context
+ // .getExternalContext().getResponse();
+ Object response = (Object) context.getExternalContext()
+ .getResponse();
+ try {
+ response.getClass().getDeclaredMethod("reset",
+ new Class[0]).invoke(response, new Object[0]);
+ // response.reset();
+ } catch (Exception e) {
+ // Do nothing - we will use directly and reset
+ // wrapper
+ }
+ ajaxContext.renderSubmittedAjaxRegion(context, true);
+ }
+ }
+ } else {
+ super.renderView(context, root);
+ }
+ ajaxContext.processHeadResources(context);
+ }
+
+ /**
+ * @param context
+ * @param ajaxRoot
+ */
+ private void processAjaxEvents(FacesContext context, AjaxViewRoot ajaxRoot) {
+ // First - process reRender from active components.
+ if (_log.isDebugEnabled()) {
+ _log.debug(Messages.getMessage(Messages.PROCESS_AJAX_EVENTS_INFO));
+ }
+ ajaxRoot.broadcastAjaxEvents(context);
+ }
+
+}
Deleted: tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,208 +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.ajax4jsf.component;
-
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyNotFoundException;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.component.AjaxSupport;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-
-/**
- * Inner class for build event string for parent component.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:38 $ Disadvantages -
- * not rebuild event string setted as EL expression. TODO - save
- * expressions for build event string at render phase.
- */
-public class EventValueBinding extends ValueBinding implements StateHolder {
-
- /**
- *
- */
- private static final long serialVersionUID = -6583167387542332290L;
-
- private String _componentId;
-
- /**
- * current update component. transient since saved state as component.
- */
- transient private AjaxSupport _component = null;
-
- /**
- * Default constructor for restoreState.
- */
- public EventValueBinding() {
-
- }
-
- /**
- * Constructor for build from AjaxComponent.
- *
- * @param update
- */
- public EventValueBinding(AjaxSupport update) {
- _component = update;
- // _componentId = string;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#getType(javax.faces.context.FacesContext)
- */
- public Class getType(FacesContext facesContext) throws EvaluationException,
- PropertyNotFoundException {
-
- return String.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#getValue(javax.faces.context.FacesContext)
- */
- public Object getValue(FacesContext facesContext)
- throws EvaluationException, PropertyNotFoundException {
- if (((UIComponent) getComponent(facesContext)).isRendered()) {
- return getComponent(facesContext).getEventString();
-
- } else {
- return null;
- }
- }
-
- private AjaxSupport getComponent(FacesContext facesContext)
- throws EvaluationException {
-
- if (_component == null) {
- UIComponent uiComponent = facesContext.getViewRoot().findComponent(
- _componentId);
- if (null != uiComponent && uiComponent instanceof AjaxComponent) {
- _component = (AjaxSupport) uiComponent;
- } else {
- throw new EvaluationException(Messages.getMessage(
- Messages.COMPONENT_NOT_FOUND, _componentId));
- }
-
- }
-
- return _component;
- }
-
- /**
- * @param component
- * the component to set
- */
- public void setComponent(AjaxSupport component) {
- _component = component;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#isReadOnly(javax.faces.context.FacesContext)
- */
- public boolean isReadOnly(FacesContext facesContext)
- throws EvaluationException, PropertyNotFoundException {
- // TODO Auto-generated method stub
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#setValue(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void setValue(FacesContext facesContext, Object value)
- throws EvaluationException, PropertyNotFoundException {
- throw new EvaluationException(Messages
- .getMessage(Messages.EVENT_IS_READ_ONLY));
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- if (null == _component) {
- return _componentId;
- } else {
- return AjaxRendererUtils
- .getAbsoluteId((UIComponent) getComponent(context));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- // TODO Auto-generated method stub
- _componentId = (String) state;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.StateHolder#isTransient()
- */
- public boolean isTransient() {
- // TODO Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.StateHolder#setTransient(boolean)
- */
- public void setTransient(boolean newTransientValue) {
- // TODO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#getExpressionString()
- */
- public String getExpressionString() {
- // FacesContext context = FacesContext.getCurrentInstance();
- // UIComponent component = (UIComponent) getComponent(context);
- // return "#{ajaxSupport["+component.getClientId(context)+"]}";
- return null;
- }
-
-}
\ No newline at end of file
Copied: tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java (from rev 2787, trunk/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java)
===================================================================
--- tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java (rev 0)
+++ tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,206 @@
+/**
+ * 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.ajax4jsf.component;
+
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+
+/**
+ * Inner class for build event string for parent component.
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:38 $ Disadvantages -
+ * not rebuild event string setted as EL expression. TODO - save
+ * expressions for build event string at render phase.
+ */
+public class EventValueBinding extends ValueBinding implements StateHolder {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6583167387542332290L;
+
+ private String _componentId;
+
+ /**
+ * current update component. transient since saved state as component.
+ */
+ transient private AjaxSupport _component = null;
+
+ /**
+ * Default constructor for restoreState.
+ */
+ public EventValueBinding() {
+
+ }
+
+ /**
+ * Constructor for build from AjaxComponent.
+ *
+ * @param update
+ */
+ public EventValueBinding(AjaxSupport update) {
+ _component = update;
+ // _componentId = string;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#getType(javax.faces.context.FacesContext)
+ */
+ public Class getType(FacesContext facesContext) throws EvaluationException,
+ PropertyNotFoundException {
+
+ return String.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#getValue(javax.faces.context.FacesContext)
+ */
+ public Object getValue(FacesContext facesContext)
+ throws EvaluationException, PropertyNotFoundException {
+ if (((UIComponent) getComponent(facesContext)).isRendered()) {
+ return getComponent(facesContext).getEventString();
+
+ } else {
+ return null;
+ }
+ }
+
+ private AjaxSupport getComponent(FacesContext facesContext)
+ throws EvaluationException {
+
+ if (_component == null) {
+ UIComponent uiComponent = facesContext.getViewRoot().findComponent(
+ _componentId);
+ if (null != uiComponent && uiComponent instanceof AjaxSupport) {
+ _component = (AjaxSupport) uiComponent;
+ } else {
+ throw new EvaluationException(Messages.getMessage(
+ Messages.COMPONENT_NOT_FOUND, _componentId));
+ }
+
+ }
+
+ return _component;
+ }
+
+ /**
+ * @param component
+ * the component to set
+ */
+ public void setComponent(AjaxSupport component) {
+ _component = component;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#isReadOnly(javax.faces.context.FacesContext)
+ */
+ public boolean isReadOnly(FacesContext facesContext)
+ throws EvaluationException, PropertyNotFoundException {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#setValue(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void setValue(FacesContext facesContext, Object value)
+ throws EvaluationException, PropertyNotFoundException {
+ throw new EvaluationException(Messages
+ .getMessage(Messages.EVENT_IS_READ_ONLY));
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ if (null == _component) {
+ return _componentId;
+ } else {
+ return AjaxRendererUtils
+ .getAbsoluteId((UIComponent) getComponent(context));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ // TODO Auto-generated method stub
+ _componentId = (String) state;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.StateHolder#isTransient()
+ */
+ public boolean isTransient() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.StateHolder#setTransient(boolean)
+ */
+ public void setTransient(boolean newTransientValue) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#getExpressionString()
+ */
+ public String getExpressionString() {
+ // FacesContext context = FacesContext.getCurrentInstance();
+ // UIComponent component = (UIComponent) getComponent(context);
+ // return "#{ajaxSupport["+component.getClientId(context)+"]}";
+ return null;
+ }
+
+}
\ No newline at end of file
Deleted: tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,438 +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.ajax4jsf.webapp;
-
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.application.AjaxViewHandler;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.AjaxContainerRenderer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class BaseXMLFilter {
- private static final Log log = LogFactory.getLog(BaseXMLFilter.class);
-
- public static final String RESPONSE_WRAPPER_ATTRIBUTE = "com.exade.vcp.Filter.ResponseWrapper";
-
- private String mimetype = "text/xml";
-
- private String publicid = "-//W3C//DTD XHTML 1.0 Transitional//EN";
-
- private String systemid = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
-
- private String namespace = "http://www.w3.org/1999/xhtml";
-
- private static final String MIME_TYPE_PARAMETER = "mime-type";
-
- private static final String PUBLICID_PARAMETER = "publicid";
-
- private static final String SYSTEMID_PARAMETER = "systemid";
-
- private static final String NAMESPACE_PARAMETER = "namespace";
-
- private boolean forcexml = false;
-
- private static final String FORCEXML_PARAMETER = "forceparser";
-
- private static final String INIT_PARAMETER_PREFIX = "org.ajax4jsf.xmlfilter.";
-
- public static final String TEXT_HTML = "text/html";
-
- public static final String APPLICATION_XHTML_XML = "application/xhtml+xml";
-
- public BaseFilter filter;
-
- public void setFilter(BaseFilter filter) {
- this.filter = filter;
- }
-
- public void init(FilterConfig config) throws ServletException {
- if (log.isDebugEnabled()) {
- log.debug("init XML filter service with class "
- + this.getClass().getName());
- }
- String forceXmlParameter = config.getInitParameter(FORCEXML_PARAMETER);
- setupForceXml(forceXmlParameter);
- forceXmlParameter = config.getServletContext().getInitParameter(
- INIT_PARAMETER_PREFIX + FORCEXML_PARAMETER);
- setMimetype((String) nz(config.getInitParameter(MIME_TYPE_PARAMETER),
- "text/xml"));
- setPublicid((String) nz(config.getInitParameter(PUBLICID_PARAMETER),
- getPublicid()));
- setSystemid((String) nz(config.getInitParameter(SYSTEMID_PARAMETER),
- getSystemid()));
- setNamespace((String) nz(config.getInitParameter(NAMESPACE_PARAMETER),
- getNamespace()));
- }
-
- /**
- * @param forceXmlParameter
- */
- private void setupForceXml(String forceXmlParameter) {
- if ("false".equalsIgnoreCase(forceXmlParameter)) {
- this.forcexml = false;
- }
- if ("true".equalsIgnoreCase(forceXmlParameter)) {
- this.forcexml = true;
- }
- }
-
- /**
- * Perform filter chain with xml parsing and transformation. Subclasses must
- * implement concrete HTML to XML parsing, nesseasary transformations and
- * serialization.
- *
- * @param chain
- * @param httpServletRequest
- * @param httpServletResponse
- * @throws ServletException
- * @throws IOException
- */
- protected void doXmlFilter(FilterChain chain, HttpServletRequest request,
- final HttpServletResponse response) throws IOException,
- ServletException {
- if (log.isDebugEnabled()) {
- log.debug("XML filter service start processing request");
- }
- FilterServletResponseWrapper servletResponseWrapper = getWrapper(response);
- // HACK - to avoid MyFaces <f:view> incompabilites and bypass
- // intermediaty filters
- // in chain, self-rendered region write directly to wrapper stored in
- // request-scope attribute.
- try {
- request.setAttribute(RESPONSE_WRAPPER_ATTRIBUTE,
- servletResponseWrapper);
- chain.doFilter(request, servletResponseWrapper);
-
- } finally {
- request.removeAttribute(RESPONSE_WRAPPER_ATTRIBUTE);
- }
- String viewId = (String) request
- .getAttribute(AjaxViewHandler.VIEW_ID_KEY);
- HtmlParser parser = null;
- // setup response
- // Redirect in AJAX request - convert to special response recognized by
- // client.
- String redirectLocation = servletResponseWrapper.getRedirectLocation();
- String characterEncoding = servletResponseWrapper
- .getCharacterEncoding();
- Writer output;
- if (null != redirectLocation) {
- if (isAjaxRequest(request)) {
- // Special handling of redirect - client-side script must
- // Check for response and perform redirect by window.location
- if (log.isDebugEnabled()) {
- log.debug("Create AJAX redirect response to url: "
- + redirectLocation);
- }
- response.reset();
- // Keep cookies.
- for (Iterator iter = servletResponseWrapper.getCookies()
- .iterator(); iter.hasNext();) {
- Cookie cookie = (Cookie) iter.next();
- response.addCookie(cookie);
- }
- // Copy response headers
- Map headers = servletResponseWrapper.getHeaders();
- for (Iterator iter = headers.entrySet().iterator(); iter
- .hasNext();) {
- Map.Entry header = (Map.Entry) iter.next();
- response.setHeader((String) header.getKey(),
- (String) header.getValue());
- }
- response.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADER,
- "redirect");
- // Not caching AJAX request
- response.setHeader("Cache-Control",
- "no-cache, must-revalidate, max_age=0, no-store");
- response.setHeader("Expires", "0");
- response.setHeader("Pragma", "no-cache");
- response.setContentType(getMimetype() + ";charset=UTF-8");
- response.setHeader(AjaxContainerRenderer.AJAX_LOCATION_HEADER,
- redirectLocation);
- output = createResponseWriter(response, "UTF-8");
- // For buggy XmlHttpRequest realisations repeat headers in
- // <meta>
- output.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
- + "<meta name=\""
- + AjaxContainerRenderer.AJAX_FLAG_HEADER
- + "\" content=\"redirect\" />" + "<meta name=\""
- + AjaxContainerRenderer.AJAX_LOCATION_HEADER
- + "\" content=\"" + redirectLocation + "\" />"
- + "</head></html>");
- output.flush();
- response.flushBuffer();
- } else {
- response.sendRedirect(redirectLocation);
- }
- return;
- } else if ("true".equals(servletResponseWrapper.getHeaders().get(
- AjaxContainerRenderer.AJAX_FLAG_HEADER))) {
- if (log.isDebugEnabled()) {
- log
- .debug("Process response to well-formed XML for AJAX XMLHttpRequest parser");
- }
- // Not caching AJAX request
- response.setHeader("Cache-Control",
- "no-cache, must-revalidate, max_age=0, no-store");
- response.setHeader("Expires", "0");
- response.setHeader("Pragma", "no-cache");
- // response.setCharacterEncoding(servletResponseWrapper
- // .getCharacterEncoding()); //
- // JSContentHandler.DEFAULT_ENCODING);
- // Set the content-type. For AJAX responses default encoding -
- // UTF8.
- // TODO - for null encoding, setup only Output encoding for
- // filter ?
- String outputEncoding = "UTF-8";
- String contentType = getMimetype() + ";charset=" + outputEncoding;
- response.setContentType(contentType);
- parser = getParser(getMimetype(), true, viewId);
- if (null == parser) {
- throw new ServletException(Messages.getMessage(
- Messages.PARSER_NOT_INSTANTIATED_ERROR, contentType));
- }
- output = createResponseWriter(response, outputEncoding);
- parser.setDoctype(getPublicid());
- parser.setInputEncoding(characterEncoding);
- parser.setOutputEncoding(outputEncoding);
- parser.setViewState((String) request
- .getAttribute(AjaxViewHandler.SERIALIZED_STATE_KEY));
- } else {
- // setup conversion reules for output contentType, send directly
- // if content not
- // supported by tidy.
- String contentType = servletResponseWrapper.getContentType();
- if (log.isDebugEnabled()) {
- log.debug("create HTML/XML parser for content type: "
- + contentType);
- }
- // if(contentType == null){
- // contentType = request.getContentType();
- // }
- if (contentType != null) {
- if (contentType.indexOf("charset") < 0
- && null != characterEncoding) {
- contentType += ";charset=" + characterEncoding;
- }
- parser = getParser(contentType, false, viewId);
- response.setContentType(contentType);
- }
- // null or unsupported content type
- if (null == parser) {
- if (log.isDebugEnabled()) {
- log
- .debug("Parser not have support for the such content type, send response as-is");
- }
- try {
- if (servletResponseWrapper.isUseWriter()) {
- output = createResponseWriter(response,
- characterEncoding);
- servletResponseWrapper.sendContent(output);
- } else if (servletResponseWrapper.isUseStream()) {
- ServletOutputStream out = response.getOutputStream();
- servletResponseWrapper.sendContent(out);
- }
- } finally {
- // reuseWrapper(servletResponseWrapper);
- }
- return;
- }
- output = createResponseWriter(response, characterEncoding);
-
- parser.setInputEncoding(characterEncoding);
- parser.setOutputEncoding(characterEncoding);
- }
-
- try {
- // Setup scripts and styles
- parser.setScripts((Set) request
- .getAttribute(AjaxContext.SCRIPTS_PARAMETER));
- parser.setStyles((Set) request
- .getAttribute(AjaxContext.STYLES_PARAMETER));
- // Process parsing.
- long startTimeMills = System.currentTimeMillis();
- servletResponseWrapper.parseContent(output, parser);
- if (log.isDebugEnabled()) {
- startTimeMills = System.currentTimeMillis() - startTimeMills;
- log.debug(Messages.getMessage(Messages.PARSING_TIME_INFO, ""
- + startTimeMills));
- }
- } catch (Exception e) {
- throw new ServletException(Messages
- .getMessage(Messages.JTIDY_PARSING_ERROR), e);
- } finally {
- reuseParser(parser);
- }
- }
-
- /**
- * @param response
- * @return
- * @throws ServletException
- */
- protected FilterServletResponseWrapper getWrapper(
- HttpServletResponse response) throws ServletException {
- return new FilterServletResponseWrapper(response);
- }
-
- /**
- * @param request
- * @return
- */
- protected boolean isAjaxRequest(ServletRequest request) {
- try {
- return null != request
- .getParameter(AjaxContainerRenderer.AJAX_PARAMETER_NAME);
- } catch (Exception e) {
- // OCJ 10 - throw exception for static resources.
- return false;
- }
- }
-
- /**
- * @param response
- * @param characterEncoding
- * @return
- * @throws IOException
- * @throws UnsupportedEncodingException
- */
- private Writer createResponseWriter(final HttpServletResponse response,
- String characterEncoding) throws IOException,
- UnsupportedEncodingException {
- Writer output;
- try {
- output = response.getWriter();
- } catch (IllegalStateException e) {
- if (null != characterEncoding) {
- output = new OutputStreamWriter(response.getOutputStream(),
- characterEncoding);
- } else {
- output = new OutputStreamWriter(response.getOutputStream());
- }
- }
- return output;
- }
-
- protected abstract void reuseParser(HtmlParser parser);
-
- protected abstract HtmlParser getParser(String mimetype, boolean isAjax,
- String viewId);
-
- /**
- * @param publicid
- * The publicid to set.
- */
- protected void setPublicid(String publicid) {
- this.publicid = publicid;
- }
-
- /**
- * @return Returns the publicid.
- */
- public String getPublicid() {
- return publicid;
- }
-
- /**
- * @param systemid
- * The systemid to set.
- */
- protected void setSystemid(String systemid) {
- this.systemid = systemid;
- }
-
- /**
- * @return Returns the systemid.
- */
- public String getSystemid() {
- return systemid;
- }
-
- /**
- * @param namespace
- * The namespace to set.
- */
- protected void setNamespace(String namespace) {
- this.namespace = namespace;
- }
-
- /**
- * @return Returns the namespace.
- */
- public String getNamespace() {
- return namespace;
- }
-
- /**
- * @param mimetype
- * The mimetype to set.
- */
- protected void setMimetype(String mimetype) {
- this.mimetype = mimetype;
- }
-
- /**
- * @return Returns the mimetype.
- */
- protected String getMimetype() {
- return mimetype;
- }
-
- /**
- * @return Returns the forcexml.
- */
- public boolean isForcexml() {
- return this.forcexml;
- }
-
- /**
- * @param forcexml
- * The forcexml to set.
- */
- protected void setForcexml(boolean forcexml) {
- this.forcexml = forcexml;
- }
-
- private Object nz(Object param, Object def) {
- return param != null ? param : def;
- }
-
-}
Copied: tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java (from rev 2788, trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java)
===================================================================
--- tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java (rev 0)
+++ tags/3.1.0-rc5/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,442 @@
+/**
+ * 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.ajax4jsf.webapp;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.application.AjaxViewHandler;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class BaseXMLFilter {
+ private static final Log log = LogFactory.getLog(BaseXMLFilter.class);
+
+ public static final String RESPONSE_WRAPPER_ATTRIBUTE = "com.exade.vcp.Filter.ResponseWrapper";
+
+ private String mimetype = "text/xml";
+
+ private String publicid = "-//W3C//DTD XHTML 1.0 Transitional//EN";
+
+ private String systemid = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
+
+ private String namespace = "http://www.w3.org/1999/xhtml";
+
+ private static final String MIME_TYPE_PARAMETER = "mime-type";
+
+ private static final String PUBLICID_PARAMETER = "publicid";
+
+ private static final String SYSTEMID_PARAMETER = "systemid";
+
+ private static final String NAMESPACE_PARAMETER = "namespace";
+
+ private boolean forcexml = false;
+
+ private static final String FORCEXML_PARAMETER = "forceparser";
+
+ private static final String INIT_PARAMETER_PREFIX = "org.ajax4jsf.xmlfilter.";
+
+ public static final String TEXT_HTML = "text/html";
+
+ public static final String APPLICATION_XHTML_XML = "application/xhtml+xml";
+
+ public BaseFilter filter;
+
+ public void setFilter(BaseFilter filter) {
+ this.filter = filter;
+ }
+
+ public void init(FilterConfig config) throws ServletException {
+ if (log.isDebugEnabled()) {
+ log.debug("init XML filter service with class "
+ + this.getClass().getName());
+ }
+ String forceXmlParameter = config.getInitParameter(FORCEXML_PARAMETER);
+ setupForceXml(forceXmlParameter);
+ forceXmlParameter = config.getServletContext().getInitParameter(
+ INIT_PARAMETER_PREFIX + FORCEXML_PARAMETER);
+ setMimetype((String) nz(config.getInitParameter(MIME_TYPE_PARAMETER),
+ "text/xml"));
+ setPublicid((String) nz(config.getInitParameter(PUBLICID_PARAMETER),
+ getPublicid()));
+ setSystemid((String) nz(config.getInitParameter(SYSTEMID_PARAMETER),
+ getSystemid()));
+ setNamespace((String) nz(config.getInitParameter(NAMESPACE_PARAMETER),
+ getNamespace()));
+ }
+
+ /**
+ * @param forceXmlParameter
+ */
+ private void setupForceXml(String forceXmlParameter) {
+ if ("false".equalsIgnoreCase(forceXmlParameter)) {
+ this.forcexml = false;
+ }
+ if ("true".equalsIgnoreCase(forceXmlParameter)) {
+ this.forcexml = true;
+ }
+ }
+
+ /**
+ * Perform filter chain with xml parsing and transformation. Subclasses must
+ * implement concrete HTML to XML parsing, nesseasary transformations and
+ * serialization.
+ *
+ * @param chain
+ * @param httpServletRequest
+ * @param httpServletResponse
+ * @throws ServletException
+ * @throws IOException
+ */
+ protected void doXmlFilter(FilterChain chain, HttpServletRequest request,
+ final HttpServletResponse response) throws IOException,
+ ServletException {
+ if (log.isDebugEnabled()) {
+ log.debug("XML filter service start processing request");
+ }
+ FilterServletResponseWrapper servletResponseWrapper = getWrapper(response);
+ // HACK - to avoid MyFaces <f:view> incompabilites and bypass
+ // intermediaty filters
+ // in chain, self-rendered region write directly to wrapper stored in
+ // request-scope attribute.
+ try {
+ request.setAttribute(RESPONSE_WRAPPER_ATTRIBUTE,
+ servletResponseWrapper);
+ chain.doFilter(request, servletResponseWrapper);
+
+ } finally {
+ request.removeAttribute(RESPONSE_WRAPPER_ATTRIBUTE);
+ }
+ String viewId = (String) request
+ .getAttribute(AjaxViewHandler.VIEW_ID_KEY);
+ HtmlParser parser = null;
+ // setup response
+ // Redirect in AJAX request - convert to special response recognized by
+ // client.
+ String redirectLocation = servletResponseWrapper.getRedirectLocation();
+ String characterEncoding = servletResponseWrapper
+ .getCharacterEncoding();
+ Object view_expired = request.getAttribute(AjaxViewHandler.VIEW_EXPIRED);
+ if(null != view_expired){
+ servletResponseWrapper.setHeader("Ajax-Expired", view_expired.toString());
+ }
+ Writer output;
+ if (null != redirectLocation) {
+ if (isAjaxRequest(request)) {
+ // Special handling of redirect - client-side script must
+ // Check for response and perform redirect by window.location
+ if (log.isDebugEnabled()) {
+ log.debug("Create AJAX redirect response to url: "
+ + redirectLocation);
+ }
+ response.reset();
+ // Keep cookies.
+ for (Iterator iter = servletResponseWrapper.getCookies()
+ .iterator(); iter.hasNext();) {
+ Cookie cookie = (Cookie) iter.next();
+ response.addCookie(cookie);
+ }
+ // Copy response headers
+ Map headers = servletResponseWrapper.getHeaders();
+ for (Iterator iter = headers.entrySet().iterator(); iter
+ .hasNext();) {
+ Map.Entry header = (Map.Entry) iter.next();
+ response.setHeader((String) header.getKey(),
+ (String) header.getValue());
+ }
+ response.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADER,
+ "redirect");
+ // Not caching AJAX request
+ response.setHeader("Cache-Control",
+ "no-cache, must-revalidate, max_age=0, no-store");
+ response.setHeader("Expires", "0");
+ response.setHeader("Pragma", "no-cache");
+ response.setContentType(getMimetype() + ";charset=UTF-8");
+ response.setHeader(AjaxContainerRenderer.AJAX_LOCATION_HEADER,
+ redirectLocation);
+ output = createResponseWriter(response, "UTF-8");
+ // For buggy XmlHttpRequest realisations repeat headers in
+ // <meta>
+ output.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
+ + "<meta name=\""
+ + AjaxContainerRenderer.AJAX_FLAG_HEADER
+ + "\" content=\"redirect\" />" + "<meta name=\""
+ + AjaxContainerRenderer.AJAX_LOCATION_HEADER
+ + "\" content=\"" + redirectLocation + "\" />"
+ + "</head></html>");
+ output.flush();
+ response.flushBuffer();
+ } else {
+ response.sendRedirect(redirectLocation);
+ }
+ return;
+ } else if ("true".equals(servletResponseWrapper.getHeaders().get(
+ AjaxContainerRenderer.AJAX_FLAG_HEADER))) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Process response to well-formed XML for AJAX XMLHttpRequest parser");
+ }
+ // Not caching AJAX request
+ response.setHeader("Cache-Control",
+ "no-cache, must-revalidate, max_age=0, no-store");
+ response.setHeader("Expires", "0");
+ response.setHeader("Pragma", "no-cache");
+ // response.setCharacterEncoding(servletResponseWrapper
+ // .getCharacterEncoding()); //
+ // JSContentHandler.DEFAULT_ENCODING);
+ // Set the content-type. For AJAX responses default encoding -
+ // UTF8.
+ // TODO - for null encoding, setup only Output encoding for
+ // filter ?
+ String outputEncoding = "UTF-8";
+ String contentType = getMimetype() + ";charset=" + outputEncoding;
+ response.setContentType(contentType);
+ parser = getParser(getMimetype(), true, viewId);
+ if (null == parser) {
+ throw new ServletException(Messages.getMessage(
+ Messages.PARSER_NOT_INSTANTIATED_ERROR, contentType));
+ }
+ output = createResponseWriter(response, outputEncoding);
+ parser.setDoctype(getPublicid());
+ parser.setInputEncoding(characterEncoding);
+ parser.setOutputEncoding(outputEncoding);
+ parser.setViewState((String) request
+ .getAttribute(AjaxViewHandler.SERIALIZED_STATE_KEY));
+ } else {
+ // setup conversion reules for output contentType, send directly
+ // if content not
+ // supported by tidy.
+ String contentType = servletResponseWrapper.getContentType();
+ if (log.isDebugEnabled()) {
+ log.debug("create HTML/XML parser for content type: "
+ + contentType);
+ }
+ // if(contentType == null){
+ // contentType = request.getContentType();
+ // }
+ if (contentType != null) {
+ if (contentType.indexOf("charset") < 0
+ && null != characterEncoding) {
+ contentType += ";charset=" + characterEncoding;
+ }
+ parser = getParser(contentType, false, viewId);
+ response.setContentType(contentType);
+ }
+ // null or unsupported content type
+ if (null == parser) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Parser not have support for the such content type, send response as-is");
+ }
+ try {
+ if (servletResponseWrapper.isUseWriter()) {
+ output = createResponseWriter(response,
+ characterEncoding);
+ servletResponseWrapper.sendContent(output);
+ } else if (servletResponseWrapper.isUseStream()) {
+ ServletOutputStream out = response.getOutputStream();
+ servletResponseWrapper.sendContent(out);
+ }
+ } finally {
+ // reuseWrapper(servletResponseWrapper);
+ }
+ return;
+ }
+ output = createResponseWriter(response, characterEncoding);
+
+ parser.setInputEncoding(characterEncoding);
+ parser.setOutputEncoding(characterEncoding);
+ }
+
+ try {
+ // Setup scripts and styles
+ parser.setScripts((Set) request
+ .getAttribute(AjaxContext.SCRIPTS_PARAMETER));
+ parser.setStyles((Set) request
+ .getAttribute(AjaxContext.STYLES_PARAMETER));
+ // Process parsing.
+ long startTimeMills = System.currentTimeMillis();
+ servletResponseWrapper.parseContent(output, parser);
+ if (log.isDebugEnabled()) {
+ startTimeMills = System.currentTimeMillis() - startTimeMills;
+ log.debug(Messages.getMessage(Messages.PARSING_TIME_INFO, ""
+ + startTimeMills));
+ }
+ } catch (Exception e) {
+ throw new ServletException(Messages
+ .getMessage(Messages.JTIDY_PARSING_ERROR), e);
+ } finally {
+ reuseParser(parser);
+ }
+ }
+
+ /**
+ * @param response
+ * @return
+ * @throws ServletException
+ */
+ protected FilterServletResponseWrapper getWrapper(
+ HttpServletResponse response) throws ServletException {
+ return new FilterServletResponseWrapper(response);
+ }
+
+ /**
+ * @param request
+ * @return
+ */
+ protected boolean isAjaxRequest(ServletRequest request) {
+ try {
+ return null != request
+ .getParameter(AjaxContainerRenderer.AJAX_PARAMETER_NAME);
+ } catch (Exception e) {
+ // OCJ 10 - throw exception for static resources.
+ return false;
+ }
+ }
+
+ /**
+ * @param response
+ * @param characterEncoding
+ * @return
+ * @throws IOException
+ * @throws UnsupportedEncodingException
+ */
+ private Writer createResponseWriter(final HttpServletResponse response,
+ String characterEncoding) throws IOException,
+ UnsupportedEncodingException {
+ Writer output;
+ try {
+ output = response.getWriter();
+ } catch (IllegalStateException e) {
+ if (null != characterEncoding) {
+ output = new OutputStreamWriter(response.getOutputStream(),
+ characterEncoding);
+ } else {
+ output = new OutputStreamWriter(response.getOutputStream());
+ }
+ }
+ return output;
+ }
+
+ protected abstract void reuseParser(HtmlParser parser);
+
+ protected abstract HtmlParser getParser(String mimetype, boolean isAjax,
+ String viewId);
+
+ /**
+ * @param publicid
+ * The publicid to set.
+ */
+ protected void setPublicid(String publicid) {
+ this.publicid = publicid;
+ }
+
+ /**
+ * @return Returns the publicid.
+ */
+ public String getPublicid() {
+ return publicid;
+ }
+
+ /**
+ * @param systemid
+ * The systemid to set.
+ */
+ protected void setSystemid(String systemid) {
+ this.systemid = systemid;
+ }
+
+ /**
+ * @return Returns the systemid.
+ */
+ public String getSystemid() {
+ return systemid;
+ }
+
+ /**
+ * @param namespace
+ * The namespace to set.
+ */
+ protected void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ /**
+ * @return Returns the namespace.
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * @param mimetype
+ * The mimetype to set.
+ */
+ protected void setMimetype(String mimetype) {
+ this.mimetype = mimetype;
+ }
+
+ /**
+ * @return Returns the mimetype.
+ */
+ protected String getMimetype() {
+ return mimetype;
+ }
+
+ /**
+ * @return Returns the forcexml.
+ */
+ public boolean isForcexml() {
+ return this.forcexml;
+ }
+
+ /**
+ * @param forcexml
+ * The forcexml to set.
+ */
+ protected void setForcexml(boolean forcexml) {
+ this.forcexml = forcexml;
+ }
+
+ private Object nz(Object param, Object def) {
+ return param != null ? param : def;
+ }
+
+}
Deleted: tags/3.1.0-rc5/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,1282 +0,0 @@
-// Global Variables
-// var timeout = null;
-
-// TODO - use sarissa for standard XMLHttpRequest Support.
-
-
-// AJAX-JSF AJAX-like library, for communicate with view Tree on server side.
-
-// Modified by Alexander J. Smirnov to use as JSF AJAX-like components.
-
-A4J.AJAX = {};
-
-/**
- * XMLHttp transport class - incapsulate most of client-specifiv functions for call server requests.
- */
-A4J.AJAX.XMLHttpRequest = function(query){
- this._query = query;
- };
-
-A4J.AJAX.XMLHttpRequest.prototype = {
- _query : null,
- _timeout : 0,
- _timeoutID : null,
- onready : null,
- _parsingStatus : Sarissa.PARSED_EMPTY,
- _errorMessage : "XML Response object not set",
- _contentType : null,
- _onerror : function(req,status,message) {
- // Status not 200 - error !
- // window.alert(message);
- A4J.AJAX.replacePage(req);
- },
- onfinish : null,
- options : {},
- domEvt : null,
- form : null,
- _request : null,
- _aborted : false,
-
- setRequestTimeout : function(timeout){
- this._timeout = timeout;
- },
- /**
- * Send request to server with parameters from query ( POST or GET depend on client type )
- */
- send : function(){
- this._request = new XMLHttpRequest();
- var _this = this;
- this._request.onreadystatechange = function(){
- if(_this._aborted){return;};
- LOG.debug("Reqest state : "+_this._request.readyState );
- if (_this._request.readyState == 4 ) {
- LOG.debug("Reqest end with state 4");
- if(_this._timeoutID){
- window.clearTimeout(_this._timeoutID);
- }
- var requestStatus;
- var requestStatusText;
- try{
- requestStatus = _this._request.status;
- requestStatusText = _this._request.statusText;
- } catch(e){
- LOG.error("request don't have status code - network problem");
- requestStatus = 501;
- requestStatusText = "Network error";
- }
- if(requestStatus == 200){
- try {
- LOG.debug("Response with content-type: "+ _this.getResponseHeader('Content-Type'));
- LOG.debug("Full response content: ", _this.getResponseText());
- } catch(e) {
- // IE Can throw exception for any responses
- }
- // Prepare XML, if exist.
- if(_this._request.responseXML ){
- _this._parsingStatus = Sarissa.getParseErrorText(_this._request.responseXML);
- if(_this._parsingStatus == Sarissa.PARSED_OK && Sarissa.setXpathNamespaces ){
- Sarissa.setXpathNamespaces(_this._request.responseXML,"xmlns='http://www.w3.org/1999/xhtml'");
- }
- }
- if(_this.onready){
- _this.onready(_this);
- }
- } else {
- _this._errorMessage = "Reqest error, status : "+requestStatus +" " + requestStatusText ;
- LOG.error(_this._errorMessage);
- if(typeof(_this._onerror) == "function"){
- _this._onerror(_this,requestStatus,_this._errorMessage);
- }
- }
- if(_this.onfinish){
- _this.onfinish(_this);
- }
- _this = undefined;
- }
- }; //this._onReady;
- try{
- LOG.debug("Start XmlHttpRequest");
- this._request.open('POST', this._query.getActionUrl("") , true);
- // Query use utf-8 encoding for prepare urlencode data, force request content-type and charset.
- var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
- this._request.setRequestHeader( "Content-Type", contentType);
- } catch(e){
- // Opera 7-8 - force get
- LOG.debug("XmlHttpRequest not support setRequestHeader - use GET instead of POST");
- this._request.open('GET', this._query.getActionUrl("")+"?"+this._query.getQueryString() , true);
- }
- // send data.
- this._request.send(this._query.getQueryString());
- if(this._timeout > 0){
- this._timeoutID = window.setTimeout(function(){
- LOG.warn("request stopped due to timeout");
- if(!_this._aborted){
- A4J.AJAX.status(_this.containerId,_this.options.status,false);
- if(typeof(A4J.AJAX.onAbort) == "function"){
- A4J.AJAX.onAbort(_this);
- }
- }
- _this._aborted=true;
- _this._request.abort();
- if(_this._onerror){
- _this._errorMessage = "Request timeout";
- _this._onerror(_this,500,_this._errorMessage);
- }
- if(_this.onfinish){
- _this.onfinish(_this);
- }
- _this._request=undefined;
- _this = undefined;
- },this._timeout);
- }
- },
-
- abort: function(){
- if(!this._aborted){
- A4J.AJAX.status(this.containerId,this.options.status,false);
- if(typeof(A4J.AJAX.onAbort) == "function"){
- A4J.AJAX.onAbort(this);
- }
- }
- this._aborted=true;
- if(this._request){
- try{
- this._request.abort();
- if(this._timeoutID){
- window.clearTimeout(this._timeoutID);
- }
- } catch (e){
- LOG.warn("Exception for abort current request "+e.Message);
- }
- }
- },
- getResponseText : function(){
- return this._request.responseText;
- },
- getError : function(){
- return this._errorMessage;
- },
- getParserStatus : function(){
- return this._parsingStatus;
- },
- getContentType : function(){
- if(!this._contentType){
- var contentType = this.getResponseHeader('Content-Type');
- if(contentType){
- var i = contentType.indexOf(';');
- if( i >= 0 ){
- this._contentType = contentType.substring(0,i);
- } else {
- this._contentType = contentType;
- }
- } else {
- this._contentType="text/html";
- }
- }
- return this._contentType;
- },
- getResponseHeader : function(name){
- var result;
- // Different behavior - for non-existing headers, Firefox throws exception,
- // IE return "" ,
- try{
- result = this._request.getResponseHeader(name);
- if(result === ""){
- result = undefined;
- }
- } catch(e) {
- }
- if(!result){
- // Header not exist or Opera <=8.0 error. Try to find <meta > tag with same name.
- LOG.debug("Header "+name+" not found, search in <meta>");
- if(this._parsingStatus == Sarissa.PARSED_OK){
- var metas = this.getElementsByTagName("meta");
- for(var i = 0; i < metas.length;i++){
- var meta = metas[i];
- LOG.debug("Find <meta name='"+meta.getAttribute('name')+"' content='"+meta.getAttribute('content')+"'>");
- if(meta.getAttribute("name") == name){
- result = meta.getAttribute("content");
- break;
- }
- }
- }
-
- }
- return result;
- },
- /**
- * get elements with elementname in responseXML or, if present - in element.
- */
- getElementsByTagName : function(elementname,element){
- if(!element){
- element = this._request.responseXML;
- }
- LOG.debug("search for elements by name '"+elementname+"' "+" in element "+element.nodeName);
- var elements;
- try
- {
- elements = element.selectNodes(".//*[local-name()=\""+
- elementname +"\"]");
- LOG.debug("selectNodes found "+elements.length);
- }
- catch (ex) {
- elements = element.getElementsByTagName(elementname);
- LOG.debug("getElementsByTagName found "+elements.length);
- }
-// return document.getElementsByTagName(tagName);
-// elements = element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml",elementname);
-// LOG.debug("getElementsByTagNameNS found "+elements.length);
- return elements;
- },
- /**
- * Find element in response by ID. Since in IE response not validated, use selectSingleNode instead.
- */
- getElementById : function(id){
- // first attempt - .getElementById.
- var oDoc = this._request.responseXML;
- if(typeof(oDoc.getElementById) != 'undefined') {
- LOG.debug("call getElementById for id= "+id);
- return oDoc.getElementById(id);
- }
- else if(typeof(oDoc.selectSingleNode) != "undefined") {
- LOG.debug("call selectSingleNode for id= "+id);
- return oDoc.selectSingleNode("//*[@id='"+id+"']"); /* XPATH istead of ID */
- }
- // nodeFromID not worked since XML validation disabled by
- // default for MS
- else if(typeof(oDoc.nodeFromID) != "undefined") {
- LOG.debug("call nodeFromID for id= "+id);
- return oDoc.nodeFromID(id);
- }
- LOG.error("No functions for getElementById found ");
- return null;
-
- },
-
- getJSON : function(id){
- var data;
- var dataElement = this.getElementById(id);
- if(dataElement){
- try {
- data = Sarissa.getText(dataElement,true);
- data = window.eval('('+data+')');
- } catch(e){
- LOG.error("Error on parsing JSON data "+e.message,data);
- }
- }
- return data;
- },
-
- evalScripts : function(node){
- var newscripts = this.getElementsByTagName("script",node);
- LOG.debug("Scripts in updated part count : " + newscripts.length);
- if( newscripts.length > 0 ){
- window.setTimeout(function() {
- for (var i = 0; i < newscripts.length; i++){
- var newscript = Sarissa.getText( newscripts[i],true ) ; // TODO - Mozilla disable innerHTML in XML page ..."";
- try {
- LOG.debug("Evaluate script replaced area in document: ", newscript);
- if (window.execScript) {
- window.execScript( newscript );
- } else {
- window.eval(newscript);
- }
- } catch(e){
- LOG.error("ERROR Evaluate script: Error name: " + e.name + e.message?". Error message: "+e.message:"");
- }
- }
- newscripts = null;
- },50);
- }
-
- },
- /**
- * Update DOM element with given ID by element with same ID in parsed responseXML
- */
- updatePagePart : function(id){
- var newnode = this.getElementById(id);
- if( ! newnode ) { LOG.error("New node for ID "+id+" is not present in response");return;}
- var oldnode = window.document.getElementById(id);
- if ( oldnode ) {
- var anchor = oldnode.parentNode;
- if(!window.opera && oldnode.outerHTML && !oldnode.tagName.match( /(tbody|thead|tfoot|tr|th|td)/i ) ){
- LOG.debug("Replace content of node by outerHTML()");
- try {
- oldnode.innerHTML = "";
- } catch(e){
- LOG.error("Error to clear node content by innerHTML");
- Sarissa.clearChildNodes(oldnode);
- }
- oldnode.outerHTML = new XMLSerializer().serializeToString(newnode);
- } else {
- var importednode ;
- // need to check for firstChild due to opera 8 bug with hasChildNodes
- Sarissa.clearChildNodes(oldnode);
- importednode = window.document.importNode(newnode, true);
- LOG.debug("Replace content of node by replaceChild()");
- anchor.replaceChild(importednode,oldnode);
- }
- // re-execute all script fragments in imported subtree...
- // TODO - opera 8 run scripts at replace content stage.
- if(!A4J.AJAX._scriptEvaluated){
- this.evalScripts(newnode);
- }
- LOG.debug("Update part of page for Id: "+id + " successful");
- } else {
- LOG.warn("Node for replace by response with id "+id+" not found in document");
- }
-
- },
-
- appendNewHeadElements : function(){
- // Append scripts and styles to head, if not presented in page before.
- this._appendNewElements("script","src",["type","language","charset"]);
- this._appendNewElements("link","href",["type","rel","rev","media"]);
- },
-
- _appendNewElements : function(tag,href,attributes){
- var newscripts = this.getElementsByTagName(tag);
- var oldscripts = document.getElementsByTagName(tag);
- var head = document.getElementsByTagName("head")[0]||document.documentElement;
- for(var i=0 ; i<newscripts.length;i++){
- var element = newscripts[i];
- var src = element.getAttribute(href);
- if(src){
- var exist = false;
- LOG.debug("<"+tag+"> in response with src="+src);
- for(var j = 0 ; j < oldscripts.length; j++){
- if(this._noSessionHref(src) == this._noSessionHref(oldscripts[j].getAttribute(href))){
- LOG.debug("Such element exist in document");
- exist = true;
- break;
- }
- }
- if(!exist){
- // var script = window.document.importNode(element,true); //
- var script = document.createElement(tag);
- script.setAttribute(href,src);
- for(var j = 0 ; j < attributes.length; j++){
- this._copyAttribute(element,script,attributes[j]);
- }
- LOG.debug("append element to document");
- head.appendChild(script);
- }
- }
- }
-
- },
-
- _noSessionHref : function(href){
- var cref = href;
- if(href){
- var sessionid = href.lastIndexOf(";jsessionid=");
- if(sessionid>0){
- cref = href.substring(0,sessionid);
- var params = href.lastIndexOf("?");
- if(params>sessionid){
- cref=cref+href.substring(params);
- }
- }
- }
- return cref;
- },
-
- _copyAttribute : function(src,dst,attr){
- var value = src.getAttribute(attr);
- if(value){
- dst.setAttribute(attr,value);
- }
- }
-
-};
-// eventsQueues for ajax submit events.
-A4J.AJAX._eventsQueues={};
-
-//Listeners should be notified
-A4J.AJAX.Listener = function(onafterajax){
- this.onafterajax = onafterajax;
-};
-
-A4J.AJAX._listeners= [];
-A4J.AJAX.AddListener = function(listener){
- A4J.AJAX._listeners.push(listener);
-};
-A4J.AJAX.removeListeners = function(listener){
- A4J.AJAX._listeners = [];
-};
-// pollers timerId's
-A4J.AJAX._pollers = {};
-/*
- *
- *
- */
-A4J.AJAX.Poll = function( containerId, form, options ) {
- A4J.AJAX.StopPoll(options.pollId);
- if(!options.onerror){
- options.onerror = function(req,status,message){
- if(typeof(A4J.AJAX.onError)== "function"){
- A4J.AJAX.onError(req,status,message);
- }
- // For error, re-submit request.
- A4J.AJAX.Poll(containerId,form,options);
- };
- }
- A4J.AJAX._pollers[options.pollId] = window.setTimeout(function(){
- A4J.AJAX._pollers[options.pollId]=undefined;
- if((typeof(options.onsubmit) == 'function') && (!options.onsubmit())){
- // Onsubmit disable current poll, start next interval.
- A4J.AJAX.Poll(containerId,form,options);
- } else {
- A4J.AJAX.SubmitRequest(containerId,form,null,options);
- }
- },options.pollinterval);
-};
-
-A4J.AJAX.StopPoll = function( Id ) {
- if(A4J.AJAX._pollers[Id]){
- window.clearTimeout(A4J.AJAX._pollers[Id]);
- A4J.AJAX._pollers[Id] = undefined;
- }
-};
-
-/*
- *
- *
- */
-A4J.AJAX.Push = function( containerId, form, options ) {
- A4J.AJAX.StopPush(options.pushId);
- options.onerror = function(){
- // For error, re-submit request.
- A4J.AJAX.Push(containerId,form,options);
- };
- A4J.AJAX._pollers[options.pushId] = window.setTimeout(function(){
- var request = new XMLHttpRequest();
- request.onreadystatechange = function(){
- if (request.readyState == 4 ) {
- try {
- if(request.status == 200){
-// A4J.AJAX._pollers[options.pushId]=undefined;
- A4J.AJAX.SubmitRequest(containerId,form||options.dummyForm,null,options);
- }
- } catch(e){
- // Network error.
- }
- // Re-send request.
- A4J.AJAX.Push( containerId, form, options );
- request=null;
-// A4J.AJAX._pollers[options.pushId] = window.setTimeout(function(){
-// A4J.AJAX.SendPush( request,options );
-// },options.pushinterval);
- }
- }
- A4J.AJAX.SendPush( request,options );
- },options.pushinterval);
-};
-
-A4J.AJAX.SendPush = function( request,options ) {
- var url = options.pushUrl || options.actionUrl;
- request.open('HEAD', url , true);
- request.setRequestHeader( "Ajax-Push-Key", options.pushId);
- if(options.timeout){
- request.setRequestHeader( "Timeout", options.timeout);
- }
- request.send();
-}
-
-A4J.AJAX.StopPush = function( Id ) {
- if(A4J.AJAX._pollers[Id]){
- window.clearTimeout(A4J.AJAX._pollers[Id]);
- A4J.AJAX._pollers[Id] = undefined;
- }
-};
-
-
-
-A4J.AJAX.CloneObject = function( obj, noFunctions ) {
- var cloned = {};
- for( var n in obj ){
- if(noFunctions && typeof(evt[prop]) == 'function'){
- continue;
- }
- cloned[n]=obj[n];
- }
- return cloned;
-}
-
-
-A4J.AJAX.SubmitForm = function( containerId, form, options ) {
- var opt = A4J.AJAX.CloneObject(options);
- // Setup active control if form submitted by button.
- if(A4J._formInput){
- LOG.debug("Form submitted by button "+A4J._formInput.id);
- opt.control = A4J._formInput;
- A4J._formInput = null;
- opt.submitByForm=true;
- }
- A4J.AJAX.Submit(containerId,form,null,opt);
-}
-
-// Submit or put in queue request. It not full queues - framework perform waiting only one request to same queue, new events simple replace last.
-// If request for same queue already performed, replace with current parameters.
-A4J.AJAX.Submit = function( containerId, form, evt , options ) {
- var domEvt;
- evt = evt || window.event || null;
- if(evt){
- // Create copy of event object, since most of properties undefined outside of event capture.
- try {
- domEvt = A4J.AJAX.CloneObject(evt,false);
- } catch(e){
- LOG.warn("Exception on clone event");
- }
- LOG.debug("Have Event "+domEvt+" with properties: target: "+domEvt.target+", srcElement: "+domEvt.srcElement+", type: "+domEvt.type);
- }
- if(options.eventsQueue){
- var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
- if( eventsQueue ) {
- var eventsCount = eventsQueue.options.eventsCount||1;
- eventsQueue.wait=true;
- eventsQueue.containerId=containerId;
- eventsQueue.form=form;
- eventsQueue.domEvt=domEvt;
- eventsQueue.options=options;
- eventsQueue.options.eventsCount = eventsCount+1;
- if(options.ignoreDupResponses && eventsQueue.request){
- LOG.debug("Abort uncompleted request in queue "+options.eventsQueue);
- eventsQueue.request.abort();
- eventsQueue.request=false;
- eventsQueue.wait=false;
- if( options.requestDelay ){
- window.setTimeout(function() {
- LOG.debug("End delay waiting, make request in queue "+options.eventsQueue);
- A4J.AJAX.SubmiteventsQueue(A4J.AJAX._eventsQueues[options.eventsQueue]);
- },options.requestDelay);
- LOG.debug("Create new waiting for request in queue "+options.eventsQueue);
- return;
- }
- } else {
- LOG.debug("Put new event to queue "+options.eventsQueue);
- return;
- }
- } else {
- var queue = { wait : false, containerId : containerId , form : form, domEvt : domEvt, options : options};
- A4J.AJAX._eventsQueues[options.eventsQueue] = queue;
- if( options.requestDelay ){
- window.setTimeout(function() {
- LOG.debug("End delay waiting, make request in queue "+options.eventsQueue);
- A4J.AJAX.SubmiteventsQueue(A4J.AJAX._eventsQueues[options.eventsQueue]);
- },options.requestDelay);
- LOG.debug("Event occurs, create waiting for request in queue "+options.eventsQueue);
- return;
- }
- }
- }
- A4J.AJAX.SubmitRequest( containerId, form, domEvt , options );
-};
-
-A4J.AJAX.SubmiteventsQueue = function( eventsQueue ) {
- // Clear wait flag to avoid resend same request.
- eventsQueue.wait=false;
- A4J.AJAX.SubmitRequest( eventsQueue.containerId, eventsQueue.form ,eventsQueue.domEvt , eventsQueue.options );
-};
- // Main request submitting functions.
- // parameters :
- // form - HtmlForm object for submit.
- // control - form element, called request, or, clientID for JSF view.
- // affected - Array of ID's for DOM Objects, updated after request. Override
- // list of updated areas in response.
- // statusID - DOM id request status tags.
- // oncomplete - function for call after complete request.
-A4J.AJAX.SubmitRequest = function( containerId, formId ,domEvt , options ) {
- // First - run onsubmit event for client-side validation.
- LOG.debug("NEW AJAX REQUEST !!! with form :"+formId );
-// var form = A4J.AJAX.locateForm(event);
- var form = window.document.getElementById(formId);
- if( (!form || form.nodeName.toUpperCase() != "FORM") && domEvt ) {
- var srcElement = domEvt.target||domEvt.srcElement||null;
- if(srcElement){
- form = A4J.AJAX.locateForm(srcElement);
- };
- };
- // TODO - test for null of form object
- if(!options.submitByForm && form && form.onsubmit) {
- LOG.debug("Form have onsubmit function, call it" );
- if( form.onsubmit() == false ){
- return false;
- };
- };
- var tosend = new A4J.Query(containerId, form);
- tosend.appendFormControls(options.single);
- if(options.control){
- tosend.appendControl(options.control,true);
- };
- if(options.parameters){
- tosend.appendParameters(options.parameters);
- };
- if(options.eventsCount){
- tosend.appendParameter("AJAX:EVENTS_COUNT",options.eventsCount);
- };
- if(options.actionUrl){
- tosend.setActionUrl(options.actionUrl);
- };
- // build xxxHttpRequest. by Sarissa / JSHttpRequest class always defined.
- var req = new A4J.AJAX.XMLHttpRequest(tosend);
-
- req.options = options;
- req.containerId = containerId;
- req.domEvt = domEvt;
- req.form = form;
- if(options.timeout){
- req.setRequestTimeout(options.timeout);
- };
-
- // Event handler for process response result.
- req.onready = A4J.AJAX.processResponse;
-
- if(options.onerror){
- req._onerror = options.onerror;
- } else if(typeof(A4J.AJAX.onError)== "function"){
- req._onerror = A4J.AJAX.onError;
- }
- req.onfinish = A4J.AJAX.finishRequest;
-
- A4J.AJAX.status(containerId,options.status,true);
- req.send();
- if(options.eventsQueue){
- var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
- if( eventsQueue ) {
- eventsQueue.request=req;
- }
- }
-
- return false;
- };
-
-
-
-A4J.AJAX.processResponse = function(req) {
- var options = req.options;
- var ajaxResponse = req.getResponseHeader('Ajax-Response');
- if( ajaxResponse != "true"){
- // NO Ajax header - new page.
- LOG.warn("No ajax response header ");
- var loc = req.getResponseHeader("Location");
- try{
- if(ajaxResponse == 'redirect' && loc){
- var expiredMsg = req.getResponseHeader('Ajax-Expired');
- if(expiredMsg){
- loc = A4J.AJAX.onExpired(loc,expiredMsg);
- if(!loc){
- return;
- }
- }
- window.location = loc;
- } else if(ajaxResponse == "reload"){
- window.location.reload(true);
- } else {
- A4J.AJAX.replacePage(req);
- }
- } catch(e){
- LOG.error("Error redirect to new location ");
- }
- } else {
- if(req.getParserStatus() == Sarissa.PARSED_OK){
-
- // perform beforeupdate if exists
- if(options.beforeupdate){
- LOG.debug( "Call request beforeupdate function before replacing elemements" );
- options.beforeupdate(req, req.domEvt, req.getJSON('_ajax:data'));
- }
-
- var idsFromResponse = req.getResponseHeader("Ajax-Update-Ids");
- // 3 strategy for replace :
- // if setted affected parameters - replace its
- if( options.affected ) {
- req.appendNewHeadElements();
- for ( var k =0; k < options.affected.length ; k++ ) {
- LOG.debug("Update page part from call parameter for ID " + options.affected[k]);
- req.updatePagePart(options.affected[k]);
- };
- // if resopnce contains element with ID "ajax:update" get id's from
- // child text element . like :
- // <div id="ajax:update" style="display none" >
- // <span>_id1:1234</span>
- // .........
- // </div>
- //
- } else if( idsFromResponse != "" ) {
- LOG.debug("Update page by list of rendered areas from response " + idsFromResponse );
- // Append scripts and styles to head, if not presented in page before.
- req.appendNewHeadElements();
- var childs = idsFromResponse.split(",");
- for ( var k=0 ; k < childs.length ; k++ ) {
- var id = childs[k];
- LOG.debug("Attempt to update part of page for Id: "+id);
- if ( id ) {req.updatePagePart(id);};
- };
- } else {
- // if none of above - error ?
- // A4J.AJAX.replace(form.id,A4J.AJAX.findElement(form.id,xmlDoc));
- LOG.warn("No information in response about elements to replace");
- }
- // Replace client-side hidden inputs for JSF View state.
- var idsSpan = req.getElementById("ajax-view-state");
- LOG.debug("Hidden JSF state fields: "+idsSpan);
- if(idsSpan != null){
- // For a portal case, replace content in the current window only.
- var namespace = options.parameters['org.ajax4jsf.portlet.NAMESPACE'];
- LOG.debug("Namespace for hidden view-state input fields is "+namespace);
- var anchor = namespace?window.document.getElementById(namespace):window.document;
- var inputs = anchor.getElementsByTagName("input");
- var newinputs = req.getElementsByTagName("input",idsSpan);
- A4J.AJAX.replaceViewState(inputs,newinputs);
- // For any cases, new state can be in uppercase element
- newinputs = req.getElementsByTagName("INPUT",idsSpan);
- A4J.AJAX.replaceViewState(inputs,newinputs);
- }
-
- // Process listeners.
- for(var li = 0; li < A4J.AJAX._listeners.length; li++){
- var listener = A4J.AJAX._listeners[li];
- if(listener.onafterajax){
- // Evaluate data as JSON String.
- var data = req.getJSON('_ajax:data');
- listener.onafterajax(req,req.domEvt,data);
- }
- }
- // Set focus, if nessesary.
- var focusId = req.getJSON("_A4J.AJAX.focus");
- if(focusId){
- LOG.debug("focus must be set to control "+focusId);
- var focusElement=false;
- if(req.form){
- // Attempt to get form control for name. By Richfaces naming convensions,
- // complex component must set clientId as DOM id for a root element ,
- // and as input element name.
- focusElement = req.form.elements[focusId];
- }
- if(!focusElement){
- // If not found as control element, search in DOM.
- LOG.debug("No control element "+focusId+" in submitted form");
- focusElement = document.getElementById(focusId);
- }
- if(focusElement){
- LOG.debug("Set focus to control ");
- focusElement.focus();
- } else {
- LOG.warn("Element for set focus not found");
- }
- } else {
- LOG.debug("No focus information in response");
- }
- } else {
- // No response XML
- LOG.error( "Error parsing XML" );
- LOG.error("Parse Error: " + req.getParserStatus());
- }
- }
- };
-
-A4J.AJAX.onExpired = function(loc,expiredMsg){
- if(window.confirm(expiredMsg)){
- return loc;
- } else {
- return undefined;
- }
-};
-
-A4J.AJAX.replacePage = function(req){
- LOG.debug("replace all page content with response");
- var isIE = _SARISSA_IS_IE;
- // maksimkaszynski
- //Prevent "Permission denied in IE7"
- //Reset calling principal
- var oldDocOpen = window.document.open;
- if (isIE) {
- LOG.debug("setup custom document.open method");
- window.document.open = function() {
- oldDocOpen.apply(this, arguments);
- }
- }
- // /maksimkaszynski
- window.setTimeout(function() {
- var isDocOpen=false;
- try {
- window.document.open(req.getContentType(),true);
- LOG.debug("window.document has opened for writing");
- isDocOpen=true;
- window.document.write(req.getResponseText());
- LOG.debug("window.document has been writed");
- window.document.close();
- LOG.debug("window.document has been closed for writing");
- if(isIE){
- // For Ie , scripts on page not activated.
- window.location.reload(false);
- }
- } catch(e) {
- LOG.debug("exception during write page content "+e.Message);
- if(isDocOpen){
- window.document.close();
- }
- // Firefox/Mozilla in XHTML case don't support document.write()
- // Use dom manipulation instead.
- var oDomDoc = (new DOMParser()).parseFromString(req.getResponseText(), "text/xml");
- if(Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
- LOG.debug("response has parsed as DOM documnet.");
-
- if (typeof Event != "undefined") {
- Event.unloadElementsCache();
- }
-
- Sarissa.clearChildNodes(window.document.documentElement);
- var docNodes = oDomDoc.documentElement.childNodes;
- for(var i = 0;i<docNodes.length;i++){
- if(docNodes[i].nodeType == 1){
- LOG.debug("append new node in document");
- var node = window.document.importNode(docNodes[i], true);
- window.document.documentElement.appendChild(node);
- }
- }
- } else {
- LOG.error("Error parsing response",Sarissa.getParseErrorText(oDomDoc));
- }
- // TODO - scripts reloading ?
- } finally {
- window.document.open = oldDocOpen;
- }
- LOG.debug("page content has been replaced");
- },30);
-}
-
-
-A4J.AJAX.replaceViewState = function(inputs,newinputs){
- LOG.debug("Replace value for inputs: "+inputs.length + " by new values: "+ newinputs.length);
- if( (newinputs.length > 0) && (inputs.length > 0) ){
- for(var i = 0 ; i < newinputs.length; i++){
- var newinput = newinputs[i];
- LOG.debug("Input in response: "+newinput.getAttribute("name"));
- for(var j = 0 ; j < inputs.length; j++){
- var input = inputs[j];
- if(input.name == newinput.getAttribute("name")){
- LOG.debug("Found same input on page with type: "+input.type);
- input.value = newinput.getAttribute("value");
- }
- }
- }
- }
-
-};
-/**
- *
- */
-A4J.AJAX.finishRequest = function(request){
- var options = request.options;
- // Remove unload prototype events for a removed elements.
- if ((typeof Event != "undefined") && (typeof Event.unloadElementsCache == "function")) {
- Event.unloadElementsCache();
- }
-
- // we can set listener for complete request - for example,
- // it can shedule next request for update page.
- var oncomplete = request.getElementById('org.ajax4jsf.oncomplete');
- if(oncomplete) {
- LOG.debug( "Call request oncomplete function after processing updates" );
- window.setTimeout(function(){
- var event = request.domEvt;
- var data = request.getJSON('_ajax:data');
- try {
- var newscript = Sarissa.getText(oncomplete,true);
- if (window.execScript) {
- window.execScript( newscript );
- } else {
- window.eval(newscript);
- }
- } catch(e){
- LOG.error('Error evaluate oncomplete function '+e.Message);
- }
-// mark status object ( if any ) for complete request ;
- A4J.AJAX.status(request.containerId,options.status,false);},
- 10);
- } else if(options.oncomplete){
- LOG.debug( "Call component oncomplete function after processing updates" );
- window.setTimeout(function(){
- options.oncomplete(request,request.domEvt,request.getJSON('_ajax:data'));
- // mark status object ( if any ) for complete request ;
- A4J.AJAX.status(request.containerId,options.status,false);},
- 10);
-
- } else {
- // mark status object ( if any ) for complete request ;
- A4J.AJAX.status(request.containerId,options.status,false);
- }
- // If we have events in queue - send next request.
- if(options.eventsQueue){
- var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
- if( eventsQueue ) {
- A4J.AJAX._eventsQueues[options.eventsQueue]=false;
- if(eventsQueue.wait){
- LOG.debug("Queue not empty, execute next request in queue "+options.eventsQueue);
- A4J.AJAX.SubmiteventsQueue(eventsQueue);
- }
- }
- }
- };
-
-A4J.AJAX.getCursorPos = function(inp){
-
- if(inp.selectionEnd != null)
- return inp.selectionEnd;
-
- // IE specific code
- var range = document.selection.createRange();
- var isCollapsed = range.compareEndPoints("StartToEnd", range) == 0;
- if (!isCollapsed)
- range.collapse(false);
- var b = range.getBookmark();
- return b.charCodeAt(2) - 2;
- }
-
- // Locate enclosing form for object.
-A4J.AJAX.locateForm = function(obj){
-
- var parent = obj;
- while(parent && parent.nodeName.toLowerCase() != 'form'){
- parent = parent.parentNode;
- };
- return parent;
-
- };
-
-A4J.AJAX.getElementById = function(id,options){
- var namespace = options['org.ajax4jsf.portlet.NAMESPACE'];
- var anchor = namespace?window.document.getElementById(namespace):window.document;
- var element;
- if(anchor){
- element = anchor.getElementById(id);
- } else {
- LOG.error("No root element for portlet namespace "+namespace+" on page");
- }
- return element;
-}
-
- // hash for requests count for all ID's
-A4J.AJAX._requestsCounts = {};
- // Change status object on start/stop request.
- // on start, document object with targetID+".start" make visible,
- // document object with targetID+".stop" make invisible.
- // on stop - inverse.
-A4J.AJAX.status = function(regionID,targetID,start){
- try {
- var elem;
- targetID = targetID || regionID +":status";
- A4J.AJAX._requestsCounts[targetID]=(A4J.AJAX._requestsCounts[targetID]||0)+(start?1:-1);
- if(A4J.AJAX._requestsCounts[targetID]>0){
- elem = document.getElementById(targetID+".stop");
- if(elem){elem.style.display="none";}
- elem = document.getElementById(targetID+".start");
- if(elem){
- elem.style.display="";
- if(typeof(elem.onstart) == 'function'){
- elem.onstart();
- }
- }
- }else{
- elem = document.getElementById(targetID+".start");
- if(elem){elem.style.display="none";}
- elem = document.getElementById(targetID+".stop");
- if(elem){
- elem.style.display="";
- if(typeof(elem.onstop) == 'function'){
- elem.onstop();
- }
- }
- }
- } catch(e){
- LOG.error("Exception on status change: ");
- }
-};
-
-
-
-
-// Class for build query string.
-A4J.Query = function(containerId,form){
- // For detect AJAX Request.
- this._query = {AJAXREQUEST : containerId};
- this._oldSubmit = null ;
- this._form = form ;
- this._actionUrl = ( this._form.action)?this._form.action:this._form;
- };
-
-A4J.Query.prototype = {
- _form : null,
- _actionUrl : null,
- _ext : "",
- _query : {},
- _oldSubmit : null,
- // init at loading time - script can change location at run time ? ...
- _pageBase : window.location.protocol+"//"+window.location.host,
- // hash for control elements query string functions
-
- hidden : function(control){
- this._value_query(control);
- // TODO - configurable mask for hidden command scripts.
- if( (control.name.length > 4) && (control.name.lastIndexOf("_idcl") == (control.name.length-5)) ){
- control.value="";
- // MYfaces version ...
- } else if( (control.name.length > 12) && (control.name.lastIndexOf("_link_hidden_") == (control.name.length-13)) ){
- control.value="";
- }
- },
-
- text : function(control){
- this._value_query(control);
- },
-
- textarea : function(control){
- this._value_query(control);
- },
-
- 'select-one' : function(control){
- // If none options selected, don't include parameter.
- if (control.selectedIndex != -1) {
- this._value_query(control);
- }
-// for( var i =0; i< control.childNodes.length; i++ ){
-// var child=control.childNodes[i];
-// if( child.selected ){
-// this._value_query(control);
-// break;
-// }
-// }
- },
-
- password : function(control){
- this._value_query(control);
- },
-
- file : function(control){
- this._value_query(control);
- },
-
- radio : function(control){
- this._check_query(control);
- },
-
- checkbox : function(control){
- this._check_query(control);
- },
-
-
- 'select-multiple' : function(control){
- var cname = control.name;
- var childs = control.childNodes;
- for( var i=0 ;i< childs.length;i++ ){
- var child=childs[i];
- if( child.tagName == 'OPTGROUP' ){
- var options = child.childNodes;
- for(var j=0; j < options.length; j++){
- this._addOption(cname, options[j]);
- }
- } else {
- this._addOption(cname, child);
- }
- }
- },
-
- _addOption : function(cname,option){
- if ( option.selected ){
- if( ! this._query[cname] ){
- this._query[cname]=[];
- }
- this._query[cname][this._query[cname].length]=option.value;
- }
-
- },
-// command inputs
-
- image : function( control, action ){
- if(action) this._value_query(control);
- },
- button : function( control, action ){
- if(action) this._value_query(control);
- },
-
- submit : function( control, action ){
- if(action) {
- this._value_query(control);
- }
- },
-
- // Anchor link pseudo-control.
- link : function(control, action ){
- if(action) {
- this._value_query(control);
- if(control.parameters){
- this.appendParameters(control.parameters);
- }
- }
- },
-
- // same as link, but have additional field - control, for input submit.
- input : function(control, action ){
- if(action) {
- this.link(control, action );
- // append original control.
- if( control.control ) {
- this.appendControl(control.control,action);
- }
- }
- },
-
- // Append one control to query.
- appendControl : function(control,action){
- if( this[control.type] ) {
- this[control.type](control,action);
- } else {
- this._appendById(control.id||control);
- }
-
- },
-
- // Append all non-hidden controls from form to query.
- appendFormControls : function(hiddenOnly){
- try {
- var elems = this._form.elements;
- if(elems){
- var k = 0;
- for ( k=0;k<elems.length;k++ ) {
- var element=elems[k];
- try {
- if( !hiddenOnly || element.type == "hidden") {
- this.appendControl(element,false) ;
- }
- } catch( ee ) {
- LOG.error("exception in building query ( append form control ) " + ee );
- }
- }
- }
- } catch(e) {
- LOG.warn("Error with append form controls to query "+e)
- }
- },
-
- // append map of parameters to query.
- appendParameters : function(parameters){
- for( k in parameters ){
- if(typeof Object.prototype[k] == 'undefined'){
- LOG.debug( "parameter " + k + " with value "+parameters[k]);
- this.appendParameter(k,parameters[k]);
- }
- }
- },
-
- setActionUrl : function(actionUrl){
- this._actionUrl = actionUrl;
- },
-// Return action URL ( append extention, if present )
- getActionUrl : function( ext ) {
- var actionUrl = this._actionUrl ;
- var ask = actionUrl.indexOf('?');
- // create absolute reference - for Firefox XMLHttpRequest base url can vary
- if( actionUrl.substring(0,1) == '/' ) {
- actionUrl = this._pageBase+actionUrl;
- }
- if ( ! ext ) ext = this._ext ;
- if( ask >=0 )
- {
- return actionUrl.substring(0,ask) + ext + actionUrl.substring(ask);
- }
- else return actionUrl + ext;
- },
-
-
-// Build query string for send to server.
- getQueryString : function() {
- var qs = "";
- var iname ;
- for ( var k in this._query ){
- if(typeof Object.prototype[k] == 'undefined'){
- iname = this._query[k];
- if( iname instanceof Object ){
- for ( var l=0; l< iname.length; l++ ) {
- qs += this._encode(k) + "=" + this._encode(iname[l]) + "&";
- }
- } else {
- qs += this._encode(k) + "=" + this._encode(iname) + "&";
- }
- }
- }
- LOG.debug("QueryString: "+qs);
- return qs;
- },
- // private methods
-
- _appendById : function( id ) {
- this.appendParameter(this._form.id + "_link_hidden_", id);
- // JSF-ri version ...
- // this._query[this._form.id + "_idcl"]=id;
- },
-
-
- _value_query : function(control){
- LOG.debug("Append "+control.type+" control "+control.name+" with value ["+control.value+"] and value attribute ["+control.getAttribute('value')+"]");
- if(null != control.value){
- this.appendParameter(control.name, control.value);
- }
- },
-
- _check_query : function(control){
- if( control.checked ) {
- this.appendParameter(control.name, control.value?control.value:"on");
- }
- },
-
- // Append parameter to query. if name exist, append to array of parameters
- appendParameter: function(cname,value){
- if( ! this._query[cname] ){
- this._query[cname]=value;
- return;
- } else if( !(this._query[cname] instanceof Object) ){
- this._query[cname] = [this._query[cname]];
- }
- this._query[cname][this._query[cname].length]=value;
- },
-
- // Encode data string for request string
- _encode : function(string) {
- try {
- return encodeURIComponent(string);
- } catch(e) {
- var str = escape(string);
- // escape don't encode +. but form replace ' ' in fields by '+'
- return str.split('+').join('%2B');
- }
- }
-
-
- }
-
-// Test for re-evaluate Scripts in updated part. Opera & Safari do it.
-A4J.AJAX._scriptEvaluated=false;
-if (!document.all || window.opera){
- setTimeout(function(){
- try{
- // Simulate same calls as on XmlHttp
- var oDomDoc = Sarissa.getDomDocument();
- var _span = document.createElement("span");
- document.documentElement.appendChild(_span);
- // If script evaluated with used replace method, variable will be set to true
- var xmlString = "<html xmlns='http://www.w3.org/1999/xhtml'><sc"+"ript>A4J.AJAX._scriptEvaluated=true;</scr"+"ipt></html>";
- oDomDoc = (new DOMParser()).parseFromString(xmlString, "text/xml");
- var _script=oDomDoc.getElementsByTagName("script")[0];
- if(_span.outerHTML){
- _span.outerHTML = new XMLSerializer().serializeToString(_script);
- } else {
- var importednode ;
- importednode = window.document.importNode(_script, true);
- document.documentElement.replaceChild(importednode,_span);
- }
-
- } catch(e){ /* Mozilla in XHTML mode not have innerHTML */ };
- },50);
-}
Copied: tags/3.1.0-rc5/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js (from rev 2788, trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js)
===================================================================
--- tags/3.1.0-rc5/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js (rev 0)
+++ tags/3.1.0-rc5/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,1281 @@
+// Global Variables
+// var timeout = null;
+
+// TODO - use sarissa for standard XMLHttpRequest Support.
+
+
+// AJAX-JSF AJAX-like library, for communicate with view Tree on server side.
+
+// Modified by Alexander J. Smirnov to use as JSF AJAX-like components.
+
+A4J.AJAX = {};
+
+/**
+ * XMLHttp transport class - incapsulate most of client-specifiv functions for call server requests.
+ */
+A4J.AJAX.XMLHttpRequest = function(query){
+ this._query = query;
+ };
+
+A4J.AJAX.XMLHttpRequest.prototype = {
+ _query : null,
+ _timeout : 0,
+ _timeoutID : null,
+ onready : null,
+ _parsingStatus : Sarissa.PARSED_EMPTY,
+ _errorMessage : "XML Response object not set",
+ _contentType : null,
+ _onerror : function(req,status,message) {
+ // Status not 200 - error !
+ // window.alert(message);
+ A4J.AJAX.replacePage(req);
+ },
+ onfinish : null,
+ options : {},
+ domEvt : null,
+ form : null,
+ _request : null,
+ _aborted : false,
+
+ setRequestTimeout : function(timeout){
+ this._timeout = timeout;
+ },
+ /**
+ * Send request to server with parameters from query ( POST or GET depend on client type )
+ */
+ send : function(){
+ this._request = new XMLHttpRequest();
+ var _this = this;
+ this._request.onreadystatechange = function(){
+ if(_this._aborted){return;};
+ LOG.debug("Reqest state : "+_this._request.readyState );
+ if (_this._request.readyState == 4 ) {
+ LOG.debug("Reqest end with state 4");
+ if(_this._timeoutID){
+ window.clearTimeout(_this._timeoutID);
+ }
+ var requestStatus;
+ var requestStatusText;
+ try{
+ requestStatus = _this._request.status;
+ requestStatusText = _this._request.statusText;
+ } catch(e){
+ LOG.error("request don't have status code - network problem");
+ requestStatus = 501;
+ requestStatusText = "Network error";
+ }
+ if(requestStatus == 200){
+ try {
+ LOG.debug("Response with content-type: "+ _this.getResponseHeader('Content-Type'));
+ LOG.debug("Full response content: ", _this.getResponseText());
+ } catch(e) {
+ // IE Can throw exception for any responses
+ }
+ // Prepare XML, if exist.
+ if(_this._request.responseXML ){
+ _this._parsingStatus = Sarissa.getParseErrorText(_this._request.responseXML);
+ if(_this._parsingStatus == Sarissa.PARSED_OK && Sarissa.setXpathNamespaces ){
+ Sarissa.setXpathNamespaces(_this._request.responseXML,"xmlns='http://www.w3.org/1999/xhtml'");
+ }
+ }
+ if(_this.onready){
+ _this.onready(_this);
+ }
+ } else {
+ _this._errorMessage = "Reqest error, status : "+requestStatus +" " + requestStatusText ;
+ LOG.error(_this._errorMessage);
+ if(typeof(_this._onerror) == "function"){
+ _this._onerror(_this,requestStatus,_this._errorMessage);
+ }
+ }
+ if(_this.onfinish){
+ _this.onfinish(_this);
+ }
+ _this = undefined;
+ }
+ }; //this._onReady;
+ try{
+ LOG.debug("Start XmlHttpRequest");
+ this._request.open('POST', this._query.getActionUrl("") , true);
+ // Query use utf-8 encoding for prepare urlencode data, force request content-type and charset.
+ var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
+ this._request.setRequestHeader( "Content-Type", contentType);
+ } catch(e){
+ // Opera 7-8 - force get
+ LOG.debug("XmlHttpRequest not support setRequestHeader - use GET instead of POST");
+ this._request.open('GET', this._query.getActionUrl("")+"?"+this._query.getQueryString() , true);
+ }
+ // send data.
+ this._request.send(this._query.getQueryString());
+ if(this._timeout > 0){
+ this._timeoutID = window.setTimeout(function(){
+ LOG.warn("request stopped due to timeout");
+ if(!_this._aborted){
+ A4J.AJAX.status(_this.containerId,_this.options.status,false);
+ if(typeof(A4J.AJAX.onAbort) == "function"){
+ A4J.AJAX.onAbort(_this);
+ }
+ }
+ _this._aborted=true;
+ _this._request.abort();
+ if(_this._onerror){
+ _this._errorMessage = "Request timeout";
+ _this._onerror(_this,500,_this._errorMessage);
+ }
+ if(_this.onfinish){
+ _this.onfinish(_this);
+ }
+ _this._request=undefined;
+ _this = undefined;
+ },this._timeout);
+ }
+ },
+
+ abort: function(){
+ if(!this._aborted){
+ A4J.AJAX.status(this.containerId,this.options.status,false);
+ if(typeof(A4J.AJAX.onAbort) == "function"){
+ A4J.AJAX.onAbort(this);
+ }
+ }
+ this._aborted=true;
+ if(this._request){
+ try{
+// this._request.abort();
+ if(this._timeoutID){
+ window.clearTimeout(this._timeoutID);
+ }
+ } catch (e){
+ LOG.warn("Exception for abort current request "+e.Message);
+ }
+ }
+ },
+ getResponseText : function(){
+ return this._request.responseText;
+ },
+ getError : function(){
+ return this._errorMessage;
+ },
+ getParserStatus : function(){
+ return this._parsingStatus;
+ },
+ getContentType : function(){
+ if(!this._contentType){
+ var contentType = this.getResponseHeader('Content-Type');
+ if(contentType){
+ var i = contentType.indexOf(';');
+ if( i >= 0 ){
+ this._contentType = contentType.substring(0,i);
+ } else {
+ this._contentType = contentType;
+ }
+ } else {
+ this._contentType="text/html";
+ }
+ }
+ return this._contentType;
+ },
+ getResponseHeader : function(name){
+ var result;
+ // Different behavior - for non-existing headers, Firefox throws exception,
+ // IE return "" ,
+ try{
+ result = this._request.getResponseHeader(name);
+ if(result === ""){
+ result = undefined;
+ }
+ } catch(e) {
+ }
+ if(!result){
+ // Header not exist or Opera <=8.0 error. Try to find <meta > tag with same name.
+ LOG.debug("Header "+name+" not found, search in <meta>");
+ if(this._parsingStatus == Sarissa.PARSED_OK){
+ var metas = this.getElementsByTagName("meta");
+ for(var i = 0; i < metas.length;i++){
+ var meta = metas[i];
+ LOG.debug("Find <meta name='"+meta.getAttribute('name')+"' content='"+meta.getAttribute('content')+"'>");
+ if(meta.getAttribute("name") == name){
+ result = meta.getAttribute("content");
+ break;
+ }
+ }
+ }
+
+ }
+ return result;
+ },
+ /**
+ * get elements with elementname in responseXML or, if present - in element.
+ */
+ getElementsByTagName : function(elementname,element){
+ if(!element){
+ element = this._request.responseXML;
+ }
+ LOG.debug("search for elements by name '"+elementname+"' "+" in element "+element.nodeName);
+ var elements;
+ try
+ {
+ elements = element.selectNodes(".//*[local-name()=\""+
+ elementname +"\"]");
+ LOG.debug("selectNodes found "+elements.length);
+ }
+ catch (ex) {
+ elements = element.getElementsByTagName(elementname);
+ LOG.debug("getElementsByTagName found "+elements.length);
+ }
+// return document.getElementsByTagName(tagName);
+// elements = element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml",elementname);
+// LOG.debug("getElementsByTagNameNS found "+elements.length);
+ return elements;
+ },
+ /**
+ * Find element in response by ID. Since in IE response not validated, use selectSingleNode instead.
+ */
+ getElementById : function(id){
+ // first attempt - .getElementById.
+ var oDoc = this._request.responseXML;
+ if(oDoc){
+ if(typeof(oDoc.getElementById) != 'undefined') {
+ LOG.debug("call getElementById for id= "+id);
+ return oDoc.getElementById(id);
+ }
+ else if(typeof(oDoc.selectSingleNode) != "undefined") {
+ LOG.debug("call selectSingleNode for id= "+id);
+ return oDoc.selectSingleNode("//*[@id='"+id+"']"); /* XPATH istead of ID */
+ }
+ // nodeFromID not worked since XML validation disabled by
+ // default for MS
+ else if(typeof(oDoc.nodeFromID) != "undefined") {
+ LOG.debug("call nodeFromID for id= "+id);
+ return oDoc.nodeFromID(id);
+ }
+ LOG.error("No functions for getElementById found ");
+ } else {
+ LOG.debug("No parsed XML document in response");
+ }
+ return null;
+
+ },
+
+ getJSON : function(id){
+ var data;
+ var dataElement = this.getElementById(id);
+ if(dataElement){
+ try {
+ data = Sarissa.getText(dataElement,true);
+ data = window.eval('('+data+')');
+ } catch(e){
+ LOG.error("Error on parsing JSON data "+e.message,data);
+ }
+ }
+ return data;
+ },
+
+ evalScripts : function(node){
+ var newscripts = this.getElementsByTagName("script",node);
+ LOG.debug("Scripts in updated part count : " + newscripts.length);
+ if( newscripts.length > 0 ){
+ window.setTimeout(function() {
+ for (var i = 0; i < newscripts.length; i++){
+ var newscript = Sarissa.getText( newscripts[i],true ) ; // TODO - Mozilla disable innerHTML in XML page ..."";
+ try {
+ LOG.debug("Evaluate script replaced area in document: ", newscript);
+ if (window.execScript) {
+ window.execScript( newscript );
+ } else {
+ window.eval(newscript);
+ }
+ } catch(e){
+ LOG.error("ERROR Evaluate script: Error name: " + e.name + e.message?". Error message: "+e.message:"");
+ }
+ }
+ newscripts = null;
+ },50);
+ }
+
+ },
+ /**
+ * Update DOM element with given ID by element with same ID in parsed responseXML
+ */
+ updatePagePart : function(id){
+ var newnode = this.getElementById(id);
+ if( ! newnode ) { LOG.error("New node for ID "+id+" is not present in response");return;}
+ var oldnode = window.document.getElementById(id);
+ if ( oldnode ) {
+ var anchor = oldnode.parentNode;
+ if(!window.opera && oldnode.outerHTML && !oldnode.tagName.match( /(tbody|thead|tfoot|tr|th|td)/i ) ){
+ LOG.debug("Replace content of node by outerHTML()");
+ try {
+ oldnode.innerHTML = "";
+ } catch(e){
+ LOG.error("Error to clear node content by innerHTML");
+ Sarissa.clearChildNodes(oldnode);
+ }
+ oldnode.outerHTML = new XMLSerializer().serializeToString(newnode);
+ } else {
+ var importednode ;
+ // need to check for firstChild due to opera 8 bug with hasChildNodes
+ Sarissa.clearChildNodes(oldnode);
+ importednode = window.document.importNode(newnode, true);
+ LOG.debug("Replace content of node by replaceChild()");
+ anchor.replaceChild(importednode,oldnode);
+ }
+ // re-execute all script fragments in imported subtree...
+ // TODO - opera 8 run scripts at replace content stage.
+ if(!A4J.AJAX._scriptEvaluated){
+ this.evalScripts(newnode);
+ }
+ LOG.debug("Update part of page for Id: "+id + " successful");
+ } else {
+ LOG.warn("Node for replace by response with id "+id+" not found in document");
+ }
+
+ },
+
+ appendNewHeadElements : function(){
+ // Append scripts and styles to head, if not presented in page before.
+ this._appendNewElements("script","src",["type","language","charset"]);
+ this._appendNewElements("link","href",["type","rel","rev","media"]);
+ },
+
+ _appendNewElements : function(tag,href,attributes){
+ var newscripts = this.getElementsByTagName(tag);
+ var oldscripts = document.getElementsByTagName(tag);
+ var head = document.getElementsByTagName("head")[0]||document.documentElement;
+ for(var i=0 ; i<newscripts.length;i++){
+ var element = newscripts[i];
+ var src = element.getAttribute(href);
+ if(src){
+ var exist = false;
+ LOG.debug("<"+tag+"> in response with src="+src);
+ for(var j = 0 ; j < oldscripts.length; j++){
+ if(this._noSessionHref(src) == this._noSessionHref(oldscripts[j].getAttribute(href))){
+ LOG.debug("Such element exist in document");
+ exist = true;
+ break;
+ }
+ }
+ if(!exist){
+ // var script = window.document.importNode(element,true); //
+ var script = document.createElement(tag);
+ script.setAttribute(href,src);
+ for(var j = 0 ; j < attributes.length; j++){
+ this._copyAttribute(element,script,attributes[j]);
+ }
+ LOG.debug("append element to document");
+ head.appendChild(script);
+ }
+ }
+ }
+
+ },
+
+ _noSessionHref : function(href){
+ var cref = href;
+ if(href){
+ var sessionid = href.lastIndexOf(";jsessionid=");
+ if(sessionid>0){
+ cref = href.substring(0,sessionid);
+ var params = href.lastIndexOf("?");
+ if(params>sessionid){
+ cref=cref+href.substring(params);
+ }
+ }
+ }
+ return cref;
+ },
+
+ _copyAttribute : function(src,dst,attr){
+ var value = src.getAttribute(attr);
+ if(value){
+ dst.setAttribute(attr,value);
+ }
+ }
+
+};
+// eventsQueues for ajax submit events.
+A4J.AJAX._eventsQueues={};
+
+//Listeners should be notified
+A4J.AJAX.Listener = function(onafterajax){
+ this.onafterajax = onafterajax;
+};
+
+A4J.AJAX._listeners= [];
+A4J.AJAX.AddListener = function(listener){
+ A4J.AJAX._listeners.push(listener);
+};
+A4J.AJAX.removeListeners = function(listener){
+ A4J.AJAX._listeners = [];
+};
+// pollers timerId's
+A4J.AJAX._pollers = {};
+/*
+ *
+ *
+ */
+A4J.AJAX.Poll = function( containerId, form, options ) {
+ A4J.AJAX.StopPoll(options.pollId);
+ if(!options.onerror){
+ options.onerror = function(req,status,message){
+ if(typeof(A4J.AJAX.onError)== "function"){
+ A4J.AJAX.onError(req,status,message);
+ }
+ // For error, re-submit request.
+ A4J.AJAX.Poll(containerId,form,options);
+ };
+ }
+ A4J.AJAX._pollers[options.pollId] = window.setTimeout(function(){
+ A4J.AJAX._pollers[options.pollId]=undefined;
+ if((typeof(options.onsubmit) == 'function') && (!options.onsubmit())){
+ // Onsubmit disable current poll, start next interval.
+ A4J.AJAX.Poll(containerId,form,options);
+ } else {
+ A4J.AJAX.SubmitRequest(containerId,form,null,options);
+ }
+ },options.pollinterval);
+};
+
+A4J.AJAX.StopPoll = function( Id ) {
+ if(A4J.AJAX._pollers[Id]){
+ window.clearTimeout(A4J.AJAX._pollers[Id]);
+ A4J.AJAX._pollers[Id] = undefined;
+ }
+};
+
+/*
+ *
+ *
+ */
+A4J.AJAX.Push = function( containerId, form, options ) {
+ A4J.AJAX.StopPush(options.pushId);
+ options.onerror = function(){
+ // For error, re-submit request.
+ A4J.AJAX.Push(containerId,form,options);
+ };
+ A4J.AJAX._pollers[options.pushId] = window.setTimeout(function(){
+ var request = new XMLHttpRequest();
+ request.onreadystatechange = function(){
+ if (request.readyState == 4 ) {
+ try {
+ if(request.status == 200){
+// A4J.AJAX._pollers[options.pushId]=undefined;
+ A4J.AJAX.SubmitRequest(containerId,form||options.dummyForm,null,options);
+ }
+ } catch(e){
+ // Network error.
+ }
+ // Re-send request.
+ A4J.AJAX.Push( containerId, form, options );
+ request=null;
+// A4J.AJAX._pollers[options.pushId] = window.setTimeout(function(){
+// A4J.AJAX.SendPush( request,options );
+// },options.pushinterval);
+ }
+ }
+ A4J.AJAX.SendPush( request,options );
+ },options.pushinterval);
+};
+
+A4J.AJAX.SendPush = function( request,options ) {
+ var url = options.pushUrl || options.actionUrl;
+ request.open('HEAD', url , true);
+ request.setRequestHeader( "Ajax-Push-Key", options.pushId);
+ if(options.timeout){
+ request.setRequestHeader( "Timeout", options.timeout);
+ }
+ request.send();
+}
+
+A4J.AJAX.StopPush = function( Id ) {
+ if(A4J.AJAX._pollers[Id]){
+ window.clearTimeout(A4J.AJAX._pollers[Id]);
+ A4J.AJAX._pollers[Id] = undefined;
+ }
+};
+
+
+
+A4J.AJAX.CloneObject = function( obj, noFunctions ) {
+ var cloned = {};
+ for( var n in obj ){
+ if(noFunctions && typeof(evt[prop]) == 'function'){
+ continue;
+ }
+ cloned[n]=obj[n];
+ }
+ return cloned;
+}
+
+
+A4J.AJAX.SubmitForm = function( containerId, form, options ) {
+ var opt = A4J.AJAX.CloneObject(options);
+ // Setup active control if form submitted by button.
+ if(A4J._formInput){
+ LOG.debug("Form submitted by button "+A4J._formInput.id);
+ opt.control = A4J._formInput;
+ A4J._formInput = null;
+ opt.submitByForm=true;
+ }
+ A4J.AJAX.Submit(containerId,form,null,opt);
+}
+
+// Submit or put in queue request. It not full queues - framework perform waiting only one request to same queue, new events simple replace last.
+// If request for same queue already performed, replace with current parameters.
+A4J.AJAX.Submit = function( containerId, form, evt , options ) {
+ var domEvt;
+ evt = evt || window.event || null;
+ if(evt){
+ // Create copy of event object, since most of properties undefined outside of event capture.
+ try {
+ domEvt = A4J.AJAX.CloneObject(evt,false);
+ } catch(e){
+ LOG.warn("Exception on clone event");
+ }
+ LOG.debug("Have Event "+domEvt+" with properties: target: "+domEvt.target+", srcElement: "+domEvt.srcElement+", type: "+domEvt.type);
+ }
+ if(options.eventsQueue){
+ var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
+ if( eventsQueue ) {
+ var eventsCount = eventsQueue.options.eventsCount||1;
+ eventsQueue.wait=true;
+ eventsQueue.containerId=containerId;
+ eventsQueue.form=form;
+ eventsQueue.domEvt=domEvt;
+ eventsQueue.options=options;
+ eventsQueue.options.eventsCount = eventsCount+1;
+ if(options.ignoreDupResponses && eventsQueue.request){
+ LOG.debug("Abort uncompleted request in queue "+options.eventsQueue);
+ eventsQueue.request.abort();
+ eventsQueue.request=false;
+ eventsQueue.wait=false;
+ if( options.requestDelay ){
+ window.setTimeout(function() {
+ LOG.debug("End delay waiting, make request in queue "+options.eventsQueue);
+ A4J.AJAX.SubmiteventsQueue(A4J.AJAX._eventsQueues[options.eventsQueue]);
+ },options.requestDelay);
+ LOG.debug("Create new waiting for request in queue "+options.eventsQueue);
+ return;
+ }
+ } else {
+ LOG.debug("Put new event to queue "+options.eventsQueue);
+ return;
+ }
+ } else {
+ var queue = { wait : false, containerId : containerId , form : form, domEvt : domEvt, options : options};
+ A4J.AJAX._eventsQueues[options.eventsQueue] = queue;
+ if( options.requestDelay ){
+ window.setTimeout(function() {
+ LOG.debug("End delay waiting, make request in queue "+options.eventsQueue);
+ A4J.AJAX.SubmiteventsQueue(A4J.AJAX._eventsQueues[options.eventsQueue]);
+ },options.requestDelay);
+ LOG.debug("Event occurs, create waiting for request in queue "+options.eventsQueue);
+ return;
+ }
+ }
+ }
+ A4J.AJAX.SubmitRequest( containerId, form, domEvt , options );
+};
+
+A4J.AJAX.SubmiteventsQueue = function( eventsQueue ) {
+ // Clear wait flag to avoid resend same request.
+ eventsQueue.wait=false;
+ A4J.AJAX.SubmitRequest( eventsQueue.containerId, eventsQueue.form ,eventsQueue.domEvt , eventsQueue.options );
+};
+ // Main request submitting functions.
+ // parameters :
+ // form - HtmlForm object for submit.
+ // control - form element, called request, or, clientID for JSF view.
+ // affected - Array of ID's for DOM Objects, updated after request. Override
+ // list of updated areas in response.
+ // statusID - DOM id request status tags.
+ // oncomplete - function for call after complete request.
+A4J.AJAX.SubmitRequest = function( containerId, formId ,domEvt , options ) {
+ // First - run onsubmit event for client-side validation.
+ LOG.debug("NEW AJAX REQUEST !!! with form :"+formId );
+// var form = A4J.AJAX.locateForm(event);
+ var form = window.document.getElementById(formId);
+ if( (!form || form.nodeName.toUpperCase() != "FORM") && domEvt ) {
+ var srcElement = domEvt.target||domEvt.srcElement||null;
+ if(srcElement){
+ form = A4J.AJAX.locateForm(srcElement);
+ };
+ };
+ // TODO - test for null of form object
+ if(!options.submitByForm && form && form.onsubmit) {
+ LOG.debug("Form have onsubmit function, call it" );
+ if( form.onsubmit() == false ){
+ return false;
+ };
+ };
+ var tosend = new A4J.Query(containerId, form);
+ tosend.appendFormControls(options.single);
+ if(options.control){
+ tosend.appendControl(options.control,true);
+ };
+ if(options.parameters){
+ tosend.appendParameters(options.parameters);
+ };
+ if(options.eventsCount){
+ tosend.appendParameter("AJAX:EVENTS_COUNT",options.eventsCount);
+ };
+ if(options.actionUrl){
+ tosend.setActionUrl(options.actionUrl);
+ };
+ // build xxxHttpRequest. by Sarissa / JSHttpRequest class always defined.
+ var req = new A4J.AJAX.XMLHttpRequest(tosend);
+
+ req.options = options;
+ req.containerId = containerId;
+ req.domEvt = domEvt;
+ req.form = form;
+ if(options.timeout){
+ req.setRequestTimeout(options.timeout);
+ };
+
+ // Event handler for process response result.
+ req.onready = A4J.AJAX.processResponse;
+
+ if(options.onerror){
+ req._onerror = options.onerror;
+ } else if(typeof(A4J.AJAX.onError)== "function"){
+ req._onerror = A4J.AJAX.onError;
+ }
+ req.onfinish = A4J.AJAX.finishRequest;
+
+ A4J.AJAX.status(containerId,options.status,true);
+ req.send();
+ if(options.eventsQueue){
+ var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
+ if( eventsQueue ) {
+ eventsQueue.request=req;
+ }
+ }
+
+ return false;
+ };
+
+
+
+A4J.AJAX.processResponse = function(req) {
+ var options = req.options;
+ var ajaxResponse = req.getResponseHeader('Ajax-Response');
+ // If view is expired, check user-defined handler.
+ var expiredMsg = req.getResponseHeader('Ajax-Expired');
+ if(expiredMsg && typeof(A4J.AJAX.onExpired) == 'function' ){
+ var loc = A4J.AJAX.onExpired(window.location,expiredMsg);
+ if(loc){
+ window.location = loc;
+ return;
+ }
+ }
+ if( ajaxResponse != "true"){
+ // NO Ajax header - new page.
+ LOG.warn("No ajax response header ");
+ var loc = req.getResponseHeader("Location");
+ try{
+ if(ajaxResponse == 'redirect' && loc){
+ window.location = loc;
+ } else if(ajaxResponse == "reload"){
+ window.location.reload(true);
+ } else {
+ A4J.AJAX.replacePage(req);
+ }
+ } catch(e){
+ LOG.error("Error redirect to new location ");
+ }
+ } else {
+ if(req.getParserStatus() == Sarissa.PARSED_OK){
+
+ // perform beforeupdate if exists
+ if(options.beforeupdate){
+ LOG.debug( "Call request beforeupdate function before replacing elemements" );
+ options.beforeupdate(req, req.domEvt, req.getJSON('_ajax:data'));
+ }
+
+ var idsFromResponse = req.getResponseHeader("Ajax-Update-Ids");
+ // 3 strategy for replace :
+ // if setted affected parameters - replace its
+ if( options.affected ) {
+ req.appendNewHeadElements();
+ for ( var k =0; k < options.affected.length ; k++ ) {
+ LOG.debug("Update page part from call parameter for ID " + options.affected[k]);
+ req.updatePagePart(options.affected[k]);
+ };
+ // if resopnce contains element with ID "ajax:update" get id's from
+ // child text element . like :
+ // <div id="ajax:update" style="display none" >
+ // <span>_id1:1234</span>
+ // .........
+ // </div>
+ //
+ } else if( idsFromResponse != "" ) {
+ LOG.debug("Update page by list of rendered areas from response " + idsFromResponse );
+ // Append scripts and styles to head, if not presented in page before.
+ req.appendNewHeadElements();
+ var childs = idsFromResponse.split(",");
+ for ( var k=0 ; k < childs.length ; k++ ) {
+ var id = childs[k];
+ LOG.debug("Attempt to update part of page for Id: "+id);
+ if ( id ) {req.updatePagePart(id);};
+ };
+ } else {
+ // if none of above - error ?
+ // A4J.AJAX.replace(form.id,A4J.AJAX.findElement(form.id,xmlDoc));
+ LOG.warn("No information in response about elements to replace");
+ }
+ // Replace client-side hidden inputs for JSF View state.
+ var idsSpan = req.getElementById("ajax-view-state");
+ LOG.debug("Hidden JSF state fields: "+idsSpan);
+ if(idsSpan != null){
+ // For a portal case, replace content in the current window only.
+ var namespace = options.parameters['org.ajax4jsf.portlet.NAMESPACE'];
+ LOG.debug("Namespace for hidden view-state input fields is "+namespace);
+ var anchor = namespace?window.document.getElementById(namespace):window.document;
+ var inputs = anchor.getElementsByTagName("input");
+ var newinputs = req.getElementsByTagName("input",idsSpan);
+ A4J.AJAX.replaceViewState(inputs,newinputs);
+ // For any cases, new state can be in uppercase element
+ newinputs = req.getElementsByTagName("INPUT",idsSpan);
+ A4J.AJAX.replaceViewState(inputs,newinputs);
+ }
+
+ // Process listeners.
+ for(var li = 0; li < A4J.AJAX._listeners.length; li++){
+ var listener = A4J.AJAX._listeners[li];
+ if(listener.onafterajax){
+ // Evaluate data as JSON String.
+ var data = req.getJSON('_ajax:data');
+ listener.onafterajax(req,req.domEvt,data);
+ }
+ }
+ // Set focus, if nessesary.
+ var focusId = req.getJSON("_A4J.AJAX.focus");
+ if(focusId){
+ LOG.debug("focus must be set to control "+focusId);
+ var focusElement=false;
+ if(req.form){
+ // Attempt to get form control for name. By Richfaces naming convensions,
+ // complex component must set clientId as DOM id for a root element ,
+ // and as input element name.
+ focusElement = req.form.elements[focusId];
+ }
+ if(!focusElement){
+ // If not found as control element, search in DOM.
+ LOG.debug("No control element "+focusId+" in submitted form");
+ focusElement = document.getElementById(focusId);
+ }
+ if(focusElement){
+ LOG.debug("Set focus to control ");
+ focusElement.focus();
+ } else {
+ LOG.warn("Element for set focus not found");
+ }
+ } else {
+ LOG.debug("No focus information in response");
+ }
+ } else {
+ // No response XML
+ LOG.error( "Error parsing XML" );
+ LOG.error("Parse Error: " + req.getParserStatus());
+ }
+ }
+ };
+
+
+A4J.AJAX.replacePage = function(req){
+ LOG.debug("replace all page content with response");
+ var isIE = _SARISSA_IS_IE;
+ // maksimkaszynski
+ //Prevent "Permission denied in IE7"
+ //Reset calling principal
+ var oldDocOpen = window.document.open;
+ if (isIE) {
+ LOG.debug("setup custom document.open method");
+ window.document.open = function() {
+ oldDocOpen.apply(this, arguments);
+ }
+ }
+ // /maksimkaszynski
+ window.setTimeout(function() {
+ var isDocOpen=false;
+ try {
+ window.document.open(req.getContentType(),true);
+ LOG.debug("window.document has opened for writing");
+ isDocOpen=true;
+ window.document.write(req.getResponseText());
+ LOG.debug("window.document has been writed");
+ window.document.close();
+ LOG.debug("window.document has been closed for writing");
+ if(isIE){
+ // For Ie , scripts on page not activated.
+ window.location.reload(false);
+ }
+ } catch(e) {
+ LOG.debug("exception during write page content "+e.Message);
+ if(isDocOpen){
+ window.document.close();
+ }
+ // Firefox/Mozilla in XHTML case don't support document.write()
+ // Use dom manipulation instead.
+ var oDomDoc = (new DOMParser()).parseFromString(req.getResponseText(), "text/xml");
+ if(Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
+ LOG.debug("response has parsed as DOM documnet.");
+
+ if (typeof Event != "undefined") {
+ Event.unloadElementsCache();
+ }
+
+ Sarissa.clearChildNodes(window.document.documentElement);
+ var docNodes = oDomDoc.documentElement.childNodes;
+ for(var i = 0;i<docNodes.length;i++){
+ if(docNodes[i].nodeType == 1){
+ LOG.debug("append new node in document");
+ var node = window.document.importNode(docNodes[i], true);
+ window.document.documentElement.appendChild(node);
+ }
+ }
+ } else {
+ LOG.error("Error parsing response",Sarissa.getParseErrorText(oDomDoc));
+ }
+ // TODO - scripts reloading ?
+ } finally {
+ window.document.open = oldDocOpen;
+ }
+ LOG.debug("page content has been replaced");
+ },30);
+}
+
+
+A4J.AJAX.replaceViewState = function(inputs,newinputs){
+ LOG.debug("Replace value for inputs: "+inputs.length + " by new values: "+ newinputs.length);
+ if( (newinputs.length > 0) && (inputs.length > 0) ){
+ for(var i = 0 ; i < newinputs.length; i++){
+ var newinput = newinputs[i];
+ LOG.debug("Input in response: "+newinput.getAttribute("name"));
+ for(var j = 0 ; j < inputs.length; j++){
+ var input = inputs[j];
+ if(input.name == newinput.getAttribute("name")){
+ LOG.debug("Found same input on page with type: "+input.type);
+ input.value = newinput.getAttribute("value");
+ }
+ }
+ }
+ }
+
+};
+/**
+ *
+ */
+A4J.AJAX.finishRequest = function(request){
+ var options = request.options;
+ // Remove unload prototype events for a removed elements.
+ if ((typeof Event != "undefined") && (typeof Event.unloadElementsCache == "function")) {
+ Event.unloadElementsCache();
+ }
+
+ // we can set listener for complete request - for example,
+ // it can shedule next request for update page.
+ var oncomplete = request.getElementById('org.ajax4jsf.oncomplete');
+ if(oncomplete) {
+ LOG.debug( "Call request oncomplete function after processing updates" );
+ window.setTimeout(function(){
+ var event = request.domEvt;
+ var data = request.getJSON('_ajax:data');
+ try {
+ var newscript = Sarissa.getText(oncomplete,true);
+ if (window.execScript) {
+ window.execScript( newscript );
+ } else {
+ window.eval(newscript);
+ }
+ } catch(e){
+ LOG.error('Error evaluate oncomplete function '+e.Message);
+ }
+// mark status object ( if any ) for complete request ;
+ A4J.AJAX.status(request.containerId,options.status,false);},
+ 10);
+ } else if(options.oncomplete){
+ LOG.debug( "Call component oncomplete function after processing updates" );
+ window.setTimeout(function(){
+ options.oncomplete(request,request.domEvt,request.getJSON('_ajax:data'));
+ // mark status object ( if any ) for complete request ;
+ A4J.AJAX.status(request.containerId,options.status,false);},
+ 10);
+
+ } else {
+ // mark status object ( if any ) for complete request ;
+ A4J.AJAX.status(request.containerId,options.status,false);
+ }
+ // If we have events in queue - send next request.
+ if(options.eventsQueue){
+ var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
+ if( eventsQueue ) {
+ A4J.AJAX._eventsQueues[options.eventsQueue]=false;
+ if(eventsQueue.wait){
+ LOG.debug("Queue not empty, execute next request in queue "+options.eventsQueue);
+ A4J.AJAX.SubmiteventsQueue(eventsQueue);
+ }
+ }
+ }
+ };
+
+A4J.AJAX.getCursorPos = function(inp){
+
+ if(inp.selectionEnd != null)
+ return inp.selectionEnd;
+
+ // IE specific code
+ var range = document.selection.createRange();
+ var isCollapsed = range.compareEndPoints("StartToEnd", range) == 0;
+ if (!isCollapsed)
+ range.collapse(false);
+ var b = range.getBookmark();
+ return b.charCodeAt(2) - 2;
+ }
+
+ // Locate enclosing form for object.
+A4J.AJAX.locateForm = function(obj){
+
+ var parent = obj;
+ while(parent && parent.nodeName.toLowerCase() != 'form'){
+ parent = parent.parentNode;
+ };
+ return parent;
+
+ };
+
+A4J.AJAX.getElementById = function(id,options){
+ var namespace = options['org.ajax4jsf.portlet.NAMESPACE'];
+ var anchor = namespace?window.document.getElementById(namespace):window.document;
+ var element;
+ if(anchor){
+ element = anchor.getElementById(id);
+ } else {
+ LOG.error("No root element for portlet namespace "+namespace+" on page");
+ }
+ return element;
+}
+
+ // hash for requests count for all ID's
+A4J.AJAX._requestsCounts = {};
+ // Change status object on start/stop request.
+ // on start, document object with targetID+".start" make visible,
+ // document object with targetID+".stop" make invisible.
+ // on stop - inverse.
+A4J.AJAX.status = function(regionID,targetID,start){
+ try {
+ var elem;
+ targetID = targetID || regionID +":status";
+ A4J.AJAX._requestsCounts[targetID]=(A4J.AJAX._requestsCounts[targetID]||0)+(start?1:-1);
+ if(A4J.AJAX._requestsCounts[targetID]>0){
+ elem = document.getElementById(targetID+".stop");
+ if(elem){elem.style.display="none";}
+ elem = document.getElementById(targetID+".start");
+ if(elem){
+ elem.style.display="";
+ if(typeof(elem.onstart) == 'function'){
+ elem.onstart();
+ }
+ }
+ }else{
+ elem = document.getElementById(targetID+".start");
+ if(elem){elem.style.display="none";}
+ elem = document.getElementById(targetID+".stop");
+ if(elem){
+ elem.style.display="";
+ if(typeof(elem.onstop) == 'function'){
+ elem.onstop();
+ }
+ }
+ }
+ } catch(e){
+ LOG.error("Exception on status change: ");
+ }
+};
+
+
+
+
+// Class for build query string.
+A4J.Query = function(containerId,form){
+ // For detect AJAX Request.
+ this._query = {AJAXREQUEST : containerId};
+ this._oldSubmit = null ;
+ this._form = form ;
+ this._actionUrl = ( this._form.action)?this._form.action:this._form;
+ };
+
+A4J.Query.prototype = {
+ _form : null,
+ _actionUrl : null,
+ _ext : "",
+ _query : {},
+ _oldSubmit : null,
+ // init at loading time - script can change location at run time ? ...
+ _pageBase : window.location.protocol+"//"+window.location.host,
+ // hash for control elements query string functions
+
+ hidden : function(control){
+ this._value_query(control);
+ // TODO - configurable mask for hidden command scripts.
+ if( (control.name.length > 4) && (control.name.lastIndexOf("_idcl") == (control.name.length-5)) ){
+ control.value="";
+ // MYfaces version ...
+ } else if( (control.name.length > 12) && (control.name.lastIndexOf("_link_hidden_") == (control.name.length-13)) ){
+ control.value="";
+ }
+ },
+
+ text : function(control){
+ this._value_query(control);
+ },
+
+ textarea : function(control){
+ this._value_query(control);
+ },
+
+ 'select-one' : function(control){
+ // If none options selected, don't include parameter.
+ if (control.selectedIndex != -1) {
+ this._value_query(control);
+ }
+// for( var i =0; i< control.childNodes.length; i++ ){
+// var child=control.childNodes[i];
+// if( child.selected ){
+// this._value_query(control);
+// break;
+// }
+// }
+ },
+
+ password : function(control){
+ this._value_query(control);
+ },
+
+ file : function(control){
+ this._value_query(control);
+ },
+
+ radio : function(control){
+ this._check_query(control);
+ },
+
+ checkbox : function(control){
+ this._check_query(control);
+ },
+
+
+ 'select-multiple' : function(control){
+ var cname = control.name;
+ var childs = control.childNodes;
+ for( var i=0 ;i< childs.length;i++ ){
+ var child=childs[i];
+ if( child.tagName == 'OPTGROUP' ){
+ var options = child.childNodes;
+ for(var j=0; j < options.length; j++){
+ this._addOption(cname, options[j]);
+ }
+ } else {
+ this._addOption(cname, child);
+ }
+ }
+ },
+
+ _addOption : function(cname,option){
+ if ( option.selected ){
+ if( ! this._query[cname] ){
+ this._query[cname]=[];
+ }
+ this._query[cname][this._query[cname].length]=option.value;
+ }
+
+ },
+// command inputs
+
+ image : function( control, action ){
+ if(action) this._value_query(control);
+ },
+ button : function( control, action ){
+ if(action) this._value_query(control);
+ },
+
+ submit : function( control, action ){
+ if(action) {
+ this._value_query(control);
+ }
+ },
+
+ // Anchor link pseudo-control.
+ link : function(control, action ){
+ if(action) {
+ this._value_query(control);
+ if(control.parameters){
+ this.appendParameters(control.parameters);
+ }
+ }
+ },
+
+ // same as link, but have additional field - control, for input submit.
+ input : function(control, action ){
+ if(action) {
+ this.link(control, action );
+ // append original control.
+ if( control.control ) {
+ this.appendControl(control.control,action);
+ }
+ }
+ },
+
+ // Append one control to query.
+ appendControl : function(control,action){
+ if( this[control.type] ) {
+ this[control.type](control,action);
+ } else {
+ this._appendById(control.id||control);
+ }
+
+ },
+
+ // Append all non-hidden controls from form to query.
+ appendFormControls : function(hiddenOnly){
+ try {
+ var elems = this._form.elements;
+ if(elems){
+ var k = 0;
+ for ( k=0;k<elems.length;k++ ) {
+ var element=elems[k];
+ try {
+ if( !hiddenOnly || element.type == "hidden") {
+ this.appendControl(element,false) ;
+ }
+ } catch( ee ) {
+ LOG.error("exception in building query ( append form control ) " + ee );
+ }
+ }
+ }
+ } catch(e) {
+ LOG.warn("Error with append form controls to query "+e)
+ }
+ },
+
+ // append map of parameters to query.
+ appendParameters : function(parameters){
+ for( k in parameters ){
+ if(typeof Object.prototype[k] == 'undefined'){
+ LOG.debug( "parameter " + k + " with value "+parameters[k]);
+ this.appendParameter(k,parameters[k]);
+ }
+ }
+ },
+
+ setActionUrl : function(actionUrl){
+ this._actionUrl = actionUrl;
+ },
+// Return action URL ( append extention, if present )
+ getActionUrl : function( ext ) {
+ var actionUrl = this._actionUrl ;
+ var ask = actionUrl.indexOf('?');
+ // create absolute reference - for Firefox XMLHttpRequest base url can vary
+ if( actionUrl.substring(0,1) == '/' ) {
+ actionUrl = this._pageBase+actionUrl;
+ }
+ if ( ! ext ) ext = this._ext ;
+ if( ask >=0 )
+ {
+ return actionUrl.substring(0,ask) + ext + actionUrl.substring(ask);
+ }
+ else return actionUrl + ext;
+ },
+
+
+// Build query string for send to server.
+ getQueryString : function() {
+ var qs = "";
+ var iname ;
+ for ( var k in this._query ){
+ if(typeof Object.prototype[k] == 'undefined'){
+ iname = this._query[k];
+ if( iname instanceof Object ){
+ for ( var l=0; l< iname.length; l++ ) {
+ qs += this._encode(k) + "=" + this._encode(iname[l]) + "&";
+ }
+ } else {
+ qs += this._encode(k) + "=" + this._encode(iname) + "&";
+ }
+ }
+ }
+ LOG.debug("QueryString: "+qs);
+ return qs;
+ },
+ // private methods
+
+ _appendById : function( id ) {
+ this.appendParameter(this._form.id + "_link_hidden_", id);
+ // JSF-ri version ...
+ // this._query[this._form.id + "_idcl"]=id;
+ },
+
+
+ _value_query : function(control){
+ LOG.debug("Append "+control.type+" control "+control.name+" with value ["+control.value+"] and value attribute ["+control.getAttribute('value')+"]");
+ if(null != control.value){
+ this.appendParameter(control.name, control.value);
+ }
+ },
+
+ _check_query : function(control){
+ if( control.checked ) {
+ this.appendParameter(control.name, control.value?control.value:"on");
+ }
+ },
+
+ // Append parameter to query. if name exist, append to array of parameters
+ appendParameter: function(cname,value){
+ if( ! this._query[cname] ){
+ this._query[cname]=value;
+ return;
+ } else if( !(this._query[cname] instanceof Object) ){
+ this._query[cname] = [this._query[cname]];
+ }
+ this._query[cname][this._query[cname].length]=value;
+ },
+
+ // Encode data string for request string
+ _encode : function(string) {
+ try {
+ return encodeURIComponent(string);
+ } catch(e) {
+ var str = escape(string);
+ // escape don't encode +. but form replace ' ' in fields by '+'
+ return str.split('+').join('%2B');
+ }
+ }
+
+
+ }
+
+// Test for re-evaluate Scripts in updated part. Opera & Safari do it.
+A4J.AJAX._scriptEvaluated=false;
+if (!document.all || window.opera){
+ setTimeout(function(){
+ try{
+ // Simulate same calls as on XmlHttp
+ var oDomDoc = Sarissa.getDomDocument();
+ var _span = document.createElement("span");
+ document.documentElement.appendChild(_span);
+ // If script evaluated with used replace method, variable will be set to true
+ var xmlString = "<html xmlns='http://www.w3.org/1999/xhtml'><sc"+"ript>A4J.AJAX._scriptEvaluated=true;</scr"+"ipt></html>";
+ oDomDoc = (new DOMParser()).parseFromString(xmlString, "text/xml");
+ var _script=oDomDoc.getElementsByTagName("script")[0];
+ if(_span.outerHTML){
+ _span.outerHTML = new XMLSerializer().serializeToString(_script);
+ } else {
+ var importednode ;
+ importednode = window.document.importNode(_script, true);
+ document.documentElement.replaceChild(importednode,_span);
+ }
+
+ } catch(e){ /* Mozilla in XHTML mode not have innerHTML */ };
+ },50);
+}
Deleted: tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,191 +0,0 @@
-package org.richfaces.demo.extendeddatamodel;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-import org.ajax4jsf.model.SerializableDataModel;
-/**
- *
- * @author ias
- * This is example class that intended to demonstrate use of ExtendedDataModel and SerializableDataModel.
- * This implementation intended to be used as a request scope bean. However, it actually provides serialized
- * state, so on a post-back we do not load data from the data provider. Instead we use whatever data was used
- * during rendering.
- * This data model intended to be used together with Data Provider, which is responsible for actual data load
- * from the database using specific filtering and sorting. Normally it suppose to be in either session, or conversation
- * scope.
- */
-public class AuctionDataModel extends SerializableDataModel {
-
- private AuctionDataProvider dataProvider;
- private Integer currentPk;
- private Map<Integer,AuctionItem> wrappedData = new HashMap<Integer,AuctionItem>();
- private List<Integer> wrappedKeys = null;
- private boolean detached = false;
-
- /**
- *
- */
- private static final long serialVersionUID = -1956179896877538628L;
-
- /**
- * This method never called from framework.
- * (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- @Override
- public Object getRowKey() {
- return currentPk;
- }
- /**
- * This method normally called by Visitor before request Data Row.
- */
- @Override
- public void setRowKey(Object key) {
- this.currentPk = (Integer) key;
-
- }
- /**
- * This is main part of Visitor pattern. Method called by framework many times during request processing.
- */
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException {
- int firstRow = ((SequenceRange)range).getFirstRow();
- int numberOfRows = ((SequenceRange)range).getRows();
- if (detached) { // Is this serialized model
-// Here we just ignore current Rage and use whatever data was saved in serialized model.
-// Such approach uses much more getByPk() operations, instead of just one request by range.
-// Concrete case may be different from that, so you can just load data from data provider by range.
-// We are using wrappedKeys list only to preserve actual order of items.
- for (Integer key:wrappedKeys) {
- setRowKey(key);
- visitor.process(context, key, argument);
- }
- } else { // if not serialized, than we request data from data provider
- wrappedKeys = new ArrayList<Integer>();
- for (AuctionItem item:dataProvider.getItemsByrange(new Integer(firstRow), numberOfRows, null, true)) {
- wrappedKeys.add(item.getPk());
- wrappedData.put(item.getPk(), item);
- visitor.process(context, item.getPk(), argument);
- }
- }
- }
- /**
- * This method must return actual data rows count from the Data Provider. It is used by pagination control
- * to determine total number of data items.
- */
- private Integer rowCount; // better to buffer row count locally
- @Override
- public int getRowCount() {
- if (rowCount==null) {
- rowCount = new Integer(getDataProvider().getRowCount());
- return rowCount.intValue();
- } else {
- return rowCount.intValue();
- }
- }
- /**
- * This is main way to obtain data row. It is intensively used by framework.
- * We strongly recommend use of local cache in that method.
- */
- @Override
- public Object getRowData() {
- if (currentPk==null) {
- return null;
- } else {
- AuctionItem ret = wrappedData.get(currentPk);
- if (ret==null) {
- ret = getDataProvider().getAuctionItemByPk(currentPk);
- wrappedData.put(currentPk, ret);
- return ret;
- } else {
- return ret;
- }
- }
- }
-
- /**
- * Unused rudiment from old JSF staff.
- */
- @Override
- public int getRowIndex() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Unused rudiment from old JSF staff.
- */
- @Override
- public Object getWrappedData() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Never called by framework.
- */
- @Override
- public boolean isRowAvailable() {
- if (currentPk==null) {
- return false;
- } else {
- return getDataProvider().hasAuctionItemByPk(currentPk);
- }
- }
-
- /**
- * Unused rudiment from old JSF staff.
- */
- @Override
- public void setRowIndex(int rowIndex) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Unused rudiment from old JSF staff.
- */
- @Override
- public void setWrappedData(Object data) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * This method suppose to produce SerializableDataModel that will be serialized into View State and used on a post-back.
- * In current implementation we just mark current model as serialized. In more complicated cases we may need to
- * transform data to actually serialized form.
- */
- public SerializableDataModel getSerializableModel(Range range) {
- if (wrappedKeys!=null) {
- detached = true;
-// Some activity to detach persistent data from wrappedData map may be taken here.
-// In that specific case we are doing nothing.
- return this;
- } else {
- return null;
- }
- }
- /**
- * This is helper method that is called by framework after model update. In must delegate actual database update to
- * Data Provider.
- */
- @Override
- public void update() {
- getDataProvider().update();
- }
-
- public AuctionDataProvider getDataProvider() {
- return dataProvider;
- }
-
- public void setDataProvider(AuctionDataProvider dataProvider) {
- this.dataProvider = dataProvider;
- }
-
-}
Copied: tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java (from rev 2787, trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java)
===================================================================
--- tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java (rev 0)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,191 @@
+package org.richfaces.demo.extendeddatamodel;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+import org.ajax4jsf.model.SerializableDataModel;
+/**
+ *
+ * @author ias
+ * This is example class that intended to demonstrate use of ExtendedDataModel and SerializableDataModel.
+ * This implementation intended to be used as a request scope bean. However, it actually provides serialized
+ * state, so on a post-back we do not load data from the data provider. Instead we use data that was used
+ * during rendering.
+ * This data model must be used together with Data Provider, which is responsible for actual data load
+ * from the database using specific filtering and sorting. Normally Data Provider must be in either session, or conversation
+ * scope.
+ */
+public class AuctionDataModel extends SerializableDataModel {
+
+ private AuctionDataProvider dataProvider;
+ private Integer currentPk;
+ private Map<Integer,AuctionItem> wrappedData = new HashMap<Integer,AuctionItem>();
+ private List<Integer> wrappedKeys = null;
+ private boolean detached = false;
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1956179896877538628L;
+
+ /**
+ * This method never called from framework.
+ * (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ @Override
+ public Object getRowKey() {
+ return currentPk;
+ }
+ /**
+ * This method normally called by Visitor before request Data Row.
+ */
+ @Override
+ public void setRowKey(Object key) {
+ this.currentPk = (Integer) key;
+
+ }
+ /**
+ * This is main part of Visitor pattern. Method called by framework many times during request processing.
+ */
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException {
+ int firstRow = ((SequenceRange)range).getFirstRow();
+ int numberOfRows = ((SequenceRange)range).getRows();
+ if (detached) { // Is this serialized model
+// Here we just ignore current Rage and use whatever data was saved in serialized model.
+// Such approach uses much more getByPk() operations, instead of just one request by range.
+// Concrete case may be different from that, so you can just load data from data provider by range.
+// We are using wrappedKeys list only to preserve actual order of items.
+ for (Integer key:wrappedKeys) {
+ setRowKey(key);
+ visitor.process(context, key, argument);
+ }
+ } else { // if not serialized, than we request data from data provider
+ wrappedKeys = new ArrayList<Integer>();
+ for (AuctionItem item:dataProvider.getItemsByrange(new Integer(firstRow), numberOfRows, null, true)) {
+ wrappedKeys.add(item.getPk());
+ wrappedData.put(item.getPk(), item);
+ visitor.process(context, item.getPk(), argument);
+ }
+ }
+ }
+ /**
+ * This method must return actual data rows count from the Data Provider. It is used by pagination control
+ * to determine total number of data items.
+ */
+ private Integer rowCount; // better to buffer row count locally
+ @Override
+ public int getRowCount() {
+ if (rowCount==null) {
+ rowCount = new Integer(getDataProvider().getRowCount());
+ return rowCount.intValue();
+ } else {
+ return rowCount.intValue();
+ }
+ }
+ /**
+ * This is main way to obtain data row. It is intensively used by framework.
+ * We strongly recommend use of local cache in that method.
+ */
+ @Override
+ public Object getRowData() {
+ if (currentPk==null) {
+ return null;
+ } else {
+ AuctionItem ret = wrappedData.get(currentPk);
+ if (ret==null) {
+ ret = getDataProvider().getAuctionItemByPk(currentPk);
+ wrappedData.put(currentPk, ret);
+ return ret;
+ } else {
+ return ret;
+ }
+ }
+ }
+
+ /**
+ * Unused rudiment from old JSF staff.
+ */
+ @Override
+ public int getRowIndex() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unused rudiment from old JSF staff.
+ */
+ @Override
+ public Object getWrappedData() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Never called by framework.
+ */
+ @Override
+ public boolean isRowAvailable() {
+ if (currentPk==null) {
+ return false;
+ } else {
+ return getDataProvider().hasAuctionItemByPk(currentPk);
+ }
+ }
+
+ /**
+ * Unused rudiment from old JSF staff.
+ */
+ @Override
+ public void setRowIndex(int rowIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unused rudiment from old JSF staff.
+ */
+ @Override
+ public void setWrappedData(Object data) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * This method suppose to produce SerializableDataModel that will be serialized into View State and used on a post-back.
+ * In current implementation we just mark current model as serialized. In more complicated cases we may need to
+ * transform data to actually serialized form.
+ */
+ public SerializableDataModel getSerializableModel(Range range) {
+ if (wrappedKeys!=null) {
+ detached = true;
+// Some activity to detach persistent data from wrappedData map may be taken here.
+// In that specific case we are doing nothing.
+ return this;
+ } else {
+ return null;
+ }
+ }
+ /**
+ * This is helper method that is called by framework after model update. In must delegate actual database update to
+ * Data Provider.
+ */
+ @Override
+ public void update() {
+ getDataProvider().update();
+ }
+
+ public AuctionDataProvider getDataProvider() {
+ return dataProvider;
+ }
+
+ public void setDataProvider(AuctionDataProvider dataProvider) {
+ this.dataProvider = dataProvider;
+ }
+
+}
Deleted: tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,100 +0,0 @@
-package org.richfaces.demo.extendeddatamodel;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-public class AuctionItem {
- private Integer pk;
- private String description;
- private Double bid;
- private Double highestBid;
- private Integer qtyRequested;
- private Integer qtyAvialable;
- private UIComponent bidInput;
- private UIComponent qtyInput;
- private boolean won = false;
- private boolean loose = false;
- private Double amount;
-
- @SuppressWarnings("unused")
- private AuctionItem() {};
-
- public AuctionItem(Integer pk) {
- this.pk = pk;
- }
-
- public Integer getPk() {
- return pk;
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public Double getBid() {
- return bid;
- }
- public void setBid(Double bid) {
- this.bid = bid;
- }
- public Double getHighestBid() {
- return highestBid;
- }
- public void setHighestBid(Double highestBid) {
- this.highestBid = highestBid;
- }
- public Integer getQtyRequested() {
- return qtyRequested;
- }
- public void setQtyRequested(Integer qty) {
- this.qtyRequested = qty;
- }
- public Double getAmount() {
- return this.amount;
- }
- public Integer getQtyAvialable() {
- return qtyAvialable;
- }
- public void setQtyAvialable(Integer qtyAvialable) {
- this.qtyAvialable = qtyAvialable;
- }
- public String placeBid() {
- if (qtyRequested!=null && bid!=null) {
- System.out.println("place bid for pk="+getPk()+" bid="+getBid()+" qty="+getQtyRequested());
- FacesContext ctx = FacesContext.getCurrentInstance();
- if (qtyRequested>qtyAvialable) {
- ctx.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Requested quantity is grater that avialable quantity","You cannot request more auction items, that actually avialable on auction"));
- won = loose = false;
- } else if (bid<=highestBid) {
- ctx.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,"Bid amount is lower that highest bid","You need to bid amount higher that highest bid"));
- won = false;
- loose = true;
- } else {
- highestBid = bid;
- won = true;
- loose = false;
- amount = qtyRequested*bid;
- }
- }
- return null;
- }
-
- public UIComponent getBidInput() {
- return bidInput;
- }
-
- public void setBidInput(UIComponent bidInput) {
- this.bidInput = bidInput;
- }
-
- public UIComponent getQtyInput() {
- return qtyInput;
- }
-
- public void setQtyInput(UIComponent qtyInput) {
- this.qtyInput = qtyInput;
- }
-
-}
Copied: tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java (from rev 2787, trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java)
===================================================================
--- tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java (rev 0)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,99 @@
+package org.richfaces.demo.extendeddatamodel;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+public class AuctionItem {
+ private Integer pk;
+ private String description;
+ private Double bid;
+ private Double highestBid;
+ private Integer qtyRequested;
+ private Integer qtyAvialable;
+ private UIComponent bidInput;
+ private UIComponent qtyInput;
+ private boolean won = false;
+ private boolean loose = false;
+ private Double amount;
+
+ @SuppressWarnings("unused")
+ private AuctionItem() {};
+
+ public AuctionItem(Integer pk) {
+ this.pk = pk;
+ }
+
+ public Integer getPk() {
+ return pk;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public Double getBid() {
+ return bid;
+ }
+ public void setBid(Double bid) {
+ this.bid = bid;
+ }
+ public Double getHighestBid() {
+ return highestBid;
+ }
+ public void setHighestBid(Double highestBid) {
+ this.highestBid = highestBid;
+ }
+ public Integer getQtyRequested() {
+ return qtyRequested;
+ }
+ public void setQtyRequested(Integer qty) {
+ this.qtyRequested = qty;
+ }
+ public Double getAmount() {
+ return this.amount;
+ }
+ public Integer getQtyAvialable() {
+ return qtyAvialable;
+ }
+ public void setQtyAvialable(Integer qtyAvialable) {
+ this.qtyAvialable = qtyAvialable;
+ }
+ public void placeBid(ActionEvent event) {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ if (bid!=null) {
+ System.out.println("place bid for pk="+getPk()+" bid="+getBid()+" qty="+getQtyRequested());
+ if (bid<=highestBid) {
+ ctx.addMessage(event.getComponent().getClientId(ctx), new FacesMessage(FacesMessage.SEVERITY_WARN,"Bid amount is lower that highest bid","You need to bid amount higher that highest bid"));
+ won = false;
+ loose = true;
+ } else {
+ highestBid = bid;
+ won = true;
+ loose = false;
+ amount = bid;
+ }
+ } else {
+ ctx.addMessage(event.getComponent().getClientId(ctx), new FacesMessage(FacesMessage.SEVERITY_ERROR,"Bid value is missing","You must provide bid value"));
+ }
+ }
+
+ public UIComponent getBidInput() {
+ return bidInput;
+ }
+
+ public void setBidInput(UIComponent bidInput) {
+ this.bidInput = bidInput;
+ }
+
+ public UIComponent getQtyInput() {
+ return qtyInput;
+ }
+
+ public void setQtyInput(UIComponent qtyInput) {
+ this.qtyInput = qtyInput;
+ }
+
+}
Deleted: tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,62 +0,0 @@
-<ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich">
-
- <rich:messages />
-
- <h:form>
- <rich:datascroller for="auction" maxPages="5"/>
- <rich:spacer height="30" />
- <rich:dataTable id="auction" value="#{auctionDataModel}" var="item" rows="25">
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Description"/>
- </f:facet>
- <h:outputText value="#{item.description}"/>
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Highest Bid"/>
- </f:facet>
- <h:outputText id="highestBid" value="#{item.highestBid}">
- <f:convertNumber pattern="$#,##0.00"/>
- </h:outputText>
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Qty Avialable"/>
- </f:facet>
- <h:outputText value="#{item.qtyAvialable}"/>
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Your Bid"/>
- </f:facet>
- <h:inputText id="bid" value="#{item.bid}">
- <f:convertNumber />
- </h:inputText>
- <a4j:commandLink action="#{item.placeBid}" value="Bid!" reRender="bid,qty,amount,highestBid" />
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Your Qty"/>
- </f:facet>
- <h:inputText id="qty" value="#{item.qtyRequested}">
- <f:convertNumber />
- </h:inputText>
- </rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="Amount"/>
- </f:facet>
- <h:outputText id="amount" value="#{item.amount}" >
- <f:convertNumber pattern="$#,##0.00"/>
- </h:outputText>
- </rich:column>
- </rich:dataTable>
- </h:form>
-
-</ui:composition>
\ No newline at end of file
Copied: tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml (from rev 2787, trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml)
===================================================================
--- tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml (rev 0)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,48 @@
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+ <rich:messages />
+ <h:form>
+ <rich:datascroller for="auction" maxPages="5"/>
+ <rich:spacer height="30" />
+ <rich:dataTable id="auction" value="#{auctionDataModel}" var="item" rows="10">
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Description"/>
+ </f:facet>
+ <h:outputText value="#{item.description}"/>
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Highest Bid"/>
+ </f:facet>
+ <h:outputText id="highestBid" value="#{item.highestBid}">
+ <f:convertNumber pattern="$#,##0.00"/>
+ </h:outputText>
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Your Bid"/>
+ </f:facet>
+ <h:inputText id="bid" value="#{item.bid}">
+ <f:convertNumber />
+ </h:inputText>
+ <a4j:commandLink id="bid_link" actionListener="#{item.placeBid}" value="Place a bid!" reRender="bid,amount,highestBid" />
+ <rich:message for="bid_link" />
+ <rich:message for="bid" />
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Amount"/>
+ </f:facet>
+ <h:outputText id="amount" value="#{item.amount}" >
+ <f:convertNumber pattern="$#,##0.00"/>
+ </h:outputText>
+ </rich:column>
+ </rich:dataTable>
+ </h:form>
+
+</ui:composition>
\ No newline at end of file
Deleted: tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,29 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich">
- <ui:composition template="/templates/component-sample.xhtml">
- <ui:define name="sample">
- <p>Some explanation how to use ExtendedDataModel will be here
- </p>
- <div class="sample-container" >
-
- <ui:include src="/richfaces/dataTable/examples/extendedDataModel.xhtml"/>
- <ui:include src="/templates/include/sourceview.xhtml">
- <ui:param name="sourcepath" value="/richfaces/dataTable/examples/extendedDataModel.xhtml"/>
- <ui:param name="openlabel" value="View Page Source" />
- </ui:include>
-
- <ui:include src="/templates/include/sourceview.xhtml">
- <ui:param name="sourcepath" value="/WEB-INF/src/org/richfaces/datatable/ExpenseReport.java"/>
- <ui:param name="openlabel" value="View Page Source" />
- </ui:include>
-
- </div>
- </ui:define>
-
- </ui:composition>
-</html>
Copied: tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml (from rev 2787, trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml)
===================================================================
--- tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml (rev 0)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,51 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+ <ui:composition template="/templates/component-sample.xhtml">
+ <ui:define name="sample">
+ <p>
+Perhaps the most obvious problem of DataTable and javax.faces.model.DataModel is lack of support for more complicated scenarios that uses
+data from the database.
+To solve that problem <b>Richfaces</b> has two major tools:
+<ul>
+ <li>
+ set of data-driven components that render data sets in many different ways (<b>rich:dataTable</b> , <b>rich:dataGrid</b>, <b>rich:dataList</b>, <b>a4j:repeat</b> etc.).
+ All this components derived it common functionality from the common core that, in addition to standard javax.faces.model.DataModel,
+ can understand and use
+ </li>
+ <li>
+ extended data model classes <b>org.ajax4jsf.model.ExtendedDataModel</b> and <b>org.ajax4jsf.model.SerializableDataModel</b>. This two classes works
+ together to provide functions that missing in standard DataModel.
+ </li>
+</ul>
+The most important additional functions are:
+<ul>
+ <li>access for rows by primary keys instead of index position</li>
+ <li>implementation of "visitor" pattern over the "range" of rows to support "table scroller" or "paginator" functions</li>
+ <li>ability to serialize table data so it may be used on a post-back processing without additional database query</li>
+</ul>
+To use this extensions you need to implement your own DataModel that extends one of our ExtendedDataModel classes and implement few of
+important functions. Below is the example of such implementation.
+ </p>
+ <div class="sample-container" >
+
+ <ui:include src="/richfaces/dataTable/examples/extendedDataModel.xhtml"/>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath" value="/richfaces/dataTable/examples/extendedDataModel.xhtml"/>
+ <ui:param name="openlabel" value="View Page Source" />
+ </ui:include>
+
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath" value="/WEB-INF/src/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java"/>
+ <ui:param name="openlabel" value="View Page Source" />
+ </ui:include>
+
+ </div>
+ </ui:define>
+
+ </ui:composition>
+</html>
Deleted: tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/form/snippets/commandLinkProblem.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/form/snippets/commandLinkProblem.xhtml 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/form/snippets/commandLinkProblem.xhtml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,17 +0,0 @@
- ....
- <-- This code does not work correctly after the link is re-rendered -->
- <-- Parameter will not be encoded correctly in this case -->
- <h:form>
- ....
- <a4j:commandButton value="Update Non-Ajax Link" reRender="panel" />
- ....
- <h:panelGrid id="panel">
- ....
- <h:commandLink value="Non-Ajax Submit" action="foo" >
- <f:param name="param1" value="foo"/>
- ...
- </h:commandLink>
- ....
- </h:panelGrid>
- ....
- </h:form>
\ No newline at end of file
Copied: tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/form/snippets/commandLinkProblem.xhtml (from rev 2787, trunk/samples/richfaces-demo/src/main/webapp/richfaces/form/snippets/commandLinkProblem.xhtml)
===================================================================
--- tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/form/snippets/commandLinkProblem.xhtml (rev 0)
+++ tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/form/snippets/commandLinkProblem.xhtml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,15 @@
+ ....
+ <-- This code does not work correctly after the link is re-rendered -->
+ <h:form>
+ ....
+ <a4j:commandButton value="Update Non-Ajax Link" reRender="panel" />
+ ....
+ <h:panelGrid id="panel">
+ ....
+ <h:commandLink value="Non-Ajax Submit" action="foo" >
+ ...
+ </h:commandLink>
+ ....
+ </h:panelGrid>
+ ....
+ </h:form>
\ No newline at end of file
Copied: tags/3.1.0-rc5/samples/richfaces-demo/src/main/webapp/richfaces/htmlCommandLink (from rev 2787, trunk/samples/richfaces-demo/src/main/webapp/richfaces/htmlCommandLink)
Deleted: tags/3.1.0-rc5/samples/seamEAR/pom.xml
===================================================================
--- trunk/samples/seamEAR/pom.xml 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/samples/seamEAR/pom.xml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,91 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <!--
- <parent>
- <artifactId>samples</artifactId>
- <groupId>org.richfaces</groupId>
- <version>3.1.0-SNAPSHOT</version>
- </parent>
- -->
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.samples</groupId>
- <version>3.1.0-SNAPSHOT</version>
- <artifactId>seamEAR</artifactId>
- <packaging>pom</packaging>
- <name>seam EAR project</name>
- <modules>
- <module>projects</module>
- <module>primary-source</module>
- <module>wars</module>
- <module>ejbs</module>
- <module>ear</module>
- </modules>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <unzipCommand>
- /usr/bin/unzip -o > err.txt
- </unzipCommand>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <inherited>true</inherited>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- <repositories>
- <repository>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- <updatePolicy>never</updatePolicy>
- </snapshots>
- <id>repository.jboss.com</id>
- <name>Jboss Repository for Maven</name>
- <url>http://repository.jboss.com/maven2/</url>
- <layout>default</layout>
- </repository>
- </repositories>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>
- org.richfaces.samples.seamEAR.projects
- </groupId>
- <artifactId>logging</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.samples.seamEAR</groupId>
- <artifactId>primary-source</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.samples.seamEAR.wars</groupId>
- <artifactId>seamWebapp</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- <type>war</type>
- </dependency>
- <dependency>
- <groupId>org.richfaces.samples.seamEAR</groupId>
- <artifactId>ejbs</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- <type>ejb</type>
- </dependency>
- </dependencies>
- </dependencyManagement>
-</project>
Copied: tags/3.1.0-rc5/samples/seamEAR/pom.xml (from rev 2788, trunk/samples/seamEAR/pom.xml)
===================================================================
--- tags/3.1.0-rc5/samples/seamEAR/pom.xml (rev 0)
+++ tags/3.1.0-rc5/samples/seamEAR/pom.xml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <!--
+ <parent>
+ <artifactId>samples</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.1.0-SNAPSHOT</version>
+ </parent>
+ -->
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.samples</groupId>
+ <version>3.1.0-SNAPSHOT</version>
+ <artifactId>seamEAR</artifactId>
+ <packaging>pom</packaging>
+ <name>seam EAR project</name>
+ <modules>
+ <module>projects</module>
+ <module>primary-source</module>
+ <module>wars</module>
+ <module>ejbs</module>
+ <module>ear</module>
+ </modules>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <repositories>
+ <repository>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ <id>repository.jboss.com</id>
+ <name>Jboss Repository for Maven</name>
+ <url>http://repository.jboss.com/maven2/</url>
+ <layout>default</layout>
+ </repository>
+ </repositories>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>
+ org.richfaces.samples.seamEAR.projects
+ </groupId>
+ <artifactId>logging</artifactId>
+ <version>3.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.samples.seamEAR</groupId>
+ <artifactId>primary-source</artifactId>
+ <version>3.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.samples.seamEAR.wars</groupId>
+ <artifactId>seamWebapp</artifactId>
+ <version>3.1.0-SNAPSHOT</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.samples.seamEAR</groupId>
+ <artifactId>ejbs</artifactId>
+ <version>3.1.0-SNAPSHOT</version>
+ <type>ejb</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
Deleted: tags/3.1.0-rc5/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java
===================================================================
--- trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,95 +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.ajax4jsf;
-
-import java.io.Serializable;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpSession;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.End;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-/**
- * @author $Autor$
- *
- */
-@Name("seamBean") @Scope(ScopeType.CONVERSATION) public class Bean implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -4209339000953631111L;
- private String text;
- private String text2;
-
- /**
- * @return the text
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text the text to set
- */
- public void setText(String text) {
- this.text = text;
- }
-
- @Begin
- public String start() {
- return "start";
- }
-
- @End
- public String stop() {
- return "stop";
- }
-
- public String clearSession(){
- ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
- HttpSession session = (HttpSession) externalContext.getSession(false);
- if(null != session){
- session.setMaxInactiveInterval(10);
- }
- return null;
- }
-
- /**
- * @return the text2
- */
- public String getText2() {
- return text2;
- }
-
- /**
- * @param text2 the text2 to set
- */
- public void setText2(String text2) {
- this.text2 = text2;
- }
-}
\ No newline at end of file
Copied: tags/3.1.0-rc5/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java (from rev 2788, trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java)
===================================================================
--- tags/3.1.0-rc5/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java (rev 0)
+++ tags/3.1.0-rc5/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,95 @@
+/**
+ * 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.ajax4jsf;
+
+import java.io.Serializable;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpSession;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.End;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+/**
+ * @author $Autor$
+ *
+ */
+@Name("seamBean") @Scope(ScopeType.CONVERSATION) public class Bean implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4209339000953631111L;
+ private String text;
+ private String text2;
+
+ /**
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ @Begin
+ public String start() {
+ return "start";
+ }
+
+ @End
+ public String stop() {
+ return "stop";
+ }
+
+ public String clearSession(){
+ ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+ HttpSession session = (HttpSession) externalContext.getSession(false);
+ if(null != session){
+ session.setMaxInactiveInterval(5);
+ }
+ return null;
+ }
+
+ /**
+ * @return the text2
+ */
+ public String getText2() {
+ return text2;
+ }
+
+ /**
+ * @param text2 the text2 to set
+ */
+ public void setText2(String text2) {
+ this.text2 = text2;
+ }
+}
\ No newline at end of file
Copied: tags/3.1.0-rc5/test-applications/facelets/src/main/java (from rev 2787, trunk/test-applications/facelets/src/main/java)
Copied: tags/3.1.0-rc5/test-applications/facelets/src/main/webapp (from rev 2787, trunk/test-applications/facelets/src/main/webapp)
Deleted: tags/3.1.0-rc5/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/ui/calendar/src/main/config/component/calendar.xml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,449 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd"
-[
-<!ENTITY listeners SYSTEM "listener.ent">
-]
->
-<components>
- <component>
- <name>org.richfaces.Calendar</name>
- <family>org.richfaces.Calendar</family>
- <classname>org.richfaces.component.html.HtmlCalendar</classname>
- <superclass>org.richfaces.component.UICalendar</superclass>
- <test>
- <classname>
- org.richfaces.component.html.HtmlCalendarTest
- </classname>
- <superclassname>
- org.ajax4jsf.tests.AbstractAjax4JsfTestCase
- </superclassname>
- </test>
- <description>
- <![CDATA[
- ]]>
- </description>
- <renderer generate="true" override="true">
- <name>org.richfaces.CalendarRenderer</name>
- <template>org/richfaces/htmlCalendar.jspx</template>
- </renderer>
- <tag>
- <name>calendar</name>
- <classname>org.richfaces.taglib.CalendarTag</classname>
- <superclass>
- org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
- </superclass>
-
- <test>
- <classname>
- org.richfaces.component.html.HtmlCalendarTest
- </classname>
- <superclassname>
- org.ajax4jsf.tests.AbstractAjax4JsfTestCase
- </superclassname>
- </test>
- </tag>
- <!--
- <taghandler>
- <classname>org.ajax4jsf.tag.TestHandler</classname>
- </taghandler>
- -->
- &ui_component_attributes;
- &ajax_component_attributes;
- &ui_input_attributes;
- &ui_output_attributes;
- <property>
- <name>width</name>
- <classname>java.lang.String</classname>
- <description>Defines a width of the calendar</description>
- <defaultvalue>"400px;"</defaultvalue>
- </property>
- <property>
- <name>height</name>
- <classname>java.lang.String</classname>
- <description>Defines a height of the calendar</description>
- <defaultvalue>"250px"</defaultvalue>
- </property>
- <property elonly="true">
- <name>dataModel</name>
- <classname>org.richfaces.model.CalendarDataModel</classname>
- <description>
- Used to provide data for calendar elements. If data is
- not provided, all Data Model related functions are
- disabled
- </description>
- </property>
- <property elonly="true">
- <name>locale</name>
- <classname>java.util.Locale</classname>
- <description>Used for locale definition</description>
- <defaultvalue>getDefaultLocale()</defaultvalue>
- </property>
- <property elonly="true">
- <name>timeZone</name>
- <classname>java.util.TimeZone</classname>
- <description>
- Used for current date calculations
- </description>
- <defaultvalue>getDefaultTimeZone()</defaultvalue>
- </property>
- <property elonly="true">
- <name>preloadDateRangeBegin</name>
- <classname>java.util.Date</classname>
- <description>
- Define the initial range of date which will be loaded to
- client from dataModel under rendering
- </description>
- <defaultvalue>
- getDefaultPreloadBegin(getCurrentDateOrDefault())
- </defaultvalue>
- </property>
- <property elonly="true">
- <name>preloadDateRangeEnd</name>
- <classname>java.util.Date</classname>
- <description>
- Defines the last range of date which will be loaded to
- client from dataModel under rendering
- </description>
- <defaultvalue>
- getDefaultPreloadEnd(getCurrentDateOrDefault())
- </defaultvalue>
- </property>
- <property elonly="true">
- <name>currentDate</name>
- <classname>java.util.Date</classname>
- <description>Defines current date</description>
- <defaultvalue>
- java.util.Calendar.getInstance(getTimeZone()).getTime()
- </defaultvalue>
- </property>
- <property>
- <name>currentDateChangeListener</name>
- <classname>javax.faces.el.MethodBinding</classname>
- <description>MethodBinding representing an action listener method that will be notified after date selection</description>
- </property>
- <property>
- <name>datePattern</name>
- <classname>java.lang.String</classname>
- <description>Defines date pattern</description>
- <defaultvalue>"MMM d, yyyy"</defaultvalue>
- </property>
- <property>
- <name>scrollMode</name>
- <classname>java.lang.String</classname>
- <description>
- Valid values are "ajax" and "client"
- </description>
- <defaultvalue>"ajax"</defaultvalue>
- </property>
- <property>
- <name>popup</name>
- <classname>boolean</classname>
- <description>
- If "true" calendar will be rendered initially
- as hidden with additional elements for calling as popup
- </description>
- <defaultvalue>true</defaultvalue>
- </property>
- <property>
- <name>disabled</name>
- <classname>boolean</classname>
- <description>
- If "true", rendered is disabled. In
- "popup" mode both controls are disabled
- </description>
- <defaultvalue>false</defaultvalue>
- </property>
- <property>
- <name>jointPoint</name>
- <classname>java.lang.String</classname>
- <description>
- Set the corner of the button for the popup to be
- connected with (top-left, top-right, bottom-left
- (Default), bottom-right, auto)
- </description>
- <defaultvalue>"bottom-left"</defaultvalue>
- </property>
- <property>
- <name>direction</name>
- <classname>java.lang.String</classname>
- <description>
- Defines direction of the calendar popup (top-left,
- top-right, bottom-left, bottom-right (Default), auto)
- </description>
- <defaultvalue>"bottom-right"</defaultvalue>
- </property>
- <property>
- <name>weekDayLabels</name>
- <classname>java.lang.Object</classname>
- <description>
- List of the day names displays on the days bar in the
- following way "Sun, Mon, Tue, Wed, …"
- </description>
- </property>
- <property>
- <name>weekDayLabelsShort</name>
- <classname>java.lang.Object</classname>
- <description>
- Attribute that allows to customize short names of the
- weeks. Should accept list with the weeks names.
- </description>
- </property>
- <property>
- <name>monthLabels</name>
- <classname>java.lang.Object</classname>
- <description>
- Attribute that allows to customize names of the months.
- Should accept list with the month names
- </description>
- </property>
- <property>
- <name>monthLabelsShort</name>
- <classname>java.lang.Object</classname>
- <description>
- Attribute that allows to customize short names of the
- months. Should accept list with the month names
- </description>
- </property>
- <property>
- <name>buttonLabel</name>
- <classname>java.lang.String</classname>
- <description>
- Defines label for the popup button element
- </description>
- <defaultvalue>"popupButton"</defaultvalue>
- </property>
- <property>
- <name>toolTipMode</name>
- <classname>java.lang.String</classname>
- <description>
- Used to specify mode to load tooltips. Valid values are
- "none", "single" and
- "batch"
- </description>
- <defaultvalue>"batch"</defaultvalue>
- </property>
- <property>
- <name>boundaryDatesMode</name>
- <classname>java.lang.String</classname>
- <description>
- Used for the dates boundaries in the list. Valid values
- are "inactive" (Default) – dates inactive and
- gray colored, "scroll" – boundaries work as
- month scrolling controls, and "select" –
- boundaries work in the same way as "scroll"
- but with the date clicked selection
- </description>
- <defaultvalue>"inactive"</defaultvalue>
- </property>
- <property>
- <name>enableManualInput</name>
- <classname>boolean</classname>
- <description>
- If "true" calendar input will be editable and
- it will be possible to change the date manualy. If
- "false" value for this attribute makes a text
- field "read-only", so the value can be changed
- only from a handle
- </description>
- <defaultvalue>false</defaultvalue>
- </property>
- <property>
- <name>showInput</name>
- <classname>boolean</classname>
- <description>
- "false" value for this attribute makes text
- field invisible. If "true" - input field will
- be shown
- </description>
- <defaultvalue>true</defaultvalue>
- </property>
- <property>
- <name>style</name>
- <classname>java.lang.String</classname>
- <description>
- CSS style(s) is/are to be applied when this component is
- rendered
- </description>
- </property>
- <property>
- <name>styleClass</name>
- <classname>java.lang.String</classname>
- <description>
- Corresponds to the HTML class attribute
- </description>
- </property>
- <property>
- <name>inputStyle</name>
- <classname>java.lang.String</classname>
- <description>Style attribute for text field</description>
- </property>
- <property>
- <name>inputClass</name>
- <classname>java.lang.String</classname>
- <description>
- Style Class attribute for a text field
- </description>
- </property>
- <property>
- <name>zindex</name>
- <classname>int</classname>
- <description>
- Attribute is similar to the standard HTML attribute and
- can specify window placement relative to the content
- </description>
- <defaultvalue>3</defaultvalue>
- </property>
-
- <property>
- <name>requiredMessage</name>
- <classname>java.lang.String</classname>
- <description>
- A ValueExpression enabled attribute that, if present,
- will be used as the text of the validation message for
- the "required" facility, if the "required" facility is
- used
- </description>
- </property>
- <property>
- <name>validatorMessage</name>
- <classname>java.lang.String</classname>
- <description>
- A ValueExpression enabled attribute that, if present,
- will be used as the text of the validator message,
- replacing any message that comes from the validator
- </description>
- </property>
- <property>
- <name>converterMessage</name>
- <classname>java.lang.String</classname>
- <description>
- A ValueExpression enabled attribute that, if present,
- will be used as the text of the converter message,
- replacing any message that comes from the converter
- </description>
- </property>
-
- <property>
- <name>ondateselect</name>
- <classname>java.lang.String</classname>
- <description>
- onDateSelect event handler
- </description>
- </property>
- <property>
- <name>oncurrentdateselect</name>
- <classname>java.lang.String</classname>
- <description>
- onCurrentDateSelect event handler
- </description>
- </property>
- <property>
- <name>onexpand</name>
- <classname>java.lang.String</classname>
- <description>
- onExpand event handler
- </description>
- </property>
- <property>
- <name>oncollapse</name>
- <classname>java.lang.String</classname>
- <description>
- onCollapse event handler
- </description>
- </property>
- <property>
- <name>ondatemouseover</name>
- <classname>java.lang.String</classname>
- <description>
- onDateMouseOver event handler
- </description>
- </property>
- <property>
- <name>ondatemouseout</name>
- <classname>java.lang.String</classname>
- <description>
- onDateMouseOut event handler
- </description>
- </property>
-
- <property>
- <name>oninputchange</name>
- <classname>java.lang.String</classname>
- <description>
- input onChange event handler
- </description>
- </property>
- <property>
- <name>oninputselect</name>
- <classname>java.lang.String</classname>
- <description>
- input onSelect event handler
- </description>
- </property>
- <property>
- <name>oninputfocus</name>
- <classname>java.lang.String</classname>
- <description>
- input onFocus event handler
- </description>
- </property>
- <property>
- <name>oninputblur</name>
- <classname>java.lang.String</classname>
- <description>
- input onBlur event handler
- </description>
- </property>
- <property>
- <name>oninputclick</name>
- <classname>java.lang.String</classname>
- <description>
- input onClick event handler
- </description>
- </property>
- <property>
- <name>oninputkeypress</name>
- <classname>java.lang.String</classname>
- <description>
- input onKeyPress event handler
- </description>
- </property>
- <property>
- <name>oninputkeydown</name>
- <classname>java.lang.String</classname>
- <description>
- input onKeyDown event handler
- </description>
- </property>
- <property>
- <name>oninputkeyup</name>
- <classname>java.lang.String</classname>
- <description>
- input onKeyUp event handler
- </description>
- </property>
-
- <property hidden="true">
- <name>localValueSet</name>
- <description>localValueSet</description>
- </property>
- <property hidden="true">
- <name>valid</name>
- <description>valid</description>
- </property>
- <property hidden="true">
- <name>valid</name>
- <description>valid</description>
- </property>
-
- <property>
- <name>ajaxSingle</name>
- <classname>boolean</classname>
- <description>if "true", submits ONLY one field/link, instead of all form controls</description>
- <defaultvalue>true</defaultvalue>
- </property>
-
- </component>
- &listeners;
-</components>
-
Copied: tags/3.1.0-rc5/ui/calendar/src/main/config/component/calendar.xml (from rev 2787, trunk/ui/calendar/src/main/config/component/calendar.xml)
===================================================================
--- tags/3.1.0-rc5/ui/calendar/src/main/config/component/calendar.xml (rev 0)
+++ tags/3.1.0-rc5/ui/calendar/src/main/config/component/calendar.xml 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,453 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd"
+[
+<!ENTITY listeners SYSTEM "listener.ent">
+]
+>
+<components>
+ <component>
+ <name>org.richfaces.Calendar</name>
+ <family>org.richfaces.Calendar</family>
+ <classname>org.richfaces.component.html.HtmlCalendar</classname>
+ <superclass>org.richfaces.component.UICalendar</superclass>
+ <test>
+ <classname>
+ org.richfaces.component.html.HtmlCalendarTest
+ </classname>
+ <superclassname>
+ org.ajax4jsf.tests.AbstractAjax4JsfTestCase
+ </superclassname>
+ </test>
+ <description>
+ <![CDATA[
+ ]]>
+ </description>
+ <renderer generate="true" override="true">
+ <name>org.richfaces.CalendarRenderer</name>
+ <template>org/richfaces/htmlCalendar.jspx</template>
+ </renderer>
+ <tag>
+ <name>calendar</name>
+ <classname>org.richfaces.taglib.CalendarTag</classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ </superclass>
+
+ <test>
+ <classname>
+ org.richfaces.component.html.HtmlCalendarTest
+ </classname>
+ <superclassname>
+ org.ajax4jsf.tests.AbstractAjax4JsfTestCase
+ </superclassname>
+ </test>
+ </tag>
+ <!--
+ <taghandler>
+ <classname>org.ajax4jsf.tag.TestHandler</classname>
+ </taghandler>
+ -->
+ &ui_component_attributes;
+ &ajax_component_attributes;
+ &ui_input_attributes;
+ &ui_output_attributes;
+ <property>
+ <name>width</name>
+ <classname>java.lang.String</classname>
+ <description>Defines a width of the calendar</description>
+ <defaultvalue>"400px;"</defaultvalue>
+ </property>
+ <property>
+ <name>height</name>
+ <classname>java.lang.String</classname>
+ <description>Defines a height of the calendar</description>
+ <defaultvalue>"250px"</defaultvalue>
+ </property>
+ <property elonly="true">
+ <name>dataModel</name>
+ <classname>org.richfaces.model.CalendarDataModel</classname>
+ <description>
+ Used to provide data for calendar elements. If data is
+ not provided, all Data Model related functions are
+ disabled
+ </description>
+ </property>
+ <property elonly="true">
+ <name>locale</name>
+ <classname>java.util.Locale</classname>
+ <description>Used for locale definition</description>
+ <defaultvalue>getDefaultLocale()</defaultvalue>
+ </property>
+ <property elonly="true">
+ <name>timeZone</name>
+ <classname>java.util.TimeZone</classname>
+ <description>
+ Used for current date calculations
+ </description>
+ <defaultvalue>getDefaultTimeZone()</defaultvalue>
+ </property>
+ <property elonly="true">
+ <name>preloadDateRangeBegin</name>
+ <classname>java.util.Date</classname>
+ <description>
+ Define the initial range of date which will be loaded to
+ client from dataModel under rendering
+ </description>
+ <defaultvalue>
+ getDefaultPreloadBegin(getCurrentDateOrDefault())
+ </defaultvalue>
+ </property>
+ <property elonly="true">
+ <name>preloadDateRangeEnd</name>
+ <classname>java.util.Date</classname>
+ <description>
+ Defines the last range of date which will be loaded to
+ client from dataModel under rendering
+ </description>
+ <defaultvalue>
+ getDefaultPreloadEnd(getCurrentDateOrDefault())
+ </defaultvalue>
+ </property>
+ <property elonly="true">
+ <name>currentDate</name>
+ <classname>java.util.Date</classname>
+ <description>Defines current date</description>
+ <defaultvalue>
+ java.util.Calendar.getInstance(getTimeZone()).getTime()
+ </defaultvalue>
+ </property>
+ <property>
+ <name>currentDateChangeListener</name>
+ <classname>javax.faces.el.MethodBinding</classname>
+ <description>MethodBinding representing an action listener method that will be notified after date selection</description>
+ </property>
+ <property>
+ <name>datePattern</name>
+ <classname>java.lang.String</classname>
+ <description>Defines date pattern</description>
+ <defaultvalue>"MMM d, yyyy"</defaultvalue>
+ </property>
+ <property>
+ <name>scrollMode</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Valid values are "ajax" and "client"
+ </description>
+ <defaultvalue>"ajax"</defaultvalue>
+ </property>
+ <property>
+ <name>popup</name>
+ <classname>boolean</classname>
+ <description>
+ If "true" calendar will be rendered initially
+ as hidden with additional elements for calling as popup
+ </description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property>
+ <name>disabled</name>
+ <classname>boolean</classname>
+ <description>
+ If "true", rendered is disabled. In
+ "popup" mode both controls are disabled
+ </description>
+ <defaultvalue>false</defaultvalue>
+ </property>
+ <property>
+ <name>jointPoint</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Set the corner of the button for the popup to be
+ connected with (top-left, top-right, bottom-left
+ (Default), bottom-right, auto)
+ </description>
+ <defaultvalue>"bottom-left"</defaultvalue>
+ </property>
+ <property>
+ <name>direction</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Defines direction of the calendar popup (top-left,
+ top-right, bottom-left, bottom-right (Default), auto)
+ </description>
+ <defaultvalue>"bottom-right"</defaultvalue>
+ </property>
+ <property>
+ <name>weekDayLabels</name>
+ <classname>java.lang.Object</classname>
+ <description>
+ List of the day names displays on the days bar in the
+ following way "Sun, Mon, Tue, Wed, …"
+ </description>
+ </property>
+ <property>
+ <name>weekDayLabelsShort</name>
+ <classname>java.lang.Object</classname>
+ <description>
+ Attribute that allows to customize short names of the
+ weeks. Should accept list with the weeks names.
+ </description>
+ </property>
+ <property>
+ <name>monthLabels</name>
+ <classname>java.lang.Object</classname>
+ <description>
+ Attribute that allows to customize names of the months.
+ Should accept list with the month names
+ </description>
+ </property>
+ <property>
+ <name>monthLabelsShort</name>
+ <classname>java.lang.Object</classname>
+ <description>
+ Attribute that allows to customize short names of the
+ months. Should accept list with the month names
+ </description>
+ </property>
+ <property>
+ <name>buttonLabel</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Defines label for the popup button element
+ </description>
+ <defaultvalue>"popupButton"</defaultvalue>
+ </property>
+ <property>
+ <name>toolTipMode</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Used to specify mode to load tooltips. Valid values are
+ "none", "single" and
+ "batch"
+ </description>
+ <defaultvalue>"batch"</defaultvalue>
+ </property>
+ <property>
+ <name>boundaryDatesMode</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Used for the dates boundaries in the list. Valid values
+ are "inactive" (Default) – dates inactive and
+ gray colored, "scroll" – boundaries work as
+ month scrolling controls, and "select" –
+ boundaries work in the same way as "scroll"
+ but with the date clicked selection
+ </description>
+ <defaultvalue>"inactive"</defaultvalue>
+ </property>
+ <property>
+ <name>enableManualInput</name>
+ <classname>boolean</classname>
+ <description>
+ If "true" calendar input will be editable and
+ it will be possible to change the date manualy. If
+ "false" value for this attribute makes a text
+ field "read-only", so the value can be changed
+ only from a handle
+ </description>
+ <defaultvalue>false</defaultvalue>
+ </property>
+ <property>
+ <name>showInput</name>
+ <classname>boolean</classname>
+ <description>
+ "false" value for this attribute makes text
+ field invisible. If "true" - input field will
+ be shown
+ </description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property>
+ <name>style</name>
+ <classname>java.lang.String</classname>
+ <description>
+ CSS style(s) is/are to be applied when this component is
+ rendered
+ </description>
+ </property>
+ <property>
+ <name>styleClass</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Corresponds to the HTML class attribute
+ </description>
+ </property>
+ <property>
+ <name>inputStyle</name>
+ <classname>java.lang.String</classname>
+ <description>Style attribute for text field</description>
+ </property>
+ <property>
+ <name>inputClass</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Style Class attribute for a text field
+ </description>
+ </property>
+ <property>
+ <name>zindex</name>
+ <classname>int</classname>
+ <description>
+ Attribute is similar to the standard HTML attribute and
+ can specify window placement relative to the content
+ </description>
+ <defaultvalue>3</defaultvalue>
+ </property>
+
+ <property>
+ <name>requiredMessage</name>
+ <classname>java.lang.String</classname>
+ <description>
+ A ValueExpression enabled attribute that, if present,
+ will be used as the text of the validation message for
+ the "required" facility, if the "required" facility is
+ used
+ </description>
+ </property>
+ <property>
+ <name>validatorMessage</name>
+ <classname>java.lang.String</classname>
+ <description>
+ A ValueExpression enabled attribute that, if present,
+ will be used as the text of the validator message,
+ replacing any message that comes from the validator
+ </description>
+ </property>
+ <property>
+ <name>converterMessage</name>
+ <classname>java.lang.String</classname>
+ <description>
+ A ValueExpression enabled attribute that, if present,
+ will be used as the text of the converter message,
+ replacing any message that comes from the converter
+ </description>
+ </property>
+
+ <property>
+ <name>ondateselect</name>
+ <classname>java.lang.String</classname>
+ <description>
+ onDateSelect event handler
+ </description>
+ </property>
+ <property>
+ <name>oncurrentdateselect</name>
+ <classname>java.lang.String</classname>
+ <description>
+ onCurrentDateSelect event handler
+ </description>
+ </property>
+ <property>
+ <name>onexpand</name>
+ <classname>java.lang.String</classname>
+ <description>
+ onExpand event handler
+ </description>
+ </property>
+ <property>
+ <name>oncollapse</name>
+ <classname>java.lang.String</classname>
+ <description>
+ onCollapse event handler
+ </description>
+ </property>
+ <property>
+ <name>ondatemouseover</name>
+ <classname>java.lang.String</classname>
+ <description>
+ onDateMouseOver event handler
+ </description>
+ </property>
+ <property>
+ <name>ondatemouseout</name>
+ <classname>java.lang.String</classname>
+ <description>
+ onDateMouseOut event handler
+ </description>
+ </property>
+
+ <property>
+ <name>oninputchange</name>
+ <classname>java.lang.String</classname>
+ <description>
+ input onChange event handler
+ </description>
+ </property>
+ <property>
+ <name>oninputselect</name>
+ <classname>java.lang.String</classname>
+ <description>
+ input onSelect event handler
+ </description>
+ </property>
+ <property>
+ <name>oninputfocus</name>
+ <classname>java.lang.String</classname>
+ <description>
+ input onFocus event handler
+ </description>
+ </property>
+ <property>
+ <name>oninputblur</name>
+ <classname>java.lang.String</classname>
+ <description>
+ input onBlur event handler
+ </description>
+ </property>
+ <property>
+ <name>oninputclick</name>
+ <classname>java.lang.String</classname>
+ <description>
+ input onClick event handler
+ </description>
+ </property>
+ <property>
+ <name>oninputkeypress</name>
+ <classname>java.lang.String</classname>
+ <description>
+ input onKeyPress event handler
+ </description>
+ </property>
+ <property>
+ <name>oninputkeydown</name>
+ <classname>java.lang.String</classname>
+ <description>
+ input onKeyDown event handler
+ </description>
+ </property>
+ <property>
+ <name>oninputkeyup</name>
+ <classname>java.lang.String</classname>
+ <description>
+ input onKeyUp event handler
+ </description>
+ </property>
+
+ <property hidden="true">
+ <name>localValueSet</name>
+ <description>localValueSet</description>
+ </property>
+ <property hidden="true">
+ <name>valid</name>
+ <description>valid</description>
+ </property>
+ <property hidden="true">
+ <name>valid</name>
+ <description>valid</description>
+ </property>
+
+ <property>
+ <name>ajaxSingle</name>
+ <classname>boolean</classname>
+ <description>if "true", submits ONLY one field/link, instead of all form controls</description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+
+ <property hidden="true">
+ <name>data</name>
+ <classname>java.lang.Object</classname>
+ </property>
+ </component>
+ &listeners;
+</components>
+
Deleted: tags/3.1.0-rc5/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/css/dataFilterSlider.xcss
===================================================================
--- trunk/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/css/dataFilterSlider.xcss 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/css/dataFilterSlider.xcss 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,95 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<f:template xmlns:f='http:/jsf.exadel.com/template'
- xmlns:u='http:/jsf.exadel.com/template/util'
- xmlns="http://www.w3.org/1999/xhtml" >
- <f:verbatim><![CDATA[
-
-
- .slider-container{
- background-color:transparent;
- width:100%;
- position:relative;
- }
-
- .range{
- background-color:transparent;
- height: 10px;
- overflow:hidden;
- float:left;
- border-width: 1px;
- border-style: solid;
- }
-
- .range-decor{
- height : 100%;
- width : 100%;
- border-width: 1px;
- border-style: solid;
- }
-
- .trailer{
- background-color:transparent;
- background-position:top right;
- background-repeat:repeat-x;
- height: 10px;
- }
-
- .track{
- background-color:transparent;
- height: 8px;
- overflow:hidden;
- position:absolute;
- }
-
- .handle{
- position: absolute;
- width: 10px;
- height: 8px;
- background-color:transparent;
- }
-
- .slider-input-field{
- border: 1px solid;
- background: left top repeat-x;
- padding: 0px 0px 0px 3px;
- width : 40px;
- margin: 0px 0px 0px 10px;
- float:left;
- }
-
-
-]]>
-</f:verbatim>
-
-<u:selector name=".range">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.SliderTrackGradient" />
- </u:style>
- <u:style name="border-color" skin="panelBorderColor"/>
-</u:selector>
-
-<u:selector name=".range">
- <u:style name="border-color" skin="subBorderColor"/>
-</u:selector>
-
-<u:selector name=".trailer">
- <u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/images/sldr_trailer3_bg.gif" />
- </u:style>
-</u:selector>
-
-<u:selector name=".slider-input-field">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.SliderFieldGradient" />
- </u:style>
- <u:style name="background-color" skin="controlBackgroundColor"/>
- <u:style name="font-family" skin="generalFamilyFont"/>
- <u:style name="font-size" skin="generalSizeFont"/>
- <u:style name="color" skin="controlTextColor"/>
- <u:style name="border-color" skin="panelBorderColor" />
- <u:style name="border-bottom-color" skin="subBorderColor" />
- <u:style name="border-right-color" skin="subBorderColor" />
-</u:selector>
-
-
-</f:template>
Copied: tags/3.1.0-rc5/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/css/dataFilterSlider.xcss (from rev 2787, trunk/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/css/dataFilterSlider.xcss)
===================================================================
--- tags/3.1.0-rc5/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/css/dataFilterSlider.xcss (rev 0)
+++ tags/3.1.0-rc5/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/css/dataFilterSlider.xcss 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template xmlns:f='http:/jsf.exadel.com/template'
+ xmlns:u='http:/jsf.exadel.com/template/util'
+ xmlns="http://www.w3.org/1999/xhtml" >
+ <f:verbatim><![CDATA[
+
+
+ .slider-container{
+ background-color:transparent;
+ width:100%;
+ position:relative;
+ }
+
+ .range{
+ background-color:transparent;
+ height: 10px;
+ overflow:hidden;
+ float:left;
+ border-width: 1px;
+ border-style: solid;
+ }
+
+ .range-decor{
+ height : 100%;
+ width : 100%;
+ border-width: 1px;
+ border-style: solid;
+ }
+
+ .trailer{
+ background-color:transparent;
+ background-position:top right;
+ background-repeat:repeat-x;
+ height: 10px;
+ }
+
+ .track{
+ background-color:transparent;
+ height: 8px;
+ overflow:hidden;
+ position:absolute;
+ }
+
+ .handle{
+ position: absolute;
+ width: 10px;
+ height: 8px;
+ background-color:transparent;
+ line-height: 1px;
+ font-size: 1px;
+ }
+
+ .slider-input-field{
+ border: 1px solid;
+ background: left top repeat-x;
+ padding: 0px 0px 0px 3px;
+ width : 40px;
+ margin: 0px 0px 0px 10px;
+ float:left;
+ }
+
+
+]]>
+</f:verbatim>
+
+<u:selector name=".range">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.SliderTrackGradient" />
+ </u:style>
+ <u:style name="border-color" skin="panelBorderColor"/>
+</u:selector>
+
+<u:selector name=".range">
+ <u:style name="border-color" skin="subBorderColor"/>
+</u:selector>
+
+<u:selector name=".trailer">
+ <u:style name="background-image">
+ <f:resource f:key="/org/richfaces/renderkit/html/images/sldr_trailer3_bg.gif" />
+ </u:style>
+</u:selector>
+
+<u:selector name=".slider-input-field">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.SliderFieldGradient" />
+ </u:style>
+ <u:style name="background-color" skin="controlBackgroundColor"/>
+ <u:style name="font-family" skin="generalFamilyFont"/>
+ <u:style name="font-size" skin="generalSizeFont"/>
+ <u:style name="color" skin="controlTextColor"/>
+ <u:style name="border-color" skin="panelBorderColor" />
+ <u:style name="border-bottom-color" skin="subBorderColor" />
+ <u:style name="border-right-color" skin="subBorderColor" />
+</u:selector>
+
+
+</f:template>
Deleted: tags/3.1.0-rc5/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
===================================================================
--- trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,76 +0,0 @@
-/**
- * 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.richfaces.event;
-
-import org.ajax4jsf.event.AjaxActionEvent;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesListener;
-
-/** @author Wesley Hales */
-public class DataScrollerEvent extends AjaxActionEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 2657353903701932561L;
- private String oldScrolVal;
- private String newScrolVal;
-
- /**
- * Creates a new ScrollerEvent.
- *
- * @param component the source of the event
- * @param thisOldScrolVal the previously showing item identifier
- * @param thisNewScrolVal the currently showing item identifier
- */
- public DataScrollerEvent(UIComponent component, String thisOldScrolVal,
- String thisNewScrolVal) {
- super(component);
- oldScrolVal = thisOldScrolVal;
- newScrolVal = thisNewScrolVal;
- }
-
- public String getOldScrolVal() {
- return oldScrolVal;
- }
-
- public String getNewScrolVal() {
- return newScrolVal;
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- return super.isAppropriateListener(listener)
- || (listener instanceof DataScrollerListener);
- }
-
- /**
- * Delivers this event to the SliderListener.
- *
- * @param listener the slider listener
- */
- public void processListener(FacesListener listener) {
- if (super.isAppropriateListener(listener)) {
- super.processListener(listener);
- }
- }
-}
Copied: tags/3.1.0-rc5/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java (from rev 2789, trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java)
===================================================================
--- tags/3.1.0-rc5/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java (rev 0)
+++ tags/3.1.0-rc5/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,79 @@
+/**
+ * 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.richfaces.event;
+
+import org.ajax4jsf.event.AjaxActionEvent;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesListener;
+
+/** @author Wesley Hales */
+public class DataScrollerEvent extends AjaxActionEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2657353903701932561L;
+ private String oldScrolVal;
+ private String newScrolVal;
+
+ /**
+ * Creates a new ScrollerEvent.
+ *
+ * @param component the source of the event
+ * @param thisOldScrolVal the previously showing item identifier
+ * @param thisNewScrolVal the currently showing item identifier
+ */
+ public DataScrollerEvent(UIComponent component, String thisOldScrolVal,
+ String thisNewScrolVal) {
+ super(component);
+ oldScrolVal = thisOldScrolVal;
+ newScrolVal = thisNewScrolVal;
+ }
+
+ public String getOldScrolVal() {
+ return oldScrolVal;
+ }
+
+ public String getNewScrolVal() {
+ return newScrolVal;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return super.isAppropriateListener(listener)
+ || (listener instanceof DataScrollerListener);
+ }
+
+ /**
+ * Delivers this event to the SliderListener.
+ *
+ * @param listener the slider listener
+ */
+ public void processListener(FacesListener listener) {
+ if (listener instanceof DataScrollerListener) {
+ DataScrollerListener dataScrollerListener = (DataScrollerListener) listener;
+ dataScrollerListener.processScroller(this);
+ } else if (super.isAppropriateListener(listener)) {
+ super.processListener(listener);
+ }
+ }
+}
Deleted: tags/3.1.0-rc5/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java
===================================================================
--- trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,441 +0,0 @@
-/**
- *
- */
-package org.richfaces.renderkit.html;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.component.NamingContainer;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.component.UIScrollableDataTable;
-
-/**
- * bean to store current {@link com.exadel.vcp.components.datagrid.UIDataGrid } information
- * in request map. For nested grids, it support push/pop state saving.
- * In {@link javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)} method
- * must be created instance of this bean , or, if it already exist in request map - push information.
- * at the end of encodeEnd call, bean must be pop information or removed.
- * @author shura
- *
- */
-public class ScrollableDataTableRendererState implements Serializable {
-
- public static final String DATA_GRID_RENDERER_STATE = ScrollableDataTableRendererState.class.getName();
-
- private boolean fake;
-
- private HashSet ids = new HashSet();
-
- private String rowClasses[];
-
- private int rowClassesSize;
-
- private String columnClasses[];
-
- private int columnClassesSize;
-
- private int _rowIndex = 0;
-
- private int _cellIndex = 0;
-
- private int _columns = 0;
-
- private Collection collection;
-
- private Integer sepOffset;
-
- private String _cell_id_prefix;
-
- private int sumWidth = 0;
-
- private boolean header = false;
-
- private String _column_type;
-
- private int _frozenColumnCount = -1;
-
- private AjaxContext ajaxContext;
-
- private String part;
-
- private boolean _frozenPart = false;
-
- private ResponseWriter writer;
-
- private UIScrollableDataTable _grid;
-
- private String clientId;
-
- private String _cachedClientId;
-
- private ScrollableDataTableRendererState _previousState = null;
-
- private Object rowKey;
-
- private static final long serialVersionUID = 2129605586975025578L;
-
-
- /**
- * Get current grid state from JSF context
- * @param context
- * @return current data grid state, or null if not saved.
- */
- public static ScrollableDataTableRendererState getRendererState(FacesContext context) throws FacesException {
- if(null == context){
- throw new NullPointerException("Context for grid state is null");
- }
- ScrollableDataTableRendererState state = (ScrollableDataTableRendererState) context.getExternalContext().getRequestMap().get(DATA_GRID_RENDERER_STATE);
-// if( null == state){
-// throw new FacesException("State for current grid not stored in context");
-// }
- return state;
- }
-
- /**
- * Create new state for current grid. If state exist, store previsius in field of created.
- * @param context
- * @param grid
- * @return new state for grid.
- */
- public static ScrollableDataTableRendererState createState(FacesContext context, UIScrollableDataTable grid){
- if(null == context){
- throw new NullPointerException("Context for grid state is null");
- }
- ScrollableDataTableRendererState oldState = getRendererState(context);
- ScrollableDataTableRendererState state = new ScrollableDataTableRendererState(context,oldState,grid);
- state.setColumnClasses(grid.getAttributes().get("columnClasses"));
- state.setRowClasses(grid.getAttributes().get("rowClasses"));
- context.getExternalContext().getRequestMap().put(DATA_GRID_RENDERER_STATE,state);
- return state;
- }
-
- /**
- * Restore previsius state for gred, or clear request parameter.
- * @param context
- */
- public static void restoreState(FacesContext context) {
- if (null == context) {
- throw new NullPointerException("Context for grid state is null");
- }
- ScrollableDataTableRendererState state = getRendererState(context);
- if (null == state) {
- throw new FacesException(
- "State for current grid not saved in context");
- }
- ScrollableDataTableRendererState previsiosState = state.getPreviousState();
- if (null != previsiosState) {
- context.getExternalContext().getRequestMap().put(DATA_GRID_RENDERER_STATE,
- previsiosState);
- } else {
- context.getExternalContext().getRequestMap().remove(DATA_GRID_RENDERER_STATE);
- }
- }
- /**
- * Create state for current grid ( and store previsios state in field ).
- * @param previsiosState
- */
- public ScrollableDataTableRendererState(FacesContext context, ScrollableDataTableRendererState previsiosState, UIScrollableDataTable grid) {
- super();
- _grid = grid;
- _cachedClientId = grid.getClientId(context);
- clientId = _cachedClientId;
- _previousState = previsiosState;
- if(AjaxRendererUtils.isAjaxRequest(context)){
- }
-
- Map attrs = grid.getAttributes();
- }
-
- public String getCurrentCellId(FacesContext context){
- return getGrid().getClientId(context)+NamingContainer.SEPARATOR_CHAR+"row"+getRowIndex()+
- NamingContainer.SEPARATOR_CHAR+"col"+getCellIndex();
- }
-
- /**
- * @return Returns the cellIndex.
- */
- public int getCellIndex() {
- return _cellIndex;
- }
-
- /**
- * @param cellIndex The cellIndex to set.
- */
- public void setCellIndex(int cellIndex) {
- _cellIndex = cellIndex;
- }
-
- /**
- * Increment cells counter
- * @return next cell number.
- */
-
- public int nextCell(){
- return ++_cellIndex;
- }
-
-
- /**
- * @return Returns the columns.
- */
- public int getColumns() {
- return _columns;
- }
-
- /**
- * @param columns The columns to set.
- */
- public void setColumns(int columns) {
- _columns = columns;
- }
-
- /**
- * @return Returns the grid.
- */
- public UIScrollableDataTable getGrid() {
- return _grid;
- }
-
- /**
- * @param grid The grid to set.
- */
- public void setGrid(UIScrollableDataTable grid) {
- _grid = grid;
- }
-
- /**
- * @return Returns the previsiosState.
- */
- public ScrollableDataTableRendererState getPreviousState() {
- return _previousState;
- }
-
- /**
- * @param previsiosState The previsiosState to set.
- */
- public void setPreviousState(ScrollableDataTableRendererState previsiosState) {
- _previousState = previsiosState;
- }
-
- /**
- * @return Returns the rowIndex.
- */
- public int getRowIndex() {
- if(_grid.getRows() != 0 && _rowIndex >= _grid.getRows()){
- _rowIndex = 0;
- }
- return _rowIndex;
- }
-
- /**
- * Increment current row counter.
- * @return new row number.
- */
- public int nextRow(){
- _rowIndex = _rowIndex + 1;
- return _rowIndex;
- }
-
- /**
- * @param rowIndex The rowIndex to set.
- */
- public void setRowIndex(int rowIndex) {
- _rowIndex = rowIndex;
- }
-
-
- /**
- * @return the _cachedClientId
- */
- public String getCachedClientId() {
- return _cachedClientId;
- }
-
-
- private StringBuffer buffer = new StringBuffer();
-
- /**
- * @return the buffer
- */
- public StringBuffer getBuffer() {
- buffer.setLength(0);
- return buffer;
- }
-
- /**
- * @return the rowKey
- */
- public Object getRowKey() {
- return rowKey;
- }
-
- /**
- * @param rowKey the rowKey to set
- */
- public void setRowKey(Object rowKey) {
- this.rowKey = rowKey;
- }
-
- public boolean isFrozenColumn() {
- return _frozenColumnCount <= 0 ? false:true;
- }
-
- public void setFrozenColumnCount(int columnCount) {
- _frozenColumnCount = columnCount;
- }
-
- public int getFrozenColumnCount() {
- return _frozenColumnCount;
- }
-
- public boolean isFrozenPart() {
- return _frozenPart;
- }
-
- public void setFrozenPart(boolean part) {
- _frozenPart = part;
- }
-
- public String getCellIdPrefix() {
- return _cell_id_prefix;
- }
-
- public void setCellIdPrefix(String _id_prefix) {
- this._cell_id_prefix = _id_prefix;
- }
-
- public String getColumnType() {
- return _column_type;
- }
-
- public void setColumType(String _column_type) {
- this._column_type = _column_type;
- }
-
- public AjaxContext getAjaxContext() {
- return ajaxContext;
- }
-
- public void setAjaxContext(AjaxContext ajaxContext) {
- this.ajaxContext = ajaxContext;
- }
-
- public ResponseWriter getWriter() {
- return writer;
- }
-
- public void setWriter(ResponseWriter writer) {
- this.writer = writer;
- }
-
- public String getClientId(){
- return clientId;
- }
-
- public void setClientId(String clientId){
- this.clientId = clientId;
- }
-
- public boolean isHeader() {
- return header;
- }
-
- public void setHeader(boolean header) {
- this.header = header;
- }
-
- public String getPart() {
- return part;
- }
-
- public void setPart(String part) {
- this.part = part;
- }
-
- public int getSumWidth() {
- return sumWidth;
- }
-
- public void setSumWidth(int sumWidth) {
- this.sumWidth = sumWidth;
- }
-
- public Integer getSepOffset() {
- return sepOffset;
- }
-
- public void setSepOffset(Integer sepOffset) {
- this.sepOffset = sepOffset;
- }
-
- public Collection getCollection() {
- return collection;
- }
-
- public void setCollection(Collection collection) {
- this.collection = collection;
- }
-
- public boolean isFake() {
- return fake;
- }
-
- public void setFake(boolean fake) {
- this.fake = fake;
- }
-
- public String getColumnHeaderClass() {
- return "";
- }
-
-
- public String getColumnClass() {
- return getColumnClass(getCellIndex());
- }
-
- public String getColumnClass(int index) {
- if(columnClasses != null) {
- return columnClasses[index % columnClassesSize];
- } else {
- return "";
- }
- }
-
- public void setColumnClasses(Object columnClasses) {
- if(columnClasses != null) {
- this.columnClasses = ((String)columnClasses).split(",");
- columnClassesSize = this.columnClasses.length;
- }
- }
-
- public String getRowClass(int index) {
- if(rowClasses != null) {
- return rowClasses[index % rowClassesSize];
- } else {
- return "";
- }
- }
-
- public void setRowClasses(Object rowClasses) {
- if(rowClasses != null) {
- this.rowClasses = ((String)rowClasses).split(",");
- rowClassesSize = this.rowClasses.length;
- }
- }
-
- public HashSet getIds() {
- return ids;
- }
-
- public void addId(String id) {
- ids.add(id);
- }
-}
Copied: tags/3.1.0-rc5/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java (from rev 2787, trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java)
===================================================================
--- tags/3.1.0-rc5/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java (rev 0)
+++ tags/3.1.0-rc5/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,437 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.NamingContainer;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.component.UIScrollableDataTable;
+
+/**
+ * bean to store current {@link com.exadel.vcp.components.datagrid.UIDataGrid } information
+ * in request map. For nested grids, it support push/pop state saving.
+ * In {@link javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)} method
+ * must be created instance of this bean , or, if it already exist in request map - push information.
+ * at the end of encodeEnd call, bean must be pop information or removed.
+ * @author shura
+ *
+ */
+public class ScrollableDataTableRendererState implements Serializable {
+
+ public static final String DATA_GRID_RENDERER_STATE = ScrollableDataTableRendererState.class.getName();
+
+ private boolean fake;
+
+ private HashSet ids = new HashSet();
+
+ private String rowClasses[];
+
+ private int rowClassesSize;
+
+ private String columnClasses[];
+
+ private int columnClassesSize;
+
+ private int _rowIndex = 0;
+
+ private int _cellIndex = 0;
+
+ private int _columns = 0;
+
+ private Collection collection;
+
+ private Integer sepOffset;
+
+ private String _cell_id_prefix;
+
+ private int sumWidth = 0;
+
+ private boolean header = false;
+
+ private String _column_type;
+
+ private int _frozenColumnCount = -1;
+
+ private AjaxContext ajaxContext;
+
+ private String part;
+
+ private boolean _frozenPart = false;
+
+ private ResponseWriter writer;
+
+ private UIScrollableDataTable _grid;
+
+ private String clientId;
+
+ private String _cachedClientId;
+
+ private ScrollableDataTableRendererState _previousState = null;
+
+ private Object rowKey;
+
+ private static final long serialVersionUID = 2129605586975025578L;
+
+
+ /**
+ * Get current grid state from JSF context
+ * @param context
+ * @return current data grid state, or null if not saved.
+ */
+ public static ScrollableDataTableRendererState getRendererState(FacesContext context) throws FacesException {
+ if(null == context){
+ throw new NullPointerException("Context for grid state is null");
+ }
+ ScrollableDataTableRendererState state = (ScrollableDataTableRendererState) context.getExternalContext().getRequestMap().get(DATA_GRID_RENDERER_STATE);
+// if( null == state){
+// throw new FacesException("State for current grid not stored in context");
+// }
+ return state;
+ }
+
+ /**
+ * Create new state for current grid. If state exist, store previsius in field of created.
+ * @param context
+ * @param grid
+ * @return new state for grid.
+ */
+ public static ScrollableDataTableRendererState createState(FacesContext context, UIScrollableDataTable grid){
+ if(null == context){
+ throw new NullPointerException("Context for grid state is null");
+ }
+ ScrollableDataTableRendererState oldState = getRendererState(context);
+ ScrollableDataTableRendererState state = new ScrollableDataTableRendererState(context,oldState,grid);
+ state.setColumnClasses(grid.getAttributes().get("columnClasses"));
+ state.setRowClasses(grid.getAttributes().get("rowClasses"));
+ context.getExternalContext().getRequestMap().put(DATA_GRID_RENDERER_STATE,state);
+ return state;
+ }
+
+ /**
+ * Restore previsius state for gred, or clear request parameter.
+ * @param context
+ */
+ public static void restoreState(FacesContext context) {
+ if (null == context) {
+ throw new NullPointerException("Context for grid state is null");
+ }
+ ScrollableDataTableRendererState state = getRendererState(context);
+ if (null == state) {
+ throw new FacesException(
+ "State for current grid not saved in context");
+ }
+ ScrollableDataTableRendererState previsiosState = state.getPreviousState();
+ if (null != previsiosState) {
+ context.getExternalContext().getRequestMap().put(DATA_GRID_RENDERER_STATE,
+ previsiosState);
+ } else {
+ context.getExternalContext().getRequestMap().remove(DATA_GRID_RENDERER_STATE);
+ }
+ }
+ /**
+ * Create state for current grid ( and store previsios state in field ).
+ * @param previsiosState
+ */
+ public ScrollableDataTableRendererState(FacesContext context, ScrollableDataTableRendererState previsiosState, UIScrollableDataTable grid) {
+ super();
+ _grid = grid;
+ _cachedClientId = grid.getClientId(context);
+ clientId = _cachedClientId;
+ _previousState = previsiosState;
+ }
+
+ public String getCurrentCellId(FacesContext context){
+ return getGrid().getClientId(context)+NamingContainer.SEPARATOR_CHAR+"row"+getRowIndex()+
+ NamingContainer.SEPARATOR_CHAR+"col"+getCellIndex();
+ }
+
+ /**
+ * @return Returns the cellIndex.
+ */
+ public int getCellIndex() {
+ return _cellIndex;
+ }
+
+ /**
+ * @param cellIndex The cellIndex to set.
+ */
+ public void setCellIndex(int cellIndex) {
+ _cellIndex = cellIndex;
+ }
+
+ /**
+ * Increment cells counter
+ * @return next cell number.
+ */
+
+ public int nextCell(){
+ return ++_cellIndex;
+ }
+
+
+ /**
+ * @return Returns the columns.
+ */
+ public int getColumns() {
+ return _columns;
+ }
+
+ /**
+ * @param columns The columns to set.
+ */
+ public void setColumns(int columns) {
+ _columns = columns;
+ }
+
+ /**
+ * @return Returns the grid.
+ */
+ public UIScrollableDataTable getGrid() {
+ return _grid;
+ }
+
+ /**
+ * @param grid The grid to set.
+ */
+ public void setGrid(UIScrollableDataTable grid) {
+ _grid = grid;
+ }
+
+ /**
+ * @return Returns the previsiosState.
+ */
+ public ScrollableDataTableRendererState getPreviousState() {
+ return _previousState;
+ }
+
+ /**
+ * @param previsiosState The previsiosState to set.
+ */
+ public void setPreviousState(ScrollableDataTableRendererState previsiosState) {
+ _previousState = previsiosState;
+ }
+
+ /**
+ * @return Returns the rowIndex.
+ */
+ public int getRowIndex() {
+ if(_grid.getRows() != 0 && _rowIndex >= _grid.getRows()){
+ _rowIndex = 0;
+ }
+ return _rowIndex;
+ }
+
+ /**
+ * Increment current row counter.
+ * @return new row number.
+ */
+ public int nextRow(){
+ _rowIndex = _rowIndex + 1;
+ return _rowIndex;
+ }
+
+ /**
+ * @param rowIndex The rowIndex to set.
+ */
+ public void setRowIndex(int rowIndex) {
+ _rowIndex = rowIndex;
+ }
+
+
+ /**
+ * @return the _cachedClientId
+ */
+ public String getCachedClientId() {
+ return _cachedClientId;
+ }
+
+
+ private StringBuffer buffer = new StringBuffer();
+
+ /**
+ * @return the buffer
+ */
+ public StringBuffer getBuffer() {
+ buffer.setLength(0);
+ return buffer;
+ }
+
+ /**
+ * @return the rowKey
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ /**
+ * @param rowKey the rowKey to set
+ */
+ public void setRowKey(Object rowKey) {
+ this.rowKey = rowKey;
+ }
+
+ public boolean isFrozenColumn() {
+ return !(_frozenColumnCount <= 0);
+ }
+
+ public void setFrozenColumnCount(int columnCount) {
+ _frozenColumnCount = columnCount;
+ }
+
+ public int getFrozenColumnCount() {
+ return _frozenColumnCount;
+ }
+
+ public boolean isFrozenPart() {
+ return _frozenPart;
+ }
+
+ public void setFrozenPart(boolean part) {
+ _frozenPart = part;
+ }
+
+ public String getCellIdPrefix() {
+ return _cell_id_prefix;
+ }
+
+ public void setCellIdPrefix(String _id_prefix) {
+ this._cell_id_prefix = _id_prefix;
+ }
+
+ public String getColumnType() {
+ return _column_type;
+ }
+
+ public void setColumType(String _column_type) {
+ this._column_type = _column_type;
+ }
+
+ public AjaxContext getAjaxContext() {
+ return ajaxContext;
+ }
+
+ public void setAjaxContext(AjaxContext ajaxContext) {
+ this.ajaxContext = ajaxContext;
+ }
+
+ public ResponseWriter getWriter() {
+ return writer;
+ }
+
+ public void setWriter(ResponseWriter writer) {
+ this.writer = writer;
+ }
+
+ public String getClientId(){
+ return clientId;
+ }
+
+ public void setClientId(String clientId){
+ this.clientId = clientId;
+ }
+
+ public boolean isHeader() {
+ return header;
+ }
+
+ public void setHeader(boolean header) {
+ this.header = header;
+ }
+
+ public String getPart() {
+ return part;
+ }
+
+ public void setPart(String part) {
+ this.part = part;
+ }
+
+ public int getSumWidth() {
+ return sumWidth;
+ }
+
+ public void setSumWidth(int sumWidth) {
+ this.sumWidth = sumWidth;
+ }
+
+ public Integer getSepOffset() {
+ return sepOffset;
+ }
+
+ public void setSepOffset(Integer sepOffset) {
+ this.sepOffset = sepOffset;
+ }
+
+ public Collection getCollection() {
+ return collection;
+ }
+
+ public void setCollection(Collection collection) {
+ this.collection = collection;
+ }
+
+ public boolean isFake() {
+ return fake;
+ }
+
+ public void setFake(boolean fake) {
+ this.fake = fake;
+ }
+
+ public String getColumnHeaderClass() {
+ return "";
+ }
+
+
+ public String getColumnClass() {
+ return getColumnClass(getCellIndex());
+ }
+
+ public String getColumnClass(int index) {
+ if(columnClasses != null) {
+ return columnClasses[index % columnClassesSize];
+ } else {
+ return "";
+ }
+ }
+
+ public void setColumnClasses(Object columnClasses) {
+ if(columnClasses != null) {
+ this.columnClasses = ((String)columnClasses).split(",");
+ columnClassesSize = this.columnClasses.length;
+ }
+ }
+
+ public String getRowClass(int index) {
+ if(rowClasses != null) {
+ return rowClasses[index % rowClassesSize];
+ } else {
+ return "";
+ }
+ }
+
+ public void setRowClasses(Object rowClasses) {
+ if(rowClasses != null) {
+ this.rowClasses = ((String)rowClasses).split(",");
+ rowClassesSize = this.rowClasses.length;
+ }
+ }
+
+ public HashSet getIds() {
+ return ids;
+ }
+
+ public void addId(String id) {
+ ids.add(id);
+ }
+}
Deleted: tags/3.1.0-rc5/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js
===================================================================
--- trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,321 +0,0 @@
-var Utils = {
-
- DOM: {
- copyAttributes : function(target, source, opts) {
-
- //LOG.debug("copyAttributes");
- var attrs = source.attributes;
-
- var exclusions = (opts && opts.exclude) ? opts.exclude : [];
-
- for(var i = 0 ; i < attrs.length; i++) {
-
- var attributeNode = attrs[i];
- var nodeName = attributeNode.nodeName;
- var nodeValue = attributeNode.nodeValue;
-
- var shouldCheckAttribute =
- nodeValue &&
- nodeValue.length > 0 &&
- exclusions.indexOf(nodeName) < 0;
-
- if (ClientUILib.isIE) {
- shouldCheckAttribute &= attributeNode.specified;
- }
-
- if(shouldCheckAttribute) {
-
- //LOG.debug("Copying attribute " + attributeNode.nodeName + "=" + attributeNode.nodeValue);
-
- var newAttributeNode =
- document.createAttribute(nodeName);
-
- newAttributeNode.nodeValue = attributeNode.nodeValue;
- target.setAttributeNode(newAttributeNode);
- }
-
- }
- //LOG.debug("/copyAttributes");
- },
-
- replaceNode : function(id, request) {
- var target = document.getElementById(id);
- var src = request.getElementById(id);
-
- if(target && src) {
- Utils.DOM.Event.removeListeners(target);
-
- if (ClientUILib.isIE) {
-
- var s = String();
- var newOuterXml = "<table><tbody>" + src.xml + "</tbody></table>";
- var newNode = document.createElement("DIV");
-
- newNode.innerHTML = newOuterXml;
-
- var imported = newNode.firstChild.firstChild.firstChild;
- target.parentNode.replaceChild(imported, target);;
- return imported;
-
- } else {
- var theDoc = document;
-
- Utils.DOM._clearAttributes(target);
- Utils.DOM.copyAttributes(target, src);
-
- /*var tdSrc, tdNode, subNode;
- var childs = src.childNodes;
- var ccount = childs.length;
- var tcount = target.childNodes.length;
- var innerHTML = [];
- var k;
- for(k=0, l=0; k<tcount; k++, l++) {
-
- if(childs[l]){
- if(!childs[l].tagName) {
- l++;
- }
- }
-
-
- tdSrc = l<ccount ? childs[l] : null;
- innerHTML.push("<td class='");
- innerHTML.push(target.childNodes[k].className);
- innerHTML.push("'>");
- innerHTML.push(tdSrc?tdSrc.innerHTML:"");
- innerHTML.push("</td>");
- }
- */
- target.innerHTML = src.innerHTML;//nnerHTML.join("");
- return target;
- }
- }
- else {
- if(!target)
- ClientUILib.log(ClientUILogger.ERROR, "DOM Element with id " + id + " not found for update.");
- if(!src) {
- ClientUILib.log(ClientUILogger.ERROR, "RESPONSE Element with id " + id + " not found for update.");
-
- // cleanup destination
- if(target) {
- for(var i=0; i<target.cells.length; i++) {
- target.cells[i].innerHTML = "";
- }
- }
- }
- }
- },
-
- _clearAttributes : function(node) {
-
- var attrs = node.attributes;
- if (node.clearAttributes) {
- node.clearAttributes();
- } else {
- while(node.attributes.length > 0) {
- node.removeAttributeNode(node.attributes[0]);
- }
- }
- },
-
- _formatNode : function(node) {
-
- var sb = new StringBuilder();
-
- sb.append("<").append(node.nodeName);
- for (var i = 0; i < node.attributes.length; i++) {
- var attr = node.attributes[i];
- if (attr.specified) {
- sb
- .append(" ")
- .append(attr.nodeName)
- .append("=\"")
- .append(attr.nodeValue)
- .append("\" ");
- }
- }
-
- sb.append("/>");
-
- return sb.toString();
-
- },
-
- Event: {
-
- /**
- * cache listeners in element to kill them all on element ajax replace
- * @param {Object} element
- * @param {Object} event
- * @param {Object} handler
- * @param {Object} useCapture
- */
- observe : function (element, event, handler, useCapture) {
- if (true) {
- if (!element._listeners) {
- element._listeners = [];
- }
-
- element._listeners[element._listeners.length] =
- {
- event: event,
- handler: handler,
- useCapture: useCapture
- };
- }
- Event.observe(element, event, handler, useCapture);
- },
-
- stopObserving : function(element, event, handler, useCapture) {
-
- if(element._listeners) {
- element._listeners =
- element._listeners.reject(
- function(obj) {
- return obj.event == event
- && obj.handler == handler
- && obj.useCapture == useCapture;
- }
- );
- }
-
- Event.stopObserving(element, event, handler, useCapture);
-
- },
-
- removeListeners : function(element) {
- if (element._listeners) {
- var l = element._listeners.length;
- for(var i = 0; i < l; i++) {
- var listener = element._listeners[i];
- Event.stopObserving(
- element,
- listener.event,
- listener.handler,
- listener.useCapture);
- }
-
- element._listeners = null;
- }
- }
- }
- },
-
- AJAX : {
- updateRows: function(options,request,grid,clientid, callbacks, callbacksPost){
- var localOptions = options;
- var rowCount = grid.getBody().templFrozen.getElement().rows.length;
- var startRow = localOptions.startRow;
- var count = localOptions.count;
- var rowindex, i, el;
- var dataModel = grid.dataModel;
- var baseid = clientid;
-
- var countForUpdate = 0;
- var rowsForUpdate = [];
-
- for(i=0; i<count; i++) {
- rowindex = startRow + i;
- if(rowindex >= rowCount){
- rowindex -= rowCount;
- }
- [":f:", ":n:"].unbreakableEach(
- function(suffix) {
- var id = [baseid,suffix,rowindex].join("");
- var row = Utils.DOM.replaceNode(id, request);
-
- if (callbacks) {
- // just suspend operation for future
- if(!rowsForUpdate[i]) rowsForUpdate[i] = {};
- rowsForUpdate[i][suffix] = {index : rowindex, row : row};
- countForUpdate++;
- }
- }
- );
- }
- if (ClientUILib.isIE7) {
- setTimeout(function() {
- var body = grid.getBody();
- ["fTable", "nTable"].unbreakableEach(
- function(prop) {
- body[prop].hide();
- body[prop].show();
- }
- );
- }
- ,50);
- }
-
- if (callbacks && countForUpdate>0) {
- // process suspended processing
- setTimeout(function(){
- for(var i=0; i<count; i++) {
- callbacks.unbreakableEach(
- function(callback) {
- if(rowsForUpdate[i]) {
- if(rowsForUpdate[i][":f:"].row) callback.call(grid, rowsForUpdate[i][":f:"]);
- if(rowsForUpdate[i][":n:"].row) callback.call(grid, rowsForUpdate[i][":n:"]);
- }
- }
- );
- }
-
- if(callbacksPost) {
- callbacksPost.unbreakableEach(
- function(callback) {
- callback.call(grid);
- }
- );
- }
- }, 100);
- }
-
- dataModel.eventDataReady.fire(localOptions);
- }
- }
-};
-/*
-var _cAtt = Utils.DOM._clearAttributes;
-Utils.DOM._clearAttributes = function() {
- return;
- var d1 = new Date().getTime();
- _cAtt.apply(Utils.DOM, arguments);
- var d2 = new Date().getTime();
- ClientUILib.log(ClientUILogger.INFO, "Utils.DOM._clearAttributes " + (d2 - d1) + "ms");
-};
-var cAtt = Utils.DOM._clearAttributes;
-Utils.DOM.copyAttributes = function() {
- return;
- var d1 = new Date().getTime();
- cAtt.apply(Utils.DOM, arguments);
- var d2 = new Date().getTime();
- ClientUILib.log(ClientUILogger.INFO, "Utils.DOM.copyAttributes " + (d2 - d1) + "ms");
-};
-*/
-Utils.execOnLoad = function(func, condition, timeout) {
-
- if (condition()) {
- func();
- } else {
- window.setTimeout(
- function() {
- Utils.execOnLoad(func, condition, timeout);
- },
- timeout
- );
- }
-};
-Utils.Condition = {
- ElementPresent : function(element) {
- return function () {
- var el = $(element);
- return el && el.offsetHeight > 0;
- };
- }
-};
-
-Array.prototype.unbreakableEach = function(f) {
- for (var i = 0; i < this.length; i++) {
- f(this[i], i);
- }
-};
\ No newline at end of file
Copied: tags/3.1.0-rc5/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js (from rev 2787, trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js)
===================================================================
--- tags/3.1.0-rc5/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js (rev 0)
+++ tags/3.1.0-rc5/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,303 @@
+var Utils = {
+
+ DOM: {
+ copyAttributes : function(target, source, opts) {
+
+ //LOG.debug("copyAttributes");
+ var attrs = source.attributes;
+
+ var exclusions = (opts && opts.exclude) ? opts.exclude : [];
+
+ for(var i = 0 ; i < attrs.length; i++) {
+
+ var attributeNode = attrs[i];
+ var nodeName = attributeNode.nodeName;
+ var nodeValue = attributeNode.nodeValue;
+
+ var shouldCheckAttribute =
+ nodeValue &&
+ nodeValue.length > 0 &&
+ exclusions.indexOf(nodeName) < 0;
+
+ if (ClientUILib.isIE) {
+ shouldCheckAttribute &= attributeNode.specified;
+ }
+
+ if(shouldCheckAttribute) {
+
+ //LOG.debug("Copying attribute " + attributeNode.nodeName + "=" + attributeNode.nodeValue);
+
+ var newAttributeNode =
+ document.createAttribute(nodeName);
+
+ newAttributeNode.nodeValue = attributeNode.nodeValue;
+ target.setAttributeNode(newAttributeNode);
+ }
+
+ }
+ //LOG.debug("/copyAttributes");
+ },
+
+ replaceNode : function(id, request) {
+ var target = document.getElementById(id);
+ var src = request.getElementById(id);
+
+ if(target && src) {
+ Utils.DOM.Event.removeListeners(target);
+
+ if (ClientUILib.isIE) {
+
+ var s = String();
+ var newOuterXml = "<table><tbody>" + src.xml + "</tbody></table>";
+ var newNode = document.createElement("DIV");
+
+ newNode.innerHTML = newOuterXml;
+
+ var imported = newNode.firstChild.firstChild.firstChild;
+ target.parentNode.replaceChild(imported, target);;
+ return imported;
+
+ } else if (ClientUILib.isGecko){
+ //Mozill family
+ var theDoc = document;
+
+ Utils.DOM._clearAttributes(target);
+ Utils.DOM.copyAttributes(target, src);
+
+ target.innerHTML = src.innerHTML;//nnerHTML.join("");
+ return target;
+ } else {
+ //Fall back to DOM, and cross the fingers
+ src = document.importNode(src, true);
+ target.parentNode.replaceChild(src, target);
+ }
+ }
+ else {
+ if(!target)
+ ClientUILib.log(ClientUILogger.ERROR, "DOM Element with id " + id + " not found for update.");
+ if(!src) {
+ ClientUILib.log(ClientUILogger.ERROR, "RESPONSE Element with id " + id + " not found for update.");
+
+ // cleanup destination
+ if(target) {
+ for(var i=0; i<target.cells.length; i++) {
+ target.cells[i].innerHTML = "";
+ }
+ }
+ }
+ }
+ },
+
+ _clearAttributes : function(node) {
+
+ var attrs = node.attributes;
+ if (node.clearAttributes) {
+ node.clearAttributes();
+ } else {
+ while(node.attributes.length > 0) {
+ node.removeAttributeNode(node.attributes[0]);
+ }
+ }
+ },
+
+ _formatNode : function(node) {
+
+ var sb = new StringBuilder();
+
+ sb.append("<").append(node.nodeName);
+ for (var i = 0; i < node.attributes.length; i++) {
+ var attr = node.attributes[i];
+ if (attr.specified) {
+ sb
+ .append(" ")
+ .append(attr.nodeName)
+ .append("=\"")
+ .append(attr.nodeValue)
+ .append("\" ");
+ }
+ }
+
+ sb.append("/>");
+
+ return sb.toString();
+
+ },
+
+ Event: {
+
+ /**
+ * cache listeners in element to kill them all on element ajax replace
+ * @param {Object} element
+ * @param {Object} event
+ * @param {Object} handler
+ * @param {Object} useCapture
+ */
+ observe : function (element, event, handler, useCapture) {
+ if (true) {
+ if (!element._listeners) {
+ element._listeners = [];
+ }
+
+ element._listeners[element._listeners.length] =
+ {
+ event: event,
+ handler: handler,
+ useCapture: useCapture
+ };
+ }
+ Event.observe(element, event, handler, useCapture);
+ },
+
+ stopObserving : function(element, event, handler, useCapture) {
+
+ if(element._listeners) {
+ element._listeners =
+ element._listeners.reject(
+ function(obj) {
+ return obj.event == event
+ && obj.handler == handler
+ && obj.useCapture == useCapture;
+ }
+ );
+ }
+
+ Event.stopObserving(element, event, handler, useCapture);
+
+ },
+
+ removeListeners : function(element) {
+ if (element._listeners) {
+ var l = element._listeners.length;
+ for(var i = 0; i < l; i++) {
+ var listener = element._listeners[i];
+ Event.stopObserving(
+ element,
+ listener.event,
+ listener.handler,
+ listener.useCapture);
+ }
+
+ element._listeners = null;
+ }
+ }
+ }
+ },
+
+ AJAX : {
+ updateRows: function(options,request,grid,clientid, callbacks, callbacksPost){
+ var localOptions = options;
+ var rowCount = grid.getBody().templFrozen.getElement().rows.length;
+ var startRow = localOptions.startRow;
+ var count = localOptions.count;
+ var rowindex, i, el;
+ var dataModel = grid.dataModel;
+ var baseid = clientid;
+
+ var countForUpdate = 0;
+ var rowsForUpdate = [];
+
+ for(i=0; i<count; i++) {
+ rowindex = startRow + i;
+ if(rowindex >= rowCount){
+ rowindex -= rowCount;
+ }
+ [":f:", ":n:"].unbreakableEach(
+ function(suffix) {
+ var id = [baseid,suffix,rowindex].join("");
+ var row = Utils.DOM.replaceNode(id, request);
+
+ if (callbacks) {
+ // just suspend operation for future
+ if(!rowsForUpdate[i]) rowsForUpdate[i] = {};
+ rowsForUpdate[i][suffix] = {index : rowindex, row : row};
+ countForUpdate++;
+ }
+ }
+ );
+ }
+ if (ClientUILib.isIE7) {
+ setTimeout(function() {
+ var body = grid.getBody();
+ ["fTable", "nTable"].unbreakableEach(
+ function(prop) {
+ body[prop].hide();
+ body[prop].show();
+ }
+ );
+ }
+ ,50);
+ }
+
+ if (callbacks && countForUpdate>0) {
+ // process suspended processing
+ setTimeout(function(){
+ for(var i=0; i<count; i++) {
+ callbacks.unbreakableEach(
+ function(callback) {
+ if(rowsForUpdate[i]) {
+ if(rowsForUpdate[i][":f:"].row) callback.call(grid, rowsForUpdate[i][":f:"]);
+ if(rowsForUpdate[i][":n:"].row) callback.call(grid, rowsForUpdate[i][":n:"]);
+ }
+ }
+ );
+ }
+
+ if(callbacksPost) {
+ callbacksPost.unbreakableEach(
+ function(callback) {
+ callback.call(grid);
+ }
+ );
+ }
+ }, 100);
+ }
+
+ dataModel.eventDataReady.fire(localOptions);
+ }
+ }
+};
+/*
+var _cAtt = Utils.DOM._clearAttributes;
+Utils.DOM._clearAttributes = function() {
+ return;
+ var d1 = new Date().getTime();
+ _cAtt.apply(Utils.DOM, arguments);
+ var d2 = new Date().getTime();
+ ClientUILib.log(ClientUILogger.INFO, "Utils.DOM._clearAttributes " + (d2 - d1) + "ms");
+};
+var cAtt = Utils.DOM._clearAttributes;
+Utils.DOM.copyAttributes = function() {
+ return;
+ var d1 = new Date().getTime();
+ cAtt.apply(Utils.DOM, arguments);
+ var d2 = new Date().getTime();
+ ClientUILib.log(ClientUILogger.INFO, "Utils.DOM.copyAttributes " + (d2 - d1) + "ms");
+};
+*/
+Utils.execOnLoad = function(func, condition, timeout) {
+
+ if (condition()) {
+ func();
+ } else {
+ window.setTimeout(
+ function() {
+ Utils.execOnLoad(func, condition, timeout);
+ },
+ timeout
+ );
+ }
+};
+Utils.Condition = {
+ ElementPresent : function(element) {
+ return function () {
+ var el = $(element);
+ return el && el.offsetHeight > 0;
+ };
+ }
+};
+
+Array.prototype.unbreakableEach = function(f) {
+ for (var i = 0; i < this.length; i++) {
+ f(this[i], i);
+ }
+};
\ No newline at end of file
Deleted: tags/3.1.0-rc5/ui/scrollableDataTable/src/main/resources/org/richfaces/renderkit/html/css/scrollable-data-table.xcss
===================================================================
--- trunk/ui/scrollableDataTable/src/main/resources/org/richfaces/renderkit/html/css/scrollable-data-table.xcss 2007-09-05 15:46:21 UTC (rev 2776)
+++ tags/3.1.0-rc5/ui/scrollableDataTable/src/main/resources/org/richfaces/renderkit/html/css/scrollable-data-table.xcss 2007-09-05 23:11:35 UTC (rev 2790)
@@ -1,323 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<f:template
- xmlns:f="http://jsf.exadel.com/template"
- xmlns:u="http://jsf.exadel.com/template/util"
- xmlns="http://www.w3.org/1999/xhtml">
-
- <f:verbatim>
-
- .dr-sdt-sort-asc, .dr-sdt-sort-desc {
- width: 16px;
- height: 6px;
- background-position: 50% 50%;
- background-repeat: no-repeat;
- }
-
- .dr-sdt-sort-icon {
- position:absolute;
- visibility: hidden;
- }
-
- .dr-sdt {
- padding: 0px 0px;
- margin: 0px;
- z-index:0;
- border-style: solid;
- }
-
- /**
- * ---------------------------------------------
- * Grid Header declaration
- * ---------------------------------------------
- */
-
- /**
- * Header row
- */
- .dr-sdt-hr {
- z-index:2;
- }
-
- /**
- * Header cell
- */
- .dr-sdt-hc {
- -o-text-overflow: ellipsis;
- text-overflow: ellipsis;
- overflow: hidden;
- font-weight: normal;
- cursor: default;
- box-sizing: border-box;
- -moz-box-sizing: border-box;
- -moz-outline: none;
- -moz-user-focus: normal;
- padding: 0px 0px;
- white-space: nowrap;
- border-bottom-style: solid;
- border-right-style: solid;
- }
-
- .dr-sdt-hc .sort-asc, .dr-sdt-hc .sort-desc {
- background-position: right;
- background-repeat: no-repeat;
- width: 16px !important;;
- position: absolute;
- }
-
-
- /**
- * Header cells separator
- */
- .dr-sdt-hsep {
- /* background-image: url(grid-split.gif);*/
- background-position: center;
- background-repeat: repeat-y;
- cursor: e-resize;
- font-size: 1px;
- top: 15%;
- width: 6px;
- height: 70%;
- overflow: hidden;
- position: absolute;
- display: block;
- white-space: nowrap;
- z-index: 60;
- }
- .dr-sdt-hsplit {
- width:1px;
- border-right: 1px dashed;
- cursor: col-resize;
- z-index: 100;
- }
-
- /**
- * Header cell body
- */
- .dr-sdt-hcbody {
- white-space: nowrap;
- position: relative;
- display: block;
- overflow: hidden;
- width: 100%;
- font-weight: normal;
- }
-
- .dr-sdt-fb{
- z-index: 50;
- }
- .dr-sdt-nb {
- z-index: 20;
- }
-
- /**
- * ---------------------------------------------
- * Grid Footer declaration
- * ---------------------------------------------
- */
-
- /**
- * Footer row
- */
- .dr-sdt-fr {
- font-weight: normal;
- height: 22px;
- border-top: 1px solid #cbc7b8; /* //TODO Which skin parameter must be here? */
- }
-
- /**
- * Footer cell
- */
- .dr-sdt-fc {
- -o-text-overflow: ellipsis;
- text-overflow: ellipsis;
- overflow: hidden;
- font-weight: normal;
- cursor: default;
- box-sizing: border-box;
- -moz-box-sizing: border-box;
- -moz-outline: none;
- -moz-user-focus: normal;
- border-right: 1px solid;
- height:21px !important;
- padding: 0px 0px;
- white-space: nowrap;
- }
-
- /**
- * Footer cell body
- */
- .dr-sdt-fcbody {
- cursor: default;
- font-weight: normal;
- padding: 3px 5px;
- white-space: nowrap;
- position: relative;
- display: block;
- overflow: hidden;
- }
-
- .dr-sdt-fcbody1{
- cursor: default;
- font-weight: normal;
- padding: 0px 0px;
- white-space: nowrap;
- position: relative;
- display: block;
- overflow: hidden;
- width: 100%;
- }
-
- /**
- * ---------------------------------------------
- * Body styles
- * ---------------------------------------------
- */
-
- /**
- * Body cell declaration
- * dr-sdt-bc - reqired
- * dr-sdt-bcDef - default, used if no custom styles defined in body template
- */
- .dr-sdt-bc {
- box-sizing: border-box;
- -moz-box-sizing: border-box;
- -moz-outline: none;
- -moz-user-focus: normal;
- cursor: default;
- border-right: 1px solid;
- border-bottom: 1px solid;
- }
-
- /**
- * Body row style
- */
- .dr-sdt-ho {
- position: absolute;
- height: 10px;
- width: 10px;
- }
-
- .dr-sdt-rb {
- font-weight: normal;
- white-space: nowrap;
- box-sizing: border-box;
- -moz-box-sizing: border-box;
- }
-
- .dr-sdt-row-active {
- background-color: #C6D6EA; /* //TODO Which skin parameter must be here? */
- }
-
- .dr-sdt-bcbody {
- cursor: default;
- font-weight: normal;
- white-space: nowrap;
- padding: 0px 0px;
- position: relative;
- display: block;
- overflow: hidden;
- -o-text-overflow: ellipsis;
- text-overflow: ellipsis;
- -moz-box-sizing: border-box;
- -moz-outline: none;
- width: 100%;
- height: 20px;
- }
-
- /**
- * Helper classes for grid template
- */
- .dr-sdt-substrate {
- z-index: 48;
- filter:Alpha(opacity=0);
- position:absolute;
- top:0px;
- left:0px;
- display:block;
- }
-
- .dr-sdt-tmplbox {
- display: block;
- float:left;
- }
-
- .dr-sdt-inlinebox {
- position: relative;
- display: block;
- overflow: hidden;
- }
- </f:verbatim>
-
- <u:selector name=".dr-sdt">
- <u:style name="background-color" skin="tableBackgroundColor" />
- <u:style name="border-color" skin="tableBorderColor" />
- <u:style name="border-width" skin="tableBorderWidth" />
- </u:selector>
- <u:selector name=".dr-sdt-hr">
- <u:style name="background-color" skin="headerBackgroundColor" />
- </u:selector>
- <u:selector name=".dr-sdt-hc">
- <u:style name="color" skin="headerTextColor" />
- <u:style name="font-family" skin="generalFamilyFont" />
- <u:style name="font-size" skin="generalSizeFont" />
- <u:style name="border-bottom-width" skin="tableBorderWidth" />
- <u:style name="border-bottom-color" skin="tableBorderColor" />
- <u:style name="border-right-width" skin="tableBorderWidth" />
- <u:style name="border-right-color" skin="tableBorderColor" />
- </u:selector>
- <u:selector name=".dr-sdt-hsplit">
- <u:style name="border-right-color" skin="tipBorderColor" />
- </u:selector>
- <u:selector name=".dr-sdt-hcbody">
- <u:style name="font-family" skin="generalFamilyFont" />
- <u:style name="font-size" skin="generalSizeFont" />
- </u:selector>
- <u:selector name=".dr-sdt-fr">
- <u:style name="background-color" skin="tableSubfooterBackgroundColor" />
- <u:style name="font-family" skin="generalFamilyFont" />
- <u:style name="font-size" skin="generalSizeFont" />
- </u:selector>
- <u:selector name=".dr-sdt-fc">
- <u:style name="border-right-color" skin="tableBorderColor" />
- <u:style name="font-family" skin="generalFamilyFont" />
- <u:style name="font-size" skin="generalSizeFont" />
- </u:selector>
- <u:selector name=".dr-sdt-fcbody">
- <u:style name="font-family" skin="generalFamilyFont" />
- <u:style name="font-size" skin="generalSizeFont" />
- </u:selector>
- <u:selector name=".dr-sdt-fcbody1">
- <u:style name="font-family" skin="generalFamilyFont" />
- <u:style name="font-size" skin="generalSizeFont" />
- </u:selector>
- <u:selector name=".dr-sdt-bc">
- <u:style name="border-right-color" skin="tableBorderColor" />
- <u:style name="border-bottom-color" skin="tableBorderColor" />
- </u:selector>
- <u:selector name=".dr-sdt-rb">
- <u:style name="font-family" skin="generalFamilyFont" />
- <u:style name="font-size" skin="generalSizeFont" />
- </u:selector>
- <u:selector name=".dr-sdt-row-selected">
- <u:style name="background-color" skin="additionalBackgroundColor" />
- </u:selector>
- <u:selector name=".dr-sdt-bcbody">
- <u:style name="font-family" skin="generalFamilyFont" />
- <u:style name="font-size" skin="generalSizeFont" />
- </u:selector>
- <u:selector name=".dr-sdt-sort-asc">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.iconimages.ScrollableDataTableIconSortAsc"/>
- </u:style>
- </u:selector>
- <u:selector name=".dr-sdt-sort-desc">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.iconimages.ScrollableDataTableIconSortDesc"/>
- </u:style>
- </u:selector>
- <u:selector name=".dr-sdt-hsep">
- <u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.iconimages.ScrollableDataTableIconSplit"/>
- </u:style>
- </u:selector>
-</f:template>
Copied: tags/3.1.0-rc5/ui/scrollableDataTable/src/main/resources/org/richfaces/renderkit/html/css/scrollable-data-table.xcss (from rev 2787, trunk/ui/scrollableDataTable/src/main/resources/org/richfaces/renderkit/html/css/scrollable-data-table.xcss)
===================================================================
--- tags/3.1.0-rc5/ui/scrollableDataTable/src/main/resources/org/richfaces/renderkit/html/css/scrollable-data-table.xcss (rev 0)
+++ tags/3.1.0-rc5/ui/scrollableDataTable/src/main/resources/org/richfaces/renderkit/html/css/scrollable-data-table.xcss 2007-09-05 23:11:35 UTC (rev 2790)
@@ -0,0 +1,326 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template
+ xmlns:f="http://jsf.exadel.com/template"
+ xmlns:u="http://jsf.exadel.com/template/util"
+ xmlns="http://www.w3.org/1999/xhtml">
+
+ <f:verbatim>
+
+ .dr-sdt-sort-asc, .dr-sdt-sort-desc {
+ width: 16px;
+ height: 6px;
+ background-position: 50% 50%;
+ background-repeat: no-repeat;
+ }
+
+ .dr-sdt-sort-icon {
+ position:absolute;
+ visibility: hidden;
+ }
+
+ .dr-sdt {
+ padding: 0px 0px;
+ margin: 0px;
+ z-index:0;
+ border-style: solid;
+ }
+
+ /**
+ * ---------------------------------------------
+ * Grid Header declaration
+ * ---------------------------------------------
+ */
+
+ /**
+ * Header row
+ */
+ .dr-sdt-hr {
+ z-index:2;
+ }
+
+ /**
+ * Header cell
+ */
+ .dr-sdt-hc {
+ -o-text-overflow: ellipsis;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ font-weight: normal;
+ cursor: default;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -moz-outline: none;
+ -moz-user-focus: normal;
+ padding: 0px 0px;
+ white-space: nowrap;
+ border-bottom-style: solid;
+ border-right-style: solid;
+ }
+
+ .dr-sdt-hc .sort-asc, .dr-sdt-hc .sort-desc {
+ background-position: right;
+ background-repeat: no-repeat;
+ width: 16px !important;;
+ position: absolute;
+ }
+
+
+ /**
+ * Header cells separator
+ */
+ .dr-sdt-hsep {
+ /* background-image: url(grid-split.gif);*/
+ background-position: center;
+ background-repeat: repeat-y;
+ cursor: e-resize;
+ font-size: 1px;
+ top: 15%;
+ width: 6px;
+ height: 70%;
+ overflow: hidden;
+ position: absolute;
+ display: block;
+ white-space: nowrap;
+ z-index: 60;
+ }
+ .dr-sdt-hsplit {
+ width:1px;
+ border-right: 1px dashed;
+ cursor: col-resize;
+ z-index: 100;
+ }
+
+ /**
+ * Header cell body
+ */
+ .dr-sdt-hcbody {
+ white-space: nowrap;
+ position: relative;
+ display: block;
+ overflow: hidden;
+ width: 100%;
+ font-weight: normal;
+ }
+
+ .dr-sdt-fb{
+ z-index: 50;
+ }
+ .dr-sdt-nb {
+ z-index: 20;
+ }
+
+ /**
+ * ---------------------------------------------
+ * Grid Footer declaration
+ * ---------------------------------------------
+ */
+
+ /**
+ * Footer row
+ */
+ .dr-sdt-fr {
+ font-weight: normal;
+ height: 22px;
+ border-top: 1px solid #cbc7b8; /* //TODO Which skin parameter must be here? */
+ }
+
+ /**
+ * Footer cell
+ */
+ .dr-sdt-fc {
+ -o-text-overflow: ellipsis;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ font-weight: normal;
+ cursor: default;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -moz-outline: none;
+ -moz-user-focus: normal;
+ border-right: 1px solid;
+ height:21px !important;
+ padding: 0px 0px;
+ white-space: nowrap;
+ }
+
+ /**
+ * Footer cell body
+ */
+ .dr-sdt-fcbody {
+ cursor: default;
+ font-weight: normal;
+ padding: 3px 5px;
+ white-space: nowrap;
+ position: relative;
+ display: block;
+ overflow: hidden;
+ }
+
+ .dr-sdt-fcbody1{
+ cursor: default;
+ font-weight: normal;
+ padding: 0px 0px;
+ white-space: nowrap;
+ position: relative;
+ display: block;
+ overflow: hidden;
+ width: 100%;
+ }
+
+ /**
+ * ---------------------------------------------
+ * Body styles
+ * ---------------------------------------------
+ */
+
+ /**
+ * Body cell declaration
+ * dr-sdt-bc - reqired
+ * dr-sdt-bcDef - default, used if no custom styles defined in body template
+ */
+ .dr-sdt-bc {
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -moz-outline: none;
+ -moz-user-focus: normal;
+ cursor: default;
+ border-right: 1px solid;
+ border-bottom: 1px solid;
+ }
+
+ /**
+ * Body row style
+ */
+ .dr-sdt-ho {
+ position: absolute;
+ height: 10px;
+ width: 10px;
+ }
+
+ .dr-sdt-rb {
+ font-weight: normal;
+ white-space: nowrap;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ }
+ /*
+ .dr-sdt-row-active {
+ font-weight:bold; //TODO Which skin parameter must be here?
+ }
+ */
+ .dr-sdt-bcbody {
+ cursor: default;
+ font-weight: normal;
+ white-space: nowrap;
+ padding: 0px 0px;
+ position: relative;
+ display: block;
+ overflow: hidden;
+ -o-text-overflow: ellipsis;
+ text-overflow: ellipsis;
+ -moz-box-sizing: border-box;
+ -moz-outline: none;
+ width: 100%;
+ height: 20px;
+ }
+
+ /**
+ * Helper classes for grid template
+ */
+ .dr-sdt-substrate {
+ z-index: 48;
+ filter:Alpha(opacity=0);
+ position:absolute;
+ top:0px;
+ left:0px;
+ display:block;
+ }
+
+ .dr-sdt-tmplbox {
+ display: block;
+ float:left;
+ }
+
+ .dr-sdt-inlinebox {
+ position: relative;
+ display: block;
+ overflow: hidden;
+ }
+ </f:verbatim>
+
+ <u:selector name=".dr-sdt">
+ <u:style name="background-color" skin="tableBackgroundColor" />
+ <u:style name="border-color" skin="tableBorderColor" />
+ <u:style name="border-width" skin="tableBorderWidth" />
+ </u:selector>
+ <u:selector name=".dr-sdt-hr">
+ <u:style name="background-color" skin="headerBackgroundColor" />
+ </u:selector>
+ <u:selector name=".dr-sdt-hc">
+ <u:style name="color" skin="headerTextColor" />
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+ <u:style name="border-bottom-width" skin="tableBorderWidth" />
+ <u:style name="border-bottom-color" skin="tableBorderColor" />
+ <u:style name="border-right-width" skin="tableBorderWidth" />
+ <u:style name="border-right-color" skin="tableBorderColor" />
+ </u:selector>
+ <u:selector name=".dr-sdt-hsplit">
+ <u:style name="border-right-color" skin="tipBorderColor" />
+ </u:selector>
+ <u:selector name=".dr-sdt-hcbody">
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+ </u:selector>
+ <u:selector name=".dr-sdt-fr">
+ <u:style name="background-color" skin="tableSubfooterBackgroundColor" />
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+ </u:selector>
+ <u:selector name=".dr-sdt-fc">
+ <u:style name="border-right-color" skin="tableBorderColor" />
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+ </u:selector>
+ <u:selector name=".dr-sdt-fcbody">
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+ </u:selector>
+ <u:selector name=".dr-sdt-fcbody1">
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+ </u:selector>
+ <u:selector name=".dr-sdt-bc">
+ <u:style name="border-right-color" skin="tableBorderColor" />
+ <u:style name="border-bottom-color" skin="tableBorderColor" />
+ </u:selector>
+ <u:selector name=".dr-sdt-rb">
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+ </u:selector>
+ <u:selector name=".dr-sdt-row-selected">
+ <u:style name="background-color" skin="additionalBackgroundColor" />
+ </u:selector>
+ <u:selector name=".dr-sdt-row-active">
+ <u:style name="color" skin="tabDisabledTextColor" />
+ </u:selector>
+ <u:selector name=".dr-sdt-bcbody">
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+ </u:selector>
+ <u:selector name=".dr-sdt-sort-asc">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.iconimages.ScrollableDataTableIconSortAsc"/>
+ </u:style>
+ </u:selector>
+ <u:selector name=".dr-sdt-sort-desc">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.iconimages.ScrollableDataTableIconSortDesc"/>
+ </u:style>
+ </u:selector>
+ <u:selector name=".dr-sdt-hsep">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.iconimages.ScrollableDataTableIconSplit"/>
+ </u:style>
+ </u:selector>
+</f:template>
Copied: tags/3.1.0-rc5/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html (from rev 2787, trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html)
18 years, 8 months
JBoss Rich Faces SVN: r2789 - trunk/ui/datascroller/src/main/java/org/richfaces/event.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-09-05 17:54:34 -0400 (Wed, 05 Sep 2007)
New Revision: 2789
Modified:
trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
Log:
Unit test failure fixed
Modified: trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
===================================================================
--- trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-09-05 19:12:37 UTC (rev 2788)
+++ trunk/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-09-05 21:54:34 UTC (rev 2789)
@@ -69,7 +69,10 @@
* @param listener the slider listener
*/
public void processListener(FacesListener listener) {
- if (super.isAppropriateListener(listener)) {
+ if (listener instanceof DataScrollerListener) {
+ DataScrollerListener dataScrollerListener = (DataScrollerListener) listener;
+ dataScrollerListener.processScroller(this);
+ } else if (super.isAppropriateListener(listener)) {
super.processListener(listener);
}
}
18 years, 8 months
JBoss Rich Faces SVN: r2788 - in trunk: framework/impl/src/main/java/org/ajax4jsf/webapp and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-09-05 15:12:37 -0400 (Wed, 05 Sep 2007)
New Revision: 2788
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
trunk/samples/seamEAR/pom.xml
trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java
Log:
Restore processing onExpire/onError.
don't abort ignored requests ( ignoreDupResponse ), for a Seam 2.0 compability.
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-09-05 18:20:43 UTC (rev 2787)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-09-05 19:12:37 UTC (rev 2788)
@@ -58,7 +58,7 @@
private static final Log _log = LogFactory.getLog(AjaxViewHandler.class);
- private static final String REDIRECTED = "org.ajax4jsf.view.REDIRECTED";
+ public static final String VIEW_EXPIRED = "org.ajax4jsf.view.EXPIRED";
public static final String VIEW_ID_KEY = "org.ajax4jsf.VIEW_ID";
@@ -68,7 +68,7 @@
public AjaxViewHandler(ViewHandler parent) {
super(parent);
if (_log.isDebugEnabled()) {
- _log.debug("Create instance of Ajax ViewHandler");
+ _log.debug("Create instance of Ajax ViewHandler");
}
}
@@ -96,7 +96,8 @@
// HACK - since only RI 1.1 use new for create ViewRoot instead
// of Application.createComponent,
// we can use it as flag for custom creation.
- riRoot = (UIViewRoot) facesContext.getApplication().createComponent(UIViewRoot.COMPONENT_TYPE);
+ riRoot = (UIViewRoot) facesContext.getApplication()
+ .createComponent(UIViewRoot.COMPONENT_TYPE);
// fill properties from default.
riRoot.setViewId(root.getViewId());
riRoot.setLocale(root.getLocale());
@@ -107,11 +108,15 @@
}
riRoot.setRenderKitId(renderKitId);
}
- if (ajaxContext.isAjaxRequest(facesContext)) {
- // Remove ajax status - for navigation states, full page will be
- // send.
+ // if (null ==
+ // facesContext.getExternalContext().getRequestMap().get(VIEW_EXPIRED))
+ // {
+ // Clear ajax request flag ( except new view creation )- for navigation states, full page will be
+ // send.
+ if(null != facesContext.getViewRoot()){
ajaxContext.setAjaxRequest(false);
}
+ // }
}
return riRoot;
}
@@ -134,7 +139,7 @@
writer.startElement(HTML.SPAN_ELEM, null);
writer.writeAttribute(HTML.id_ATTRIBUTE, STATE_MARKER_KEY, null);
writer.writeAttribute(HTML.NAME_ATTRIBUTE, STATE_MARKER_KEY, null);
-// writer.writeAttribute("style", "display:none;", null);
+ // writer.writeAttribute("style", "display:none;", null);
if (!ajaxContext.isSelfRender()) {
super.writeState(context);
}
@@ -153,43 +158,17 @@
public UIViewRoot restoreView(FacesContext context, String viewId) {
UIViewRoot viewRoot = super.restoreView(context, viewId);
ExternalContext externalContext = context.getExternalContext();
- Map requestParameterMap = externalContext.getRequestParameterMap();
Map requestMap = externalContext.getRequestMap();
-/* if (null == viewRoot) {
- if (requestParameterMap
- .containsKey(AjaxContainerRenderer.AJAX_PARAMETER_NAME)
- && !requestMap.containsKey(REDIRECTED)) {
- // New view created for AJAX request - indicate session
- // expiration.
- // We need send special response to client and suggest reload
- // page.
- String actionURL = getActionURL(context, viewId);
- // To avoid double call to redirect, if we have more then one
- // handler in chain.
- requestMap.put(REDIRECTED, Boolean.TRUE);
- if (_log.isDebugEnabled()) {
- _log
- .debug("Detect session expiration in AJAX request - view don't restored, action URL is "
- + actionURL);
- }
- try {
- Object response = externalContext.getResponse();
- if (response instanceof HttpServletResponse) {
- HttpServletResponse httpResponse = (HttpServletResponse) response;
- // TODO - get locale from request ?
- httpResponse.setHeader("Ajax-Expired", Messages
- .getMessage(Messages.AJAX_VIEW_EXPIRED));
- }
- actionURL = externalContext.encodeActionURL(actionURL);
- externalContext.redirect(actionURL);
- context.responseComplete();
- } catch (IOException e) {
- throw new FacesException(
- "Error on redirect for reload expired page", e);
- }
+ if (null == viewRoot) {
+ requestMap.put(VIEW_EXPIRED, Messages
+ .getMessage(Messages.AJAX_VIEW_EXPIRED));
+ if (_log.isDebugEnabled()) {
+ _log
+ .debug("Detect session expiration in AJAX request - view don't restored for a viewId "
+ + viewId);
}
}
-*/ return viewRoot;
+ return viewRoot;
}
/*
@@ -244,21 +223,21 @@
.debug(Messages
.getMessage(Messages.AJAX_RESPONSE_NOT_RENDERED_INFO));
}
- ajaxContext.setSelfRender(true);
- //ServletResponse response = (ServletResponse) context
- // .getExternalContext().getResponse();
- Object response = (Object) context
- .getExternalContext().getResponse();
- try {
- response.getClass().getDeclaredMethod("reset",
- new Class[0]).invoke(response, new Object[0]);
- //response.reset();
- } catch (Exception e) {
- // Do nothing - we will use directly and reset
- // wrapper
- }
- ajaxContext.renderSubmittedAjaxRegion(context,true);
+ ajaxContext.setSelfRender(true);
+ // ServletResponse response = (ServletResponse) context
+ // .getExternalContext().getResponse();
+ Object response = (Object) context.getExternalContext()
+ .getResponse();
+ try {
+ response.getClass().getDeclaredMethod("reset",
+ new Class[0]).invoke(response, new Object[0]);
+ // response.reset();
+ } catch (Exception e) {
+ // Do nothing - we will use directly and reset
+ // wrapper
}
+ ajaxContext.renderSubmittedAjaxRegion(context, true);
+ }
}
} else {
super.renderView(context, root);
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2007-09-05 18:20:43 UTC (rev 2787)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2007-09-05 19:12:37 UTC (rev 2788)
@@ -152,6 +152,10 @@
String redirectLocation = servletResponseWrapper.getRedirectLocation();
String characterEncoding = servletResponseWrapper
.getCharacterEncoding();
+ Object view_expired = request.getAttribute(AjaxViewHandler.VIEW_EXPIRED);
+ if(null != view_expired){
+ servletResponseWrapper.setHeader("Ajax-Expired", view_expired.toString());
+ }
Writer output;
if (null != redirectLocation) {
if (isAjaxRequest(request)) {
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-09-05 18:20:43 UTC (rev 2787)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-09-05 19:12:37 UTC (rev 2788)
@@ -141,7 +141,7 @@
this._aborted=true;
if(this._request){
try{
- this._request.abort();
+// this._request.abort();
if(this._timeoutID){
window.clearTimeout(this._timeoutID);
}
@@ -234,6 +234,7 @@
getElementById : function(id){
// first attempt - .getElementById.
var oDoc = this._request.responseXML;
+ if(oDoc){
if(typeof(oDoc.getElementById) != 'undefined') {
LOG.debug("call getElementById for id= "+id);
return oDoc.getElementById(id);
@@ -249,6 +250,9 @@
return oDoc.nodeFromID(id);
}
LOG.error("No functions for getElementById found ");
+ } else {
+ LOG.debug("No parsed XML document in response");
+ }
return null;
},
@@ -656,19 +660,21 @@
A4J.AJAX.processResponse = function(req) {
var options = req.options;
var ajaxResponse = req.getResponseHeader('Ajax-Response');
- if( ajaxResponse != "true"){
+ // If view is expired, check user-defined handler.
+ var expiredMsg = req.getResponseHeader('Ajax-Expired');
+ if(expiredMsg && typeof(A4J.AJAX.onExpired) == 'function' ){
+ var loc = A4J.AJAX.onExpired(window.location,expiredMsg);
+ if(loc){
+ window.location = loc;
+ return;
+ }
+ }
+ if( ajaxResponse != "true"){
// NO Ajax header - new page.
LOG.warn("No ajax response header ");
var loc = req.getResponseHeader("Location");
try{
if(ajaxResponse == 'redirect' && loc){
- var expiredMsg = req.getResponseHeader('Ajax-Expired');
- if(expiredMsg){
- loc = A4J.AJAX.onExpired(loc,expiredMsg);
- if(!loc){
- return;
- }
- }
window.location = loc;
} else if(ajaxResponse == "reload"){
window.location.reload(true);
@@ -776,13 +782,6 @@
}
};
-A4J.AJAX.onExpired = function(loc,expiredMsg){
- if(window.confirm(expiredMsg)){
- return loc;
- } else {
- return undefined;
- }
-};
A4J.AJAX.replacePage = function(req){
LOG.debug("replace all page content with response");
Modified: trunk/samples/seamEAR/pom.xml
===================================================================
--- trunk/samples/seamEAR/pom.xml 2007-09-05 18:20:43 UTC (rev 2787)
+++ trunk/samples/seamEAR/pom.xml 2007-09-05 19:12:37 UTC (rev 2788)
@@ -26,15 +26,6 @@
<pluginManagement>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <unzipCommand>
- /usr/bin/unzip -o > err.txt
- </unzipCommand>
- </configuration>
- </plugin>
- <plugin>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
Modified: trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java
===================================================================
--- trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java 2007-09-05 18:20:43 UTC (rev 2787)
+++ trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java 2007-09-05 19:12:37 UTC (rev 2788)
@@ -74,7 +74,7 @@
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
HttpSession session = (HttpSession) externalContext.getSession(false);
if(null != session){
- session.setMaxInactiveInterval(10);
+ session.setMaxInactiveInterval(5);
}
return null;
}
18 years, 8 months
JBoss Rich Faces SVN: r2787 - trunk/framework/impl/src/main/java/org/ajax4jsf/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-09-05 14:20:43 -0400 (Wed, 05 Sep 2007)
New Revision: 2787
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java
Log:
http://jira.jboss.com/jira/browse/RF-826
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2007-09-05 18:11:56 UTC (rev 2786)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2007-09-05 18:20:43 UTC (rev 2787)
@@ -29,8 +29,6 @@
import javax.faces.el.ValueBinding;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.component.AjaxSupport;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
/**
@@ -104,7 +102,7 @@
if (_component == null) {
UIComponent uiComponent = facesContext.getViewRoot().findComponent(
_componentId);
- if (null != uiComponent && uiComponent instanceof AjaxComponent) {
+ if (null != uiComponent && uiComponent instanceof AjaxSupport) {
_component = (AjaxSupport) uiComponent;
} else {
throw new EvaluationException(Messages.getMessage(
18 years, 8 months
JBoss Rich Faces SVN: r2786 - in trunk/samples/richfaces-demo/src/main: webapp/richfaces/dataTable and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ishabalov
Date: 2007-09-05 14:11:56 -0400 (Wed, 05 Sep 2007)
New Revision: 2786
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml
Log:
More extended data model sample
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java 2007-09-05 17:46:02 UTC (rev 2785)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java 2007-09-05 18:11:56 UTC (rev 2786)
@@ -17,10 +17,10 @@
* @author ias
* This is example class that intended to demonstrate use of ExtendedDataModel and SerializableDataModel.
* This implementation intended to be used as a request scope bean. However, it actually provides serialized
- * state, so on a post-back we do not load data from the data provider. Instead we use whatever data was used
+ * state, so on a post-back we do not load data from the data provider. Instead we use data that was used
* during rendering.
- * This data model intended to be used together with Data Provider, which is responsible for actual data load
- * from the database using specific filtering and sorting. Normally it suppose to be in either session, or conversation
+ * This data model must be used together with Data Provider, which is responsible for actual data load
+ * from the database using specific filtering and sorting. Normally Data Provider must be in either session, or conversation
* scope.
*/
public class AuctionDataModel extends SerializableDataModel {
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java 2007-09-05 17:46:02 UTC (rev 2785)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java 2007-09-05 18:11:56 UTC (rev 2786)
@@ -3,6 +3,7 @@
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
public class AuctionItem {
private Integer pk;
@@ -60,25 +61,23 @@
public void setQtyAvialable(Integer qtyAvialable) {
this.qtyAvialable = qtyAvialable;
}
- public String placeBid() {
- if (qtyRequested!=null && bid!=null) {
+ public void placeBid(ActionEvent event) {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ if (bid!=null) {
System.out.println("place bid for pk="+getPk()+" bid="+getBid()+" qty="+getQtyRequested());
- FacesContext ctx = FacesContext.getCurrentInstance();
- if (qtyRequested>qtyAvialable) {
- ctx.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Requested quantity is grater that avialable quantity","You cannot request more auction items, that actually avialable on auction"));
- won = loose = false;
- } else if (bid<=highestBid) {
- ctx.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,"Bid amount is lower that highest bid","You need to bid amount higher that highest bid"));
+ if (bid<=highestBid) {
+ ctx.addMessage(event.getComponent().getClientId(ctx), new FacesMessage(FacesMessage.SEVERITY_WARN,"Bid amount is lower that highest bid","You need to bid amount higher that highest bid"));
won = false;
loose = true;
} else {
highestBid = bid;
won = true;
loose = false;
- amount = qtyRequested*bid;
+ amount = bid;
}
+ } else {
+ ctx.addMessage(event.getComponent().getClientId(ctx), new FacesMessage(FacesMessage.SEVERITY_ERROR,"Bid value is missing","You must provide bid value"));
}
- return null;
}
public UIComponent getBidInput() {
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml 2007-09-05 17:46:02 UTC (rev 2785)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/examples/extendedDataModel.xhtml 2007-09-05 18:11:56 UTC (rev 2786)
@@ -4,13 +4,11 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
-
- <rich:messages />
-
+ <rich:messages />
<h:form>
<rich:datascroller for="auction" maxPages="5"/>
<rich:spacer height="30" />
- <rich:dataTable id="auction" value="#{auctionDataModel}" var="item" rows="25">
+ <rich:dataTable id="auction" value="#{auctionDataModel}" var="item" rows="10">
<rich:column>
<f:facet name="header">
<h:outputText value="Description"/>
@@ -27,29 +25,17 @@
</rich:column>
<rich:column>
<f:facet name="header">
- <h:outputText value="Qty Avialable"/>
- </f:facet>
- <h:outputText value="#{item.qtyAvialable}"/>
- </rich:column>
- <rich:column>
- <f:facet name="header">
<h:outputText value="Your Bid"/>
</f:facet>
<h:inputText id="bid" value="#{item.bid}">
<f:convertNumber />
</h:inputText>
- <a4j:commandLink action="#{item.placeBid}" value="Bid!" reRender="bid,qty,amount,highestBid" />
+ <a4j:commandLink id="bid_link" actionListener="#{item.placeBid}" value="Place a bid!" reRender="bid,amount,highestBid" />
+ <rich:message for="bid_link" />
+ <rich:message for="bid" />
</rich:column>
<rich:column>
<f:facet name="header">
- <h:outputText value="Your Qty"/>
- </f:facet>
- <h:inputText id="qty" value="#{item.qtyRequested}">
- <f:convertNumber />
- </h:inputText>
- </rich:column>
- <rich:column>
- <f:facet name="header">
<h:outputText value="Amount"/>
</f:facet>
<h:outputText id="amount" value="#{item.amount}" >
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml 2007-09-05 17:46:02 UTC (rev 2785)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/extended-data-model.xhtml 2007-09-05 18:11:56 UTC (rev 2786)
@@ -7,7 +7,29 @@
xmlns:rich="http://richfaces.org/rich">
<ui:composition template="/templates/component-sample.xhtml">
<ui:define name="sample">
- <p>Some explanation how to use ExtendedDataModel will be here
+ <p>
+Perhaps the most obvious problem of DataTable and javax.faces.model.DataModel is lack of support for more complicated scenarios that uses
+data from the database.
+To solve that problem <b>Richfaces</b> has two major tools:
+<ul>
+ <li>
+ set of data-driven components that render data sets in many different ways (<b>rich:dataTable</b> , <b>rich:dataGrid</b>, <b>rich:dataList</b>, <b>a4j:repeat</b> etc.).
+ All this components derived it common functionality from the common core that, in addition to standard javax.faces.model.DataModel,
+ can understand and use
+ </li>
+ <li>
+ extended data model classes <b>org.ajax4jsf.model.ExtendedDataModel</b> and <b>org.ajax4jsf.model.SerializableDataModel</b>. This two classes works
+ together to provide functions that missing in standard DataModel.
+ </li>
+</ul>
+The most important additional functions are:
+<ul>
+ <li>access for rows by primary keys instead of index position</li>
+ <li>implementation of "visitor" pattern over the "range" of rows to support "table scroller" or "paginator" functions</li>
+ <li>ability to serialize table data so it may be used on a post-back processing without additional database query</li>
+</ul>
+To use this extensions you need to implement your own DataModel that extends one of our ExtendedDataModel classes and implement few of
+important functions. Below is the example of such implementation.
</p>
<div class="sample-container" >
@@ -18,7 +40,7 @@
</ui:include>
<ui:include src="/templates/include/sourceview.xhtml">
- <ui:param name="sourcepath" value="/WEB-INF/src/org/richfaces/datatable/ExpenseReport.java"/>
+ <ui:param name="sourcepath" value="/WEB-INF/src/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java"/>
<ui:param name="openlabel" value="View Page Source" />
</ui:include>
18 years, 8 months