Author: nbelaevski
Date: 2009-07-31 07:19:57 -0400 (Fri, 31 Jul 2009)
New Revision: 15073
Added:
root/ui-sandbox/trunk/components/core/
root/ui-sandbox/trunk/components/core/src/
root/ui-sandbox/trunk/components/core/src/main/
root/ui-sandbox/trunk/components/core/src/main/java/
root/ui-sandbox/trunk/components/core/src/main/java/org/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/ResourceBundleMap.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandButton.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandLink.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxForm.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxStatus.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIInclude.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UILoadBundle.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPortlet.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIQueue.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIRepeat.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIResource.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/RowKeyConverterRule.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/VariableMapperWrapper.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/package-info.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/package-info.java
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonGradientImage.java
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonInverseGradientImage.java
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderGradientImage.java
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderInverseGradientImage.java
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/InputGradientImage.java
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuGradientImage.java
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuInverseGradientImage.java
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabGradientImage.java
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabInverseGradientImage.java
Log:
Preparation for ALPHA1
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/ResourceBundleMap.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/ResourceBundleMap.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/ResourceBundleMap.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/ResourceBundleMap.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,142 @@
+/**
+ * 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 java.util.Collection;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * Very limited Map decorator to ResourceBundle.
+ * @author shura
+ *
+ */
+public class ResourceBundleMap implements Map<String, Object> {
+
+ private ResourceBundle _bundle;
+
+ /**
+ * @param bundle
+ */
+ public ResourceBundleMap(ResourceBundle bundle) {
+ super();
+ _bundle = bundle;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#size()
+ */
+ public int size() {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#isEmpty()
+ */
+ public boolean isEmpty() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#containsKey(java.lang.Object)
+ */
+ public boolean containsKey(Object key) {
+
+ try {
+ _bundle.getObject(key.toString());
+ return true;
+ } catch (MissingResourceException e) {
+ return false;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#containsValue(java.lang.Object)
+ */
+ public boolean containsValue(Object value) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#get(java.lang.Object)
+ */
+ public Object get(Object key) {
+ try {
+ return _bundle.getObject(key.toString());
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+ */
+ public Object put(String arg0, Object arg1) {
+ throw new
UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_PUT_VALUE));
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#remove(java.lang.Object)
+ */
+ public Object remove(Object key) {
+ throw new
UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_REMOVE_VALUE));
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.util.Map#clear()
+ */
+ public void clear() {
+ throw new
UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_REMOVE_VALUE));
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#keySet()
+ */
+ public Set<String> keySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#values()
+ */
+ public Collection<Object> values() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Set<java.util.Map.Entry<String, Object>> entrySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void putAll(Map<? extends String, ? extends Object> t) {
+ throw new
UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_PUT_VALUE));
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandButton.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandButton.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandButton.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandButton.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:28 $
+ *
+ */
+public abstract class UIAjaxCommandButton extends AjaxActionComponent {
+ public static final String COMPONENT_TYPE="org.ajax4jsf.CommandButton";
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandLink.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandLink.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandLink.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxCommandLink.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
+ *
+ */
+public abstract class UIAjaxCommandLink extends AjaxActionComponent {
+
+ public static final String COMPONENT_TYPE="org.ajax4jsf.CommandLink";
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxForm.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxForm.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxForm.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxForm.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,181 @@
+/**
+ * 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 java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.event.AjaxListener;
+import org.ajax4jsf.event.AjaxSource;
+
+
+/**
+ * Quite different from default <code>HtmlForm</code> - process child
components
+ * not only for submitted form, but if submitted parent
<code>AjaxContainer</code>
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:22 $
+ *
+ */
+public abstract class UIAjaxForm extends UIForm implements AjaxComponent, AjaxSource,
IterationStateHolder
+{
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Form";
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponent#processDecodes(javax.faces.context.FacesContext)
+ */
+ public void processDecodes(javax.faces.context.FacesContext context)
+ {
+ if (context == null) {
+ throw new NullPointerException("context");
+ }
+ decode(context);
+ if (mustProcessed(context))
+ {
+ for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+ {
+ UIComponent childOrFacet = (UIComponent) it.next();
+ childOrFacet.processDecodes(context);
+ }
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponent#processValidators(javax.faces.context.FacesContext)
+ */
+ public void processValidators(javax.faces.context.FacesContext context)
+ {
+ if (context == null) throw new NullPointerException("context");
+ if (mustProcessed(context))
+ {
+ for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+ {
+ UIComponent childOrFacet = (UIComponent) it.next();
+ childOrFacet.processValidators(context);
+ }
+ }
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponent#processUpdates(javax.faces.context.FacesContext)
+ */
+ public void processUpdates(javax.faces.context.FacesContext context)
+ {
+ if (context == null) throw new NullPointerException("context");
+ if (mustProcessed(context))
+ {
+ for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+ {
+ UIComponent childOrFacet = (UIComponent) it.next();
+ childOrFacet.processUpdates(context);
+ }
+ }
+ }
+
+ /**
+ * Test for condition processing decoders/validators/updates
+ * @param context current <code>FacesContext</code>
+ * @return true if submitted parent AjaxContainer or current form.
+ */
+ private boolean mustProcessed(FacesContext context)
+ {
+// if ( !AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
+ if (!isSubmitted() ) {
+ return false;
+ }
+// }
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ // perform default
+ super.broadcast(event);
+ if (event instanceof AjaxEvent) {
+ // complete re-Render fields. AjaxEvent deliver before render response.
+ setupReRender();
+ }
+ }
+
+
+ /**
+ * Template methods for fill set of resions to render in subclasses.
+ */
+ protected void setupReRender() {
+ FacesContext context = getFacesContext();
+ AjaxContext.getCurrentInstance(context).addRegionsFromComponent(this);
+ }
+
+
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxSource#addAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
+ */
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.ajax.AjaxSource#getAjaxListeners()
+ */
+ public AjaxListener[] getAjaxListeners() {
+ AjaxListener al[] = (AjaxListener [])
+ getFacesListeners(AjaxListener.class);
+ return (al);
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxSource#removeAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
+ */
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
+
+ }
+
+ public abstract boolean isAjaxSubmit();
+
+ public abstract void setAjaxSubmit(boolean ajax);
+
+ public Object getIterationState() {
+ return isSubmitted() ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public void setIterationState(Object state) {
+ setSubmitted(Boolean.TRUE.equals(state));
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,289 @@
+/**
+ * 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 java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.el.MethodExpression;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIPanel;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.event.AjaxListener;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/08 15:02:06 $
+ *
+ */
+public abstract class UIAjaxRegion extends UIPanel implements AjaxContainer {
+
+ private AjaxRegionBrige brige;
+
+ private static final ContextCallback decodeCallback= new ContextCallback(){
+ public void invokeContextCallback(FacesContext context,
+ UIComponent target) {
+ target.processDecodes(context);
+ }
+ };
+
+ private static final ContextCallback validateCallback= new ContextCallback(){
+ public void invokeContextCallback(FacesContext context,
+ UIComponent target) {
+ target.processValidators(context);
+ }
+ };
+
+ private static final ContextCallback updateCallback= new ContextCallback(){
+ public void invokeContextCallback(FacesContext context,
+ UIComponent target) {
+ target.processUpdates(context);
+ }
+ };
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.AjaxRegion";
+
+ /**
+ *
+ */
+ public UIAjaxRegion() {
+ brige = new AjaxRegionBrige(this);
+ }
+
+ @Override
+ public void processDecodes(FacesContext context) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ String ajaxSingleClientId = ajaxContext.getAjaxSingleClientId();
+ // Process this component itself
+ try {
+ decode(context);
+ } catch (RuntimeException e) {
+ context.renderResponse();
+ throw e;
+ }
+ if (ajaxContext.isAjaxRequest() && null != ajaxSingleClientId) {
+ invokeOnComponent(context, ajaxSingleClientId, new
ContextCallbackWrapper(decodeCallback));
+ Set<String> areasToProcess = ajaxContext.getAjaxAreasToProcess();
+ if(null != areasToProcess){
+ for (String areaId : areasToProcess) {
+ invokeOnComponent(context, areaId, new ContextCallbackWrapper(decodeCallback));
+ }
+ }
+ } else {
+ // Process all facets and children of this component
+ Iterator<UIComponent> kids = getFacetsAndChildren();
+ while (kids.hasNext()) {
+ UIComponent kid = kids.next();
+ kid.processDecodes(context);
+ }
+ }
+ }
+
+ @Override
+ public void processValidators(FacesContext context) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ String ajaxSingleClientId = ajaxContext.getAjaxSingleClientId();
+ if (ajaxContext.isAjaxRequest() && null != ajaxSingleClientId) {
+ invokeOnComponent(context, ajaxSingleClientId, new
ContextCallbackWrapper(validateCallback));
+ Set<String> areasToProcess = ajaxContext.getAjaxAreasToProcess();
+ if(null != areasToProcess){
+ for (String areaId : areasToProcess) {
+ invokeOnComponent(context, areaId, new ContextCallbackWrapper(validateCallback));
+ }
+ }
+ } else {
+ super.processValidators(context);
+ }
+ }
+
+ @Override
+ public void processUpdates(FacesContext context) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ String ajaxSingleClientId = ajaxContext.getAjaxSingleClientId();
+ if (ajaxContext.isAjaxRequest() && null != ajaxSingleClientId) {
+ invokeOnComponent(context, ajaxSingleClientId, new
ContextCallbackWrapper(updateCallback));
+ Set<String> areasToProcess = ajaxContext.getAjaxAreasToProcess();
+ if(null != areasToProcess){
+ for (String areaId : areasToProcess) {
+ invokeOnComponent(context, areaId, new ContextCallbackWrapper(updateCallback));
+ }
+ }
+ } else {
+ super.processUpdates(context);
+ }
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+ brige.broadcast(event);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#getAjaxListener()
+ */
+ public MethodExpression getAjaxListener() {
+ return brige.getAjaxListener();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isImmediate()
+ */
+ public boolean isImmediate() {
+ return brige.isImmediate();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSubmitted()
+ */
+ public boolean isSubmitted() {
+ return brige.isSubmitted();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#restoreState(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ Object[] mystate = (Object[]) state;
+ super.restoreState(context, mystate[0]);
+ brige.restoreState(context, mystate[1]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[2];
+ state[0] = super.saveState(context);
+ state[1] = brige.saveState(context);
+ return state;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#setAjaxListener(javax.faces.el.MethodBinding)
+ */
+ public void setAjaxListener(MethodExpression ajaxListener) {
+ brige.setAjaxListener(ajaxListener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate) {
+ brige.setImmediate(immediate);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSubmitted(boolean)
+ */
+ public void setSubmitted(boolean submitted) {
+ brige.setSubmitted(submitted);
+ }
+
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
+
+ public AjaxListener[] getAjaxListeners() {
+ return (AjaxListener[]) getFacesListeners(AjaxListener.class);
+ }
+
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSelfRendered()
+ */
+ public boolean isSelfRendered() {
+ return brige.isSelfRendered();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSelfRendered(boolean)
+ */
+ public void setSelfRendered(boolean selfRendered) {
+ brige.setSelfRendered(selfRendered);
+ }
+
+ public void encodeAjax(FacesContext context) throws IOException {
+ String rendererType = getRendererType();
+ if (rendererType != null) {
+ ((AjaxContainerRenderer) getRenderer(context)).encodeAjax(context,
+ this);
+ }
+
+ }
+
+
+ /**
+ * @return
+ * @see org.ajax4jsf.component.AjaxRegionBrige#isTransient()
+ */
+ public boolean isTransient() {
+ return brige.isTransient();
+ }
+
+
+ /**
+ * @param transientFlag
+ * @see org.ajax4jsf.component.AjaxRegionBrige#setTransient(boolean)
+ */
+ public void setTransient(boolean transientFlag) {
+ brige.setTransient(transientFlag);
+ }
+
+
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxStatus.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxStatus.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxStatus.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxStatus.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,383 @@
+/**
+ * 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 java.io.Serializable;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
+
+
+/**
+ *
+ * Component for create request state status area.
+ * can create 2 output text areas ( <span> ) with different text and
styles.
+ * if defined "start" or/and "stop" facets, it's use as conttent
+ * for different state.
+ * By default, "start" text/facet rendered with display = none style.
+ * On client side, display style changed for elements on
+ * start-stop request.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:25 $
+ *
+ */
+public class UIAjaxStatus extends UIComponentBase
+{
+
+ private static final String COMPONENT_FAMILY = "javax.faces.Output";
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.AjaxStatus";
+
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ /**
+ * id of form for wich status will displayed
+ */
+ private String _for = null;
+
+ /**
+ *
+ * @param new value of id of form for wich status will displayed to set
+ */
+ public void setFor(String _for)
+ {
+ this._for = _for;
+ }
+
+ /**
+ * @return value or result of valueBinding of id of form for wich status will
displayed
+ *
+ */
+ public String getFor()
+ {
+ return (String) getValueOrBinding(_for, "for");
+ }
+
+ /**
+ * Text to output on start request
+ */
+ private String _startText = null;
+
+ /**
+ * setter method for property
+ * @param new value of Text to output on start request to set
+ */
+ public void setStartText(String startText)
+ {
+ this._startText = startText;
+ }
+
+ /**
+ * @return value or result of valueBinding of Text to output on start request
+ */
+ public String getStartText()
+ {
+ return (String) getValueOrBinding(_startText, "startText");
+ }
+
+ /**
+ * Text to display on complete request
+ */
+ private String _stopText = null;
+
+ /**
+ * setter method for property
+ * @param new value of Text to display on complete request to set
+ */
+ public void setStopText(String stopText)
+ {
+ this._stopText = stopText;
+ }
+
+ /**
+ * @return value or result of valueBinding of Text to display on complete request
+ */
+ public String getStopText()
+ {
+ return (String) getValueOrBinding(_stopText, "stopText");
+ }
+ /**
+ * Style for display on start request
+ */
+ private String _startStyle = null;
+
+ /**
+ * setter method for property
+ * @param new value of Style for display on start request to set
+ */
+ public void setStartStyle(String startStyle)
+ {
+ this._startStyle = startStyle;
+ }
+
+ /**
+ * @return value or result of valueBinding of Style for display on start request
+ */
+ public String getStartStyle()
+ {
+ return (String) getValueOrBinding(_startStyle, "startStyle");
+ }
+ /**
+ * Style for displaying on complete
+ */
+ private String _stopStyle = null;
+
+ /**
+ * setter method for property
+ * @param new value of Style for displaying on complete to set
+ */
+ public void setStopStyle(String stopStyle)
+ {
+ this._stopStyle = stopStyle;
+ }
+
+ /**
+ * @return value or result of valueBinding of Style for displaying on complete
+ */
+ public String getStopStyle()
+ {
+ return (String) getValueOrBinding(_stopStyle, "stopStyle");
+ }
+ /**
+ * Style class for display on request
+ */
+ private String _startStyleClass = null;
+
+ /**
+ * setter method for property
+ * @param new value of Style class for display on request to set
+ */
+ public void setStartStyleClass(String startStyleClass)
+ {
+ this._startStyleClass = startStyleClass;
+ }
+
+ /**
+ * @return value or result of valueBinding of Style class for display on request
+ */
+ public String getStartStyleClass()
+ {
+ return (String) getValueOrBinding(_startStyleClass,
"startStyleClass");
+ }
+ /**
+ * Style class for display on complete request
+ */
+ private String _stopStyleClass = null;
+
+ /**
+ * setter method for property
+ * @param new value of Style class for display on complete request to set
+ */
+ public void setStopStyleClass(String stopStyleClass)
+ {
+ this._stopStyleClass = stopStyleClass;
+ }
+
+
+ /**
+ * Force id to render in Html as is
+ */
+ private boolean _forceId = false;
+ private boolean _forceIdSet = false;
+
+ /**
+ * setter method for property
+ * @param new value of Force id to render in Html as is to set
+ */
+ public void setForceId(boolean forceId)
+ {
+ this._forceId = forceId;
+ this._forceIdSet = true;
+ }
+
+ /**
+ * @return value or result of valueBinding of Force id to render in Html as is
+ */
+ public boolean isForceId()
+ {
+ return isValueOrBinding(_forceId, _forceIdSet, "forceId");
+ }
+
+
+
+
+ private String _clientId = null;
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#getClientId(javax.faces.context.FacesContext)
+ */
+ public String getClientId(FacesContext context) {
+ if (null == _clientId) {
+ String forValue = getFor();
+ UIComponent container;
+ if (null != forValue) {
+ container = RendererUtils.getInstance().findComponentFor(this, forValue);
+ // 'for' attribute must be pointed to real container in view tree
+ if (null == container || !(container instanceof AjaxContainer)) {
+ throw new FacesException(
+ Messages.getMessage(Messages.FOR_TARGETS_NO_AJAX_CONTAINER, getId()));
+ }
+ _clientId = container.getClientId(context) + ":status";
+
+ } else if (isForceId()) {
+ _clientId = getRenderer(context).convertClientId(context,
+ this.getId());
+ } else if (null !=(container = (UIComponent)
AjaxRendererUtils.findAjaxContainer(context,this))) {
+ _clientId = container.getClientId(context) + ":status";
+ } else {
+ _clientId = super.getClientId(context);
+ }
+ }
+ return _clientId;
+ }
+
+
+ /* (non-Javadoc)
+ * reset clientId for calculate
+ * @see javax.faces.component.UIComponentBase#setId(java.lang.String)
+ */
+ public void setId(String arg0) {
+ super.setId(arg0);
+ _clientId = null;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state)
+ {
+ State myState = (State) state;
+ _for = myState._for;
+ _startText = myState._startText;
+ _stopText = myState._stopText;
+ _startStyle = myState._startStyle;
+ _stopStyle = myState._stopStyle;
+ _startStyleClass = myState._startStyleClass;
+ _stopStyleClass = myState._stopStyleClass;
+ _forceId = myState._forceId;
+ _forceIdSet = myState._forceIdSet;
+ super.restoreState(context, myState.superState);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context)
+ {
+ State state = new State();
+ state._for = _for;
+ state._startText = _startText;
+ state._stopText = _stopText;
+ state._startStyle = _startStyle;
+ state._stopStyle = _stopStyle;
+ state._startStyleClass = _startStyleClass;
+ state._stopStyleClass = _stopStyleClass;
+ state._forceId = _forceId;
+ state._forceIdSet = _forceIdSet;
+ state.superState = super.saveState(context);
+ return state;
+ }
+
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:25 $
+ * Memento pattern state class for save-restore component.
+ */
+ public static class State implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 317266574102385358L;
+ Object superState;
+ String _for;
+ String _startText;
+ String _stopText;
+ String _startStyle;
+ String _stopStyle;
+ String _startStyleClass;
+ String _stopStyleClass;
+ boolean _forceIdSet;
+ boolean _forceId;
+ }
+
+ /**
+ * @return value or result of valueBinding of Style class for display on complete
request
+ */
+ public String getStopStyleClass()
+ {
+ return (String) getValueOrBinding(_stopStyleClass, "stopStyleClass");
+ }
+
+ /**
+ * @param field - value of field to get.
+ * @param name - name of field, to get from ValueBinding
+ * @return field or value of binding expression.
+ */
+ private Object getValueOrBinding(Object field, String name){
+ if( null != field){
+ return field;
+ }
+ ValueExpression vb = getValueExpression(name);
+ if (null != vb) {
+ return vb.getValue(getELContext());
+ } else {
+ return null;
+ }
+
+ }
+
+ /**
+ * @param field - value of field to get.
+ * @param name - name of field, to get from ValueBinding
+ * @return boolean value, based on field or valuebinding.
+ */
+ private boolean isValueOrBinding(boolean field, boolean fieldSet, String name){
+ if( fieldSet ){
+ return field;
+ }
+ ValueExpression vb = getValueExpression(name);
+ if (null != vb) {
+ return ((Boolean)vb.getValue(getELContext())).booleanValue();
+ } else {
+ return false;
+ }
+
+ }
+
+ private ELContext getELContext() {
+ return getFacesContext().getELContext();
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,164 @@
+/**
+ * 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.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Component for append ajax functions to any control component. Append action
+ * functionality to non-action control, setup javascript events for parent
+ * component,
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:52 $
+ *
+ */
+public abstract class UIAjaxSupport extends AjaxActionComponent implements
+ AjaxSupport {
+
+ // ~ Static fields/initializers
+ // ---------------------------------------------
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Support";
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.AjaxSupport";
+ public static final String DEFAULT_RENDERER_TYPE =
"org.ajax4jsf.components.AjaxSupportRenderer";
+ public static final String AJAX_SUPPORT_SET =
"com.exadel.components.ajax.support.";
+ private static final Log log = LogFactory.getLog(UIAjaxSupport.class);
+
+ @Override
+ public void setValueExpression(String name, ValueExpression binding) {
+ // var - not allowed name. must be literal.
+ if ("var".equals(name)) {
+ throw new FacesException(Messages.getMessage(
+ Messages.VAR_MUST_BE_LITERAL,
+ getClientId(getFacesContext())));
+ }
+ if ("event".equals(name)) {
+ throw new FacesException(Messages.getMessage(
+ Messages.EVENT_MUST_BE_LITERAL,
+ getClientId(getFacesContext())));
+ }
+ super.setValueExpression(name, binding);
+ }
+
+ /**
+ * Create Special <code>ValueBinding</code> for build JavaScrept event
+ * code in parent component from this.
+ *
+ * @return <code>EventValueBinding</code> based on properties of current
+ * component
+ */
+ private ValueExpression getEventValueBinding() {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.CREATE_JAVASCRIPT_EVENT,
+ getId()));
+ }
+ return new EventValueExpression(this);
+ }
+
+ /**
+ * @return JavaScript eventString. Rebuild on every call, since can be in
+ * loop ( as in dataTable ) with different parameters.
+ */
+ public String getEventString() {
+ StringBuffer buildOnEvent = new StringBuffer();
+ String onsubmit = getOnsubmit();
+ // Insert script to call before submit ajax request.
+ if (null != onsubmit) {
+ buildOnEvent.append(onsubmit).append(";");
+ }
+ buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this,
+ getFacesContext(), getEvent(), true));
+ String script = buildOnEvent.toString();
+ return script;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
+ */
+ public void decode(FacesContext context) {
+ // Due to JSF RI 1.1 bug, clear cached clientId
+ setId(getId());
+ super.decode(context);
+ }
+
+ /**
+ * After nornal setting <code>parent</code> property in case of created
+ * component set Ajax properties for parent.
+ *
+ * @see
javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
+ */
+ public void setParent(UIComponent parent) {
+ super.setParent(parent);
+ if (null != parent && parent.getFamily() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT,
+ parent.getClass().getName()));
+ }
+ // TODO If this comopnent configured, set properties for parent
+ // component.
+ // NEW created component have parent, restored view - null in My
+ // faces.
+ // and SUN RI not call at restore saved view.
+ // In other case - set in restoreState method.
+ // if (parent.getParent() != null)
+ {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages
+ .getMessage(Messages.DETECT_NEW_COMPONENT));
+ }
+ setParentProperties(parent);
+
+ }
+ }
+ }
+
+ public void setParentProperties(UIComponent parent) {
+ ValueExpression valueBinding;
+ if (null != getEvent()) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.SET_VALUE_BINDING_FOR_EVENT, getEvent()));
+ }
+ // for non action/data components, or for non-default events - build
+ // listener for this instance.
+ valueBinding = getEventValueBinding();
+ parent.setValueExpression(getEvent(), valueBinding);
+
+ }
+ }
+
+ protected UIComponent getSingleComponent() {
+ return getParent();
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIInclude.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIInclude.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIInclude.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIInclude.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,342 @@
+/**
+ * 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 java.io.IOException;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.context.ViewIdHolder;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class UIInclude extends UIComponentBase implements
+ ViewIdHolder, NamingContainer, AjaxOutput {
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Include";
+
+ public static final String LAYOUT_NONE ="none";
+
+ public static final String LAYOUT_BLOCK ="block";
+ public static final String LAYOUT_INLINE ="inline";
+
+ private boolean _ajaxRendered = false;
+ private boolean _ajaxRenderedSet = false;
+
+ private boolean wasNavigation = false;
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.ViewIdHolder#skipNavigation(java.lang.String)
+ */
+ public boolean skipNavigation(String ViewId) {
+ wasNavigation = true;
+ return true;
+ }
+
+ private String _viewId = null;
+
+ /*
+ * viewId for included page. Setter for viewId @param viewId - new value
+ */
+ public void setViewId(String __viewId) {
+ ValueExpression vb = getValueExpression("viewId");
+ ELContext elContext = getELContext();
+ if (null != vb && (!vb.isReadOnly(elContext))) {
+ // Change value of viewId in backed bean, if possible.
+ vb.setValue(elContext, __viewId);
+ } else {
+ this._viewId = __viewId;
+ }
+ }
+
+ /*
+ * viewId for included page. Getter for viewId @return viewId value from
+ * local variable or value bindings
+ */
+ public String getViewId() {
+ if (null != this._viewId) {
+ return this._viewId;
+ }
+ ValueExpression vb = getValueExpression("viewId");
+ if (null != vb) {
+ return (String) vb.getValue(getELContext());
+ } else {
+ return null;
+ }
+ }
+
+ private String _layout = null;
+
+ /**
+ * @return the layout
+ */
+ public String getLayout() {
+ if (null != this._layout) {
+ return this._layout;
+ }
+ ValueExpression vb = getValueExpression("layout");
+ if (null != vb) {
+ return (String) vb.getValue(getELContext());
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @param layout the layout to set
+ */
+ public void setLayout(String layout) {
+ _layout = layout;
+ }
+
+
+ public boolean isAjaxRendered() {
+ Boolean value = null;
+
+ if(this._ajaxRenderedSet) {
+ return this._ajaxRendered;
+ }
+
+ ValueExpression ve = getValueExpression("ajaxRendered");
+ if (ve != null) {
+ try {
+ value = (Boolean) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+ }
+
+
+ if (null == value) {
+// value = this._ajaxRendered;
+ value = isWasNavigation();
+ }
+
+ return (!LAYOUT_NONE.equals(getLayout())) && value;
+ }
+
+ public void setAjaxRendered(boolean ajaxRendered) {
+ this._ajaxRendered = ajaxRendered;
+ this._ajaxRenderedSet = true;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ if (event instanceof EventWrapper) {
+ FacesEvent wrapped = ((EventWrapper) event).getWrapped();
+ FacesContext context = getFacesContext();
+ ViewIdHolder holder = setupNavigation(context);
+ wrapped.getComponent().broadcast(wrapped);
+ restoreNavigation(context, holder);
+ } else {
+ super.broadcast(event);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#processDecodes(javax.faces.context.FacesContext)
+ */
+ public void processDecodes(FacesContext context) {
+ wasNavigation = false;
+ ViewIdHolder holder = setupNavigation(context);
+ super.processDecodes(context);
+ restoreNavigation(context, holder);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#processUpdates(javax.faces.context.FacesContext)
+ */
+ public void processUpdates(FacesContext context) {
+ ViewIdHolder holder = setupNavigation(context);
+ super.processUpdates(context);
+ restoreNavigation(context, holder);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#processValidators(javax.faces.context.FacesContext)
+ */
+ public void processValidators(FacesContext context) {
+ ViewIdHolder holder = setupNavigation(context);
+ super.processValidators(context);
+ restoreNavigation(context, holder);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
+ */
+ public void queueEvent(FacesEvent event) {
+ EventWrapper wrapper = new EventWrapper(this, event);
+ super.queueEvent(wrapper);
+ }
+
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ Object[] componentState = (Object[]) state;
+ super.restoreState(context, componentState[0]);
+ this._viewId = (String) componentState[1];
+ this._layout = (String) componentState[2];
+ this._ajaxRendered = ((Boolean) componentState[3]).booleanValue();
+ this._ajaxRenderedSet = ((Boolean) componentState[4]).booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ Object[] componentState = new Object[5];
+ componentState[0] = super.saveState(context);
+ componentState[1] = _viewId;
+ componentState[2] = _layout;
+ componentState[3] = Boolean.valueOf(_ajaxRendered);
+ componentState[4] = Boolean.valueOf(_ajaxRenderedSet);
+ return componentState;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ private ViewIdHolder setupNavigation(FacesContext context) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ViewIdHolder viewIdHolder = ajaxContext.getViewIdHolder();
+ ajaxContext.setViewIdHolder(this);
+ return viewIdHolder;
+ }
+
+ private void restoreNavigation(FacesContext context, ViewIdHolder viewIdHolder) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ajaxContext.setViewIdHolder(viewIdHolder);
+// if (wasNavigation) {
+// // Clear children to avoid have different components with same id
+// getChildren().clear();
+// }
+ }
+
+ private ELContext getELContext() {
+ return getFacesContext().getELContext();
+ }
+
+ @SuppressWarnings("serial")
+ private static class EventWrapper extends FacesEvent {
+
+ private FacesEvent wrapped;
+
+ public EventWrapper(UIComponent component, FacesEvent wrapped) {
+ super(component);
+ this.wrapped = wrapped;
+ }
+
+ /**
+ * @return
+ * @see javax.faces.event.FacesEvent#getPhaseId()
+ */
+ public PhaseId getPhaseId() {
+ return wrapped.getPhaseId();
+ }
+
+ /**
+ * @param listener
+ * @return
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return wrapped.isAppropriateListener(listener);
+ }
+
+ /**
+ * @param listener
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ wrapped.processListener(listener);
+ }
+
+ /**
+ *
+ * @see javax.faces.event.FacesEvent#queue()
+ */
+ public void queue() {
+ wrapped.queue();
+ }
+
+ /**
+ * @param phaseId
+ * @see javax.faces.event.FacesEvent#setPhaseId(javax.faces.event.PhaseId)
+ */
+ public void setPhaseId(PhaseId phaseId) {
+ wrapped.setPhaseId(phaseId);
+ }
+
+ /**
+ * @return the wrapped
+ */
+ public FacesEvent getWrapped() {
+ return wrapped;
+ }
+ }
+
+ /**
+ * @return the wasNavigation
+ */
+ public boolean isWasNavigation() {
+ return wasNavigation;
+ }
+
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UILoadBundle.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UILoadBundle.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UILoadBundle.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UILoadBundle.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,127 @@
+/**
+ * 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 java.io.IOException;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class UILoadBundle extends UIComponentBase implements
AjaxLoadBundleComponent {
+
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Bundle";
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Bundle";
+
+ private static final Log _log = LogFactory.getLog(UILoadBundle.class);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return COMPONENT_FAMILY;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
+ */
+ public void encodeBegin(FacesContext context) throws IOException {
+ loadBundle(context);
+
+ }
+
+ public void decode(FacesContext context) {
+ loadBundle(context);
+ }
+ /**
+ * @param context
+ */
+ public void loadBundle(FacesContext context) {
+ UIViewRoot viewRoot = context.getViewRoot();
+ Locale locale = viewRoot.getLocale();
+ if (locale == null) {
+ locale = context.getApplication().getDefaultLocale();
+ }
+
+ ResourceBundle bundle;
+ try {
+ bundle = ResourceBundle.getBundle(getBasename(), locale, Thread
+ .currentThread().getContextClassLoader());
+ } catch (MissingResourceException e) {
+ _log.error(Messages.getMessage(Messages.COULD_NOT_LOAD_RESOURCE_BUNDLE,
getBasename()));
+ return;
+ }
+
+ context.getExternalContext().getRequestMap().put(getVar(),
+ new ResourceBundleMap(bundle));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#getRendererType()
+ */
+ public String getRendererType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @return Returns the basename.
+ */
+ public abstract String getBasename();
+
+ /**
+ * @param basename
+ * The basename to set.
+ */
+ public abstract void setBasename(String basename);
+
+ /**
+ * @return Returns the var.
+ */
+ public abstract String getVar();
+
+ /**
+ * @param var
+ * The var to set.
+ */
+ public abstract void setVar(String var);
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPortlet.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPortlet.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPortlet.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIPortlet.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,73 @@
+/**
+ * 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.NamingContainer;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class UIPortlet extends UIComponentBase implements NamingContainer {
+
+
+ private static final Log _log = LogFactory.getLog(UIPortlet.class);
+ /**
+ * <p>The standard component type for this component.</p>
+ */
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Portlet";
+
+
+ /**
+ * <p>The standard component family for this component.</p>
+ */
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Portlet";
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return COMPONENT_FAMILY;
+ }
+
+ private String portletId = null;
+
+ @Override
+ public void setId(String id) {
+ portletId = null;
+ super.setId(id);
+ }
+
+ // ----------------------------------------------------- UIComponent Methods
+ public String getClientId(FacesContext context) {
+ if (portletId == null) {
+ portletId =
context.getExternalContext().encodeNamespace(super.getClientId(context));
+ }
+ return portletId;
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIQueue.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIQueue.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIQueue.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIQueue.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,124 @@
+/**
+ * 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.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIForm;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public abstract class UIQueue extends UIComponentBase {
+
+ public static final String GLOBAL_QUEUE_NAME = "org.richfaces.queue.global";
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Queue";
+
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Queue";
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ public abstract String getOnsubmit();
+ public abstract void setOnsubmit(String onsubmit);
+
+ public abstract String getOncomplete();
+ public abstract void setOncomplete(String oncomplete);
+
+ public abstract String getOnbeforedomupdate();
+ public abstract void setOnbeforedomupdate(String onbeforedomupdate);
+
+ public abstract String getOnerror();
+ public abstract void setOnerror(String onerror);
+
+ public abstract String getOnsizeexceeded();
+ public abstract void setOnsizeexceeded(String onsizeexceeded);
+
+ public abstract boolean isDisabled();
+ public abstract void setDisabled(boolean disabled);
+
+ public abstract int getSize();
+ public abstract void setSize(int size);
+
+ public abstract String getSizeExceededBehavior();
+ public abstract void setSizeExceededBehavior(String behavior);
+
+ public abstract int getTimeout();
+ public abstract void setTimeout(int timeout);
+
+ public abstract int getRequestDelay();
+ public abstract void setRequestDelay(int requestDelay);
+
+ public abstract boolean isIgnoreDupResponses();
+ public abstract void setIgnoreDupResponses(boolean ignoreDupResponses);
+
+ public abstract String getOnrequestqueue();
+ public abstract void setOnrequestqueue(String onrequestqueue);
+
+ public abstract String getOnrequestdequeue();
+ public abstract void setOnrequestdequeue(String onrequestdequeue);
+
+ public abstract String getStatus();
+ public abstract void setStatus(String status);
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ private UIComponent findParentForm() {
+ UIComponent component = getParent();
+ while (component != null && !(component instanceof UIForm)) {
+ component = component.getParent();
+ }
+
+ return component;
+ }
+
+ public String getClientName(FacesContext context) {
+ UIComponent form = findParentForm();
+ String name = getName();
+ String clientName;
+
+ if (form != null) {
+ String formClientId = form.getClientId(context);
+
+ if (name != null && name.length() != 0) {
+ clientName = formClientId + NamingContainer.SEPARATOR_CHAR + name;
+ } else {
+ clientName = formClientId;
+ }
+ } else {
+ if (name == null || name.length() == 0) {
+ name = GLOBAL_QUEUE_NAME;
+ }
+
+ clientName = context.getExternalContext().encodeNamespace(name);
+ }
+
+ return clientName;
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIRepeat.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIRepeat.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIRepeat.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIRepeat.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,51 @@
+/**
+ * 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 java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+
+
+/**
+ * @author shura
+ *
+ */
+public class UIRepeat extends SequenceDataAdaptor {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#dataChildren()
+ */
+ protected Iterator<UIComponent> dataChildren() {
+ // TODO Auto-generated method stub
+ return getChildren().iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#fixedChildren()
+ */
+ protected Iterator<UIComponent> fixedChildren() {
+ // TODO Auto-generated method stub
+ return getFacets().values().iterator();
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIResource.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/UIResource.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIResource.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/component/UIResource.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,49 @@
+/**
+ * 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.UIComponentBase;
+
+/**
+ * JSF component class
+ *
+ */
+public abstract class UIResource extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Resource";
+
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Resource";
+
+ /**
+ * Get name of script to load
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract Object getSrc();
+
+ /**
+ * @param newSrc the value to set
+ */
+ public abstract void setSrc(Object newSrc);
+
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,342 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.component.UIAjaxForm;
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
+
+/**
+ * @author shura
+ *
+ */
+public class AjaxFormRenderer extends AjaxComponentRendererBase {
+
+ public static final String FORM_SUBMIT_FUNCTION_NAME = "_JSFFormSubmit";
+
+ public static final String FORM_CLEAR_FUNCTION_NAME =
"_clearJSFFormParameters";
+
+ private static final String FORM_HAS_COMMAND_LINK_ATTR =
"com.sun.faces.FORM_HAS_COMMAND_LINK_ATTR";
+
+ private static final String NO_COMMAND_LINK_FOUND_VALUE =
"com.sun.faces.NO_COMMAND_LINK_FOUND";
+
+ public static final String CONTENT_TYPE_IS_XHTML = "com.sun.faces"
+ + "ContentTypeIsXHTML";
+
+ public static final String HIDDEN_FIELD_SUFFIX = NamingContainer.SEPARATOR_CHAR
+ + UIViewRoot.UNIQUE_ID_PREFIX + "cl";
+
+ private static final String HIDDEN_COMMAND_INPUTS_SET_ATTR = UIForm.class
+ .getName()
+ + ".org.apache.myfaces.HIDDEN_COMMAND_INPUTS_SET";
+
+ private static final String MYFACES_HIDDEN_FIELD_SUFFIX =
NamingContainer.SEPARATOR_CHAR
+ + "_link_hidden_";
+
+ private InternetResource[] _scripts = {
getResource("/org/ajax4jsf/javascript/scripts/form.js") };
+
+ private static final String[] exclusions = { "onsubmit" };
+
+ public static final String AJAX_FORM_FUNCTION_NAME = "A4J.AJAX.SubmitForm";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#doDecode(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ protected void doDecode(FacesContext context, UIComponent component) {
+ UIForm form = (UIForm) component;
+ boolean submitted = context.getExternalContext()
+ .getRequestParameterMap().containsKey(
+ component.getClientId(context));
+ form.setSubmitted(submitted);
+ if (component instanceof UIAjaxForm) {
+ UIAjaxForm ajaxForm = (UIAjaxForm) component;
+ if (submitted && ajaxForm.isAjaxSubmit()) {
+ component.queueEvent(new AjaxEvent(component));
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.HeaderResourcesRendererBase#getScripts()
+ */
+ protected InternetResource[] getAdditionalScripts() {
+ // TODO Auto-generated method stub
+ return _scripts;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
+ UIComponent component) throws IOException {
+ String clientId = component.getClientId(context);
+ writer.startElement(HTML.FORM_ELEMENT, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null);
+ writer.writeAttribute(HTML.METHOD_ATTRIBUTE, "post", null);
+ getUtils().encodeAttribute(context, component, "style");
+ getUtils().encodeAttribute(context, component, "class");
+ getUtils().encodePassThru(context, component);
+ context.getExternalContext().getRequestMap().put(
+ FORM_HAS_COMMAND_LINK_ATTR, clientId);
+ if (component instanceof UIAjaxForm) {
+ UIAjaxForm form = (UIAjaxForm) component;
+ if (form.isAjaxSubmit()) {
+ StringBuffer onSubmit = new StringBuffer("javascript:");
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
+ component, context,
+ AJAX_FORM_FUNCTION_NAME);
+ ajaxFunction.addParameter(AjaxRendererUtils.buildEventOptions(
+ context, component, false));
+ ajaxFunction.appendScript(onSubmit);
+ writer.writeURIAttribute("action", onSubmit, "action");
+ } else {
+ encodeSubmitAction(writer, context);
+ }
+ } else {
+ encodeSubmitAction(writer, context);
+ }
+ }
+
+ /**
+ * @param writer
+ * @param context
+ * @throws IOException
+ */
+ private void encodeSubmitAction(ResponseWriter writer, FacesContext context)
+ throws IOException {
+ String actionURL = getUtils().getActionUrl(context);
+ String encodedActionURL = context.getExternalContext().encodeActionURL(
+ actionURL);
+ writer.writeURIAttribute("action", encodedActionURL, "action");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
+ UIComponent component) throws IOException {
+ // Encode form submitting flag hidden field.
+ String clientId = component.getClientId(context);
+ renderHiddenInputField(writer, clientId, clientId);
+ renderHiddenInputField(writer, "autoScroll", null);
+ // MyFaces compability - render hidden field and Script.
+ // render hidden command inputs
+ Set hiddenFields = new HashSet();
+ hiddenFields.add(clientId + HIDDEN_FIELD_SUFFIX);
+ hiddenFields.add(clientId + MYFACES_HIDDEN_FIELD_SUFFIX);
+ Set set = (Set) component.getAttributes().get(
+ HIDDEN_COMMAND_INPUTS_SET_ATTR);
+ if (set != null) {
+ hiddenFields.addAll(set);
+ }
+ set = (Set) context.getExternalContext().getRequestMap().get(
+ getHiddenCommandInputsSetName(context, component));
+ if (set != null) {
+ hiddenFields.addAll(set);
+ }
+ renderHiddenCommandFormParams(writer, hiddenFields);
+ String target;
+ if (component instanceof HtmlForm) {
+ target = ((HtmlForm) component).getTarget();
+ } else {
+ target = (String) component.getAttributes().get(
+ HTML.target_ATTRIBUTE);
+ }
+ renderClearHiddenCommandFormParamsFunction(writer, clientId, hiddenFields, target);
+ // Script
+ if (component instanceof UIAjaxForm) {
+ UIAjaxForm form = (UIAjaxForm) component;
+ if (form.isAjaxSubmit()) {
+ renderAjaxFormSetupScript(writer, clientId);
+ }
+ }
+ // writeFormSubmitScript(context, writer);
+ getUtils().encodeEndForm(context, writer);
+ context.getExternalContext().getRequestMap().put(
+ FORM_HAS_COMMAND_LINK_ATTR, NO_COMMAND_LINK_FOUND_VALUE);
+ }
+
+ private static String getHiddenCommandInputsSetName(
+ FacesContext facesContext, UIComponent form) {
+ StringBuffer buf = new StringBuffer();
+ buf.append(HIDDEN_COMMAND_INPUTS_SET_ATTR);
+ buf.append("_");
+ buf.append(form.getClientId(facesContext));
+ return buf.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIForm.class;
+ }
+
+ // For MyFaces compability - create hidden firlds and script. Code got from
+ // project to simulate same functionality.
+ public void renderHiddenCommandFormParams(ResponseWriter writer,
+ Set formParams) throws IOException {
+ for (Iterator it = formParams.iterator(); it.hasNext();) {
+ Object name = it.next();
+ renderHiddenInputField(writer, name, "");
+ }
+ }
+
+ public void renderHiddenInputField(ResponseWriter writer, Object name,
+ Object value) throws IOException {
+ writer.startElement(HTML.INPUT_ELEM, null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, name, null);
+ writer.writeAttribute(HTML.value_ATTRIBUTE, value != null?value:"", null);
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+
+
+ public void renderAjaxFormSetupScript(ResponseWriter writer, String formName) throws
IOException {
+ writer.startElement(HTML.SCRIPT_ELEM, null);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ writer.writeText("A4J.setupForm('"+formName+"');", null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ }
+
+ /**
+ * Render the javascript function that is called on a click on a commandLink
+ * to clear the hidden inputs. This is necessary because on a browser back,
+ * each hidden input still has it's old value (browser cache!) and therefore
+ * a new submit would cause the according action once more!
+ *
+ * @param writer
+ * @param formName
+ * @param dummyFormParams
+ * @param formTarget
+ * @throws IOException
+ */
+ public void renderClearHiddenCommandFormParamsFunction(
+ ResponseWriter writer, String formName, Set dummyFormParams,
+ String formTarget) throws IOException {
+ // render the clear hidden inputs javascript function
+ String functionName = getClearHiddenCommandFormParamsFunctionName(formName);
+ writer.startElement(HTML.SCRIPT_ELEM, null);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+
+ // Using writeComment instead of write with <!-- tag
+ StringBuffer script = new StringBuffer();
+ script.append("function ");
+ script.append(functionName);
+ script.append("() {\n");
+ script.append(FORM_CLEAR_FUNCTION_NAME);
+ script.append("('");
+ script.append(formName);
+ script.append("','");
+ if (formTarget != null && formTarget.length() > 0) {
+ script.append(formTarget);
+ }
+ script.append("'");
+ if (dummyFormParams != null) {
+ script.append(",[");
+ for (Iterator it = dummyFormParams.iterator(); it.hasNext();) {
+ script.append('\'');
+ script.append((String) it.next());
+ script.append('\'');
+ if (it.hasNext()) {
+ script.append(',');
+ }
+ }
+ script.append("]");
+ }
+ script.append(");");
+ script.append("\n}");
+ script.append("\n");
+ script.append("function
").append("clearFormHiddenParams_").append(
+ ScriptUtils.getValidJavascriptName(formName));
+ script.append("(){").append(functionName).append("();}\n");
+ // MyFaces 1.1.5 clear form function name
+
+ //equivalent for formName.replace("-", "$_")
+ StringBuffer formNameReplaceBuffer = new StringBuffer(formName.length());
+ int idx = -1;
+ int idxA = 0;
+ while ((idx = formName.indexOf('-', idxA)) != -1) {
+ formNameReplaceBuffer.append(formName.substring(idxA, idx));
+ formNameReplaceBuffer.append("$_");
+ idxA = idx + 1;
+ }
+ formNameReplaceBuffer.append(formName.substring(idxA));
+
+ script.append("function
").append("clearFormHiddenParams_").append(formNameReplaceBuffer.toString().
+ replace(':', '_'));
+ script.append("(){").append(functionName).append("();}\n");
+ // Just to be sure we call this clear method on each load.
+ // Otherwise in the case, that someone submits a form by pressing Enter
+ // within a text input, the hidden inputs won't be cleared!
+ script.append(functionName);
+ script.append("();");
+
+ writer.writeText(script.toString(), null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ }
+
+ /**
+ * Prefixes the given String with "clear_" and removes special characters
+ *
+ * @param formName
+ * @return String
+ */
+ public String getClearHiddenCommandFormParamsFunctionName(String formName) {
+ return "clear_" + ScriptUtils.getValidJavascriptName(formName);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,97 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.component.UIInclude;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:25 $
+ *
+ */
+public class AjaxIncludeRenderer extends RendererBase {
+
+ private final String[] STYLE_ATTRIBUTES = new String[] { "style",
"class" };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIInclude.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
+ UIComponent component) throws IOException {
+ UIInclude panel = (UIInclude) component;
+ if (!UIInclude.LAYOUT_NONE.equals(panel.getLayout())) {
+ writer.startElement(getTag(panel), panel);
+ getUtils().encodeId(context, component);
+ getUtils().encodePassThru(context, component);
+ getUtils().encodeAttributesFromArray(context, component,
+ STYLE_ATTRIBUTES);
+
+ }
+ }
+
+ /**
+ * @param panel
+ * @return
+ */
+ private String getTag(UIInclude panel) {
+ // TODO Auto-generated method stub
+ return UIInclude.LAYOUT_BLOCK.equals(panel.getLayout()) ? HTML.DIV_ELEM
+ : HTML.SPAN_ELEM;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
+ UIComponent component) throws IOException {
+ UIInclude panel = (UIInclude) component;
+ if (!UIInclude.LAYOUT_NONE.equals(panel.getLayout())) {
+ writer.endElement(getTag(panel));
+
+ }
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,237 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.component.AjaxContainer;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.webapp.BaseFilter;
+
+/**
+ * @author shura
+ *
+ * Render full Html page for AJAX view. Facet "head" rendered in
<head> of
+ * page.
+ */
+public class AjaxPageRenderer extends AjaxContainerRenderer {
+
+ public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxPageRenderer";
+
+ private static final Map doctypes ;
+
+ static {
+ // Fill doctype, content-type and namespace map for different formats.
+ doctypes = new HashMap();
+ doctypes
+ .put(
+ "html-transitional",
+ new String[] {
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">\n",
+ "text/html", null });
+ doctypes.put("html", new String[] {
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n"
+ + "\"http://www.w3.org/TR/html4/strict.dtd\">\n",
+ "text/html", null });
+ doctypes.put("html-frameset", new String[] {
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Frameset//EN\"\n"
+ + "\"http://www.w3.org/TR/html4/frameset.dtd\">\n",
+ "text/html", null });
+ doctypes
+ .put(
+ "xhtml",
+ new String[] {
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Strict//EN\"\n"
+ +
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n",
+ "application/xhtml+xml",
+ "http://www.w3.org/1999/xhtml" });
+ doctypes
+ .put(
+ "xhtml-transitional",
+ new String[] {
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"\n"
+ +
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n",
+ "application/xhtml+xml",
+ "http://www.w3.org/1999/xhtml" });
+ doctypes
+ .put(
+ "xhtml-frameset",
+ new String[] {
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Frameset//EN\"\n"
+ +
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n",
+ "application/xhtml+xml",
+ "http://www.w3.org/1999/xhtml" });
+ doctypes.put("html-3.2", new String[] {
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2
Final//EN\">\n",
+ "text/html", null });
+ }
+
+ // private PreparedTemplate pageStyles =
+ //
HtmlCompiler.compileResource("com/exadel/vcp/renderers/templates/ajax/page-styles.xml");
+ protected void preEncodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ // Scripts must be encoded in component, not before html element
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void doEncodeBegin(ResponseWriter out, FacesContext context,
+ UIComponent component) throws IOException {
+ AjaxContainer ajax = (AjaxContainer) component;
+ // ServletResponse response = (ServletResponse)
+ // context.getExternalContext().getResponse();
+ Map attributes = component.getAttributes();
+ String format = (String) attributes.get("format");
+ String contentType = null;
+ String namespace = null;
+ // String characterEncoding = out.getCharacterEncoding();
+ String[] docType = null;
+ if (null != format) {
+ docType = (String[]) doctypes.get(format);
+ } else {
+ contentType = out.getContentType();
+ for (Iterator iterator = doctypes.values().iterator(); iterator.hasNext();) {
+ String[] types = (String[]) iterator.next();
+ if(types[1].equals(contentType)){
+ docType = types;
+ break;
+ }
+ }
+ }
+ if (null != docType) {
+ contentType = docType[1];
+ namespace = docType[2];
+ out.write(docType[0]);
+ }
+ if (null == contentType) {
+ contentType = (String) attributes.get("contentType");
+ }
+ if (null != contentType) {
+ // response.setContentType(contentType /*+ ";charset=" +
+ // characterEncoding*/);
+ }
+ // TODO - create "format" attribute and insert properly DOCTYPE
+ // declaratiom
+ out.startElement("html", component);
+ if (null == namespace) {
+ namespace = (String) attributes.get("namespace");
+ }
+ if (null != namespace) {
+ out.writeAttribute("xmlns", namespace, "namespace");
+ }
+ // TODO - html attributes. lang - from current locale ?
+ Locale locale = context.getViewRoot().getLocale();
+ out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
+ if (!AjaxContext.getCurrentInstance(context).isAjaxRequest()) {
+ out.startElement("head", component);
+ // Out title - requied html element.
+ Object title = attributes.get("pageTitle");
+ String viewId = context.getViewRoot().getViewId();
+ if (null == title) {
+ title = viewId;// use viewId for empty title
+ }
+ out.startElement(HTML.title_ELEM, component);
+ out.writeText(title, "pageTitle");
+ out.endElement(HTML.title_ELEM);
+ // Page base - set to current view action url.
+ // String pageBase =
+ // context.getApplication().getViewHandler().getActionURL(context,
+ // viewId);
+ // out.startElement("base", component);
+ // out.writeURIAttribute("href", pageBase, "pageBase");
+ // out.endElement("base");
+ // pageStyles.encode(this, context, component);
+ UIComponent headFacet = component.getFacet("head");
+ if (headFacet != null) {
+ // context.getExternalContext().log("Render head facet in AJAX
+ // Page");
+ renderChild(context, headFacet);
+ }
+ if (null != contentType) {
+ out.startElement("meta", component);
+ out.writeAttribute("http-equiv", "Content-Type", null);
+ out.writeAttribute("content",
+ contentType /* + ";charset=" + characterEncoding */,
+ null);
+ out.endElement("meta");
+ }
+ if ((null == context.getExternalContext().getRequestMap().get(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE))) {
+ // Filter not used - encode scripts and CSS before component.
+ encodeResourcesArray(context, component, getScripts());
+ encodeResourcesArray(context, component, getStyles());
+ }
+ out.endElement("head");
+ }
+ out.startElement("body", component);
+ getUtils().encodePassThru(context, component);
+ getUtils().encodeAttributesFromArray(context, component,
+ HTML.PASS_THRU_STYLES);
+ // TODO - special body attributes :
+ getUtils().encodeAttribute(context, component, "onload");
+ getUtils().encodeAttribute(context, component, "onunload");
+ // onload, onunload
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void doEncodeEnd(ResponseWriter out, FacesContext context,
+ UIComponent component) throws IOException {
+ out.endElement("body");
+ out.endElement("html");
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode end");
+ }
+
+ /*
+ * (non-Javadoc) For ajax requests, ViewRoot render childrens directly.
+ *
+ * @see org.ajax4jsf.renderkit.AjaxContainerRenderer#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (AjaxContext.getCurrentInstance(context).isAjaxRequest()) {
+ // Ajax Request. Control all output.
+ return true;
+ }
+ // For non Ajax request, view root not render children
+ return false;
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,100 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.component.UIPoll;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+
+/**
+ * @author shura
+ *
+ */
+public class AjaxPollRenderer extends AjaxCommandRendererBase {
+
+
+
+ private static final String AJAX_POLL_FUNCTION = "A4J.AJAX.Poll";
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIPoll poll = (UIPoll) component;
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "display:none;", null);
+ getUtils().encodeId(context, component);
+ // polling script.
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ StringBuffer script = new StringBuffer("\n");
+ if(poll.isEnabled()){
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context,
AJAX_POLL_FUNCTION);
+ Map options = AjaxRendererUtils.buildEventOptions(context, component, true);
+ Integer interval = new Integer(poll.getInterval());
+ options.put("pollinterval", interval);
+ options.put("pollId", component.getClientId(context));
+ Object onsubmit = component.getAttributes().get("onsubmit");
+ if (null != onsubmit) {
+ JSFunctionDefinition onsubmitFunction = new JSFunctionDefinition();
+ onsubmitFunction.addToBody(onsubmit);
+ options.put("onsubmit", onsubmitFunction);
+ }
+
+// options.put("timeout", interval);
+ function.addParameter(options);
+ function.appendScript(script);
+ } else {
+ script.append("A4J.AJAX.StopPoll('").append(component.getClientId(context)).append("')");
+ }
+ script.append(";\n");
+ writer.writeText(script.toString(),null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // only poll component is allowed.
+ return UIPoll.class;
+ }
+
+ protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
+ boolean submitted = super.isSubmitted(facesContext, uiComponent);
+ UIPoll poll = (UIPoll) uiComponent;
+ poll.setSubmitted(submitted);
+ return submitted;
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,58 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:28 $
+ *
+ */
+public class AjaxRegionRenderer extends AjaxContainerRenderer {
+
+ public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxRegionRenderer";
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+// AjaxRendererUtils.encodeClientScript(context,component);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+// if (((AjaxContainer) component).isAjaxRequest()) {
+// AjaxRendererUtils.encodeAreas(context,component);
+// }
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,167 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.component.UIAjaxStatus;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/19 11:17:10 $
+ *
+ * Render status component as two span's, one for start request,
+ * one for complete.
+ */
+public class AjaxStatusRenderer extends RendererBase
+{
+ /**
+ *
+ */
+ public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxStatusRenderer";
+
+ /**
+ *
+ */
+ public static final String START_STYLE = "display: none";
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ public void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException
+ {
+ // find form clientId for wich we render status.
+ String statusId = component.getClientId(context);
+ String tag = getTag(component);
+ writer.startElement(tag, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, statusId , null);
+ // render 2 span components for different states
+ encodeSpan(writer, context, component,statusId, "start", tag);
+ encodeSpan(writer, context, component,statusId, "stop", tag);
+ writer.endElement(tag);
+ }
+
+ /**
+ * Encode one span for start or stop status
+ * @param context - current context
+ * @param component - status component
+ * @param state - name of state ( start or stop ) for span.
+ * @param tag TODO
+ * @throws IOException
+ */
+ protected void encodeSpan(ResponseWriter writer, FacesContext context, UIComponent
component, String id, String state, String tag) throws IOException {
+ writer.startElement(tag, component);
+ String spanId = id+"."+state;
+ writer.writeAttribute(HTML.id_ATTRIBUTE, spanId , null);
+ // Styles for concrete state.
+ String style = getNamedAttribute(component, "Style", state);
+ // for start state rendered style always disable display of status
+ // ( since it will enabled by JavaScript on start request )
+ if("start".equals(state)) {
+ if(null == style) {
+ style = START_STYLE;
+ } else {
+ style += "; "+START_STYLE;
+ }
+ }
+// HtmlRendererUtils.renderHTMLAttribute(writer, "style",
"style", style );
+// HtmlRendererUtils.renderHTMLAttribute(writer, "styleClass",
"styleClass", getNamedAttribute(component, "StyleClass", state));
+ if (null != style) {
+ writer.writeAttribute("style", style, null);
+ }
+ String styleClass = getNamedAttribute(component, "StyleClass", state);
+ if(null != styleClass){
+ writer.writeAttribute("class", styleClass, null);
+ }
+// getUtils().encodeAttribute(context,component,"class");
+ getUtils().encodePassThru(context , component);
+ // render facet or text.
+ UIComponent facet = component.getFacet(state);
+ if(null != facet) {
+ renderChild(context, facet);
+ } else {
+ String namedAttribute = getNamedAttribute(component, "Text",
state);
+ if (null != namedAttribute) {
+ writer.writeText(namedAttribute, "text");
+ }
+// else {
+// throw new FacesException("Status component must have one of
'"+state+"' facet or '"+state+"Text' atribute");
+// }
+ }
+ writer.endElement(tag);
+ // ENCODE onstart/onstop javaScript.
+ Object eventHandler = component.getAttributes().get("on"+state);
+ if(null != eventHandler){
+ StringBuffer script = new StringBuffer("\n");
+
script.append("window.document.getElementById('").append(spanId).append("').on").append(state).append("=");
+ JSFunctionDefinition function = new JSFunctionDefinition();
+ function.addToBody(eventHandler).addToBody(";").appendScript(script);
+ script.append(";\n");
+ getUtils().writeScript(context, component, script);
+ }
+ }
+
+ /**
+ * @param component
+ * @param name name of attribute for current state
+ * @param state 'start' or 'stop' . all dublicated attributes foe
Ajax state
+ * have same syntax : startStyle/stopStyle ...
+ * @return value of attribute for name and state
+ */
+ protected String getNamedAttribute(UIComponent component, String name, String state)
+ {
+ String fullName = (new StringBuffer(state).append(name)).toString();
+ return (String) component.getAttributes().get(fullName);
+ }
+
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIAjaxStatus.class;
+ }
+
+ /**
+ * @param status
+ * @return
+ */
+ private String getTag(UIComponent status) {
+ // TODO Auto-generated method stub
+ return
"block".equals(status.getAttributes().get("layout"))?HTML.DIV_ELEM:HTML.SPAN_ELEM;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,57 @@
+/**
+ * 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.renderkit.html;
+
+import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+
+/**
+ * Since <code>UIAjaxRegion</code> dont render itself ( only set apropriate
event to parent component )
+ * only <code>decode()</code> method implemented.
+ * In case of Ajax Request caused by event for a given component
+ * send action event.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:24 $
+ *
+ */
+public class AjaxSupportRenderer extends AjaxCommandRendererBase
+{
+ private static final Log log = LogFactory.getLog(AjaxSupportRenderer.class);
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ public boolean getRendersChildren()
+ {
+
+ return false;
+ }
+
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return org.ajax4jsf.component.UIAjaxSupport.class;
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,252 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIParameter;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * "Wrapped" standard {@link javax.faces.component.html.HtmlCommandLink}
renderer,
+ * to avoid common problem - If no commandLink's exist in initial rendered page,
{@link javax.faces.component.html.HtmlForm} renderer
+ * don't encode nessesary hidden fields for link and it's param. Our form-link
renderer can avoid this problem.
+ * @author shura
+ *
+ */
+public class HtmlCommandLinkRenderer extends RendererBase {
+
+ private static final Log _log = LogFactory.getLog(HtmlCommandLinkRenderer.class);
+
+ private static final String[] LINK_EXCLUSIONS =
{"onclick","target","href"};
+
+ private InternetResource[] scripts = null;
+ private static final String FORM_SCRIPT =
"/org/ajax4jsf/javascript/scripts/form.js";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#doDecode(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ protected void doDecode(FacesContext context, UIComponent component) {
+ UIForm form = getUtils().getNestingForm(context,component);
+ if(null != form){
+ String hiddenFieldId = getHiddenFieldId(context, form, component);
+ Object hiddenFieldValue;
+ if(null !=
(hiddenFieldValue=context.getExternalContext().getRequestParameterMap().get(hiddenFieldId))){
+ if(component.getClientId(context).equals(hiddenFieldValue)){
+ // Link submitted !
+ if(_log.isDebugEnabled()){
+ _log.debug(Messages.getMessage(Messages.COMMAND_LINK_SUBMIT_INFO,
component.getClientId(context)));
+ }
+ ActionEvent actionEvent = new ActionEvent(component);
+ component.queueEvent(actionEvent);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ if(isDisabled(context,component)){
+ doEncodePassiveBegin(writer, context, component);
+ } else {
+ doEncodeActiveBegin(writer, context, component);
+ }
+ }
+
+ private String getHiddenFieldId(FacesContext context, UIForm form, UIComponent
component) {
+ return form.getClientId(context)+AjaxFormRenderer.HIDDEN_FIELD_SUFFIX;
+ }
+
+ protected void doEncodeActiveBegin(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
+ writer.startElement(HTML.a_ELEMENT,component);
+ getUtils().encodeId(context,component);
+ getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
+ getUtils().encodePassThruWithExclusionsArray(context,component,LINK_EXCLUSIONS);
+ writer.writeAttribute("href","#",null);
+ UIForm form = getUtils().getNestingForm(context,component);
+ String clientId = component.getClientId(context);
+ if(null == form){
+ if(_log.isWarnEnabled()){
+ _log.warn(Messages.getMessage(Messages.COMMAND_LINK_NOT_IN_FORM_WARNING, clientId));
+ }
+ return;
+ }
+ // Encode onclick attribute.
+ Object click = component.getAttributes().get("onclick");
+ StringBuffer onclick = new StringBuffer(256);
+ if(null != click){
+ onclick.append(click).append(';');
+ }
+ JSFunction submit = new JSFunction(AjaxFormRenderer.FORM_SUBMIT_FUNCTION_NAME);
+ submit.addParameter(clientId);
+ submit.addParameter(form.getClientId(context));
+ submit.addParameter(component.getAttributes().get("target"));
+ Map parameters = new HashMap();
+ for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
+ Object child = iter.next();
+ if (child instanceof UIParameter) {
+ UIParameter param = (UIParameter) child;
+ String name = ((UIParameter) child).getName();
+ Object value = ((UIParameter) child).getValue();
+
+ if (name == null) {
+ throw new IllegalArgumentException(Messages.getMessage(
+ Messages.UNNAMED_PARAMETER_ERROR, component.getClientId(context)));
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ parameters.put(name,value);
+ }
+ }
+
+ parameters.put(getHiddenFieldId(context, form, component),
component.getClientId(context));
+
+ submit.addParameter(parameters);
+ onclick.append("return ");
+ submit.appendScript(onclick);
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE,onclick,"onclick");
+ //
+ encodeValue(writer,context,component);
+ }
+
+ protected void doEncodePassiveBegin(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
+ writer.startElement(HTML.SPAN_ELEM,component);
+ getUtils().encodeId(context,component);
+ getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
+ getUtils().encodePassThru(context,component);
+ encodeValue(writer,context,component);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ // TODO Auto-generated method stub
+ renderChildren(context,component);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ if(isDisabled(context,component)){
+ doEncodePassiveEnd(writer, context, component);
+ } else {
+ doEncodeActiveEnd(writer, context, component);
+ }
+ }
+
+ protected void doEncodeActiveEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
+ writer.endElement(HTML.a_ELEMENT);
+ }
+
+ protected void doEncodePassiveEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+/**
+ * Check for disabled component
+ * @param context
+ * @param command
+ * @return true if link is disabled.
+ */
+private boolean isDisabled(FacesContext context, UIComponent command){
+ if (command.getAttributes().get("disabled") != null) {
+ if ((command.getAttributes().get("disabled")).equals(Boolean.TRUE)) {
+ return true;
+ }
+ }
+ return false;
+}
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UICommand.class;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ protected void encodeValue(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException{
+ String valueString = null;
+ if (component instanceof UICommand) {
+ Object value = ((UICommand) component).getValue();
+ if (value != null) {
+ valueString = value.toString();
+ }
+ } else if (component instanceof ValueHolder) {
+ Object value = ((ValueHolder) component).getValue();
+ if (value != null) {
+ valueString = getUtils().formatValue(context,component,value);
+ }
+ }
+
+ if (null != valueString && valueString.length()>0) {
+ writer.writeText(valueString,null);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.HeaderResourcesRendererBase#getScripts()
+ */
+ protected InternetResource[] getScripts() {
+ synchronized (this) {
+ if (scripts == null) {
+ scripts = new InternetResource[1];
+ scripts[0] = getResource(FORM_SCRIPT);
+ }
+ }
+
+ return scripts;
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,183 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.component.QueueRegistry;
+import org.ajax4jsf.component.UIQueue;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.html.scripts.QueueScript;
+import org.ajax4jsf.resource.InternetResource;
+import org.richfaces.component.util.MessageUtil;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueRenderer extends RendererBase {
+
+ private static final String SIZE_EXCEEDED_BEHAVIOR = "sizeExceededBehavior";
+
+ private static final String SIZE = "size";
+
+ private static final String QUEUE_ONSUBMIT_ATTRIBUTE = "queueonsubmit";
+
+ private static final String QUEUE_ONBEFOREDOMUPDATE_ATTRIBUTE =
"queueonbeforedomupdate";
+
+ private static final String QUEUE_ONCOMPLETE_ATTRIBUTE = "queueoncomplete";
+
+ private static final String QUEUE_ONERROR_ATTRIBUTE = "queueonerror";
+
+ public static final String BEHAVIOR_DROP_NEXT = "dropNext";
+
+ public static final String BEHAVIOR_DROP_NEW = "dropNew";
+
+ public static final String BEHAVIOR_FIRE_NEXT = "fireNext";
+
+ public static final String BEHAVIOR_FIRE_NEW = "fireNew";
+
+ private static final String[] REQUEST_ATTRIBUTES = new String[] {
+ "ignoreDupResponses",
+ "requestDelay",
+ "timeout"
+ };
+
+ private InternetResource[] scripts = new InternetResource[] {
+ getResource(QueueScript.class.getName())
+ };
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIQueue.class;
+ }
+
+ private static final RendererUtils utils = RendererUtils.getInstance();
+
+ private boolean isValidBehaviorValue(String value) {
+ return BEHAVIOR_DROP_NEW.equals(value) || BEHAVIOR_DROP_NEXT.equals(value) ||
+ BEHAVIOR_FIRE_NEW.equals(value) || BEHAVIOR_FIRE_NEXT.equals(value);
+ }
+
+ private QueueRendererData createRendererData(FacesContext context, UIQueue queue) {
+ Map<String, Object> attributes = queue.getAttributes();
+
+ QueueRendererData data = new QueueRendererData();
+
+ int size = queue.getSize();
+ if (utils.shouldRenderAttribute(size)) {
+ data.addQueueAttribute(SIZE, size);
+ }
+
+ String sizeExceededBehavior = (String) attributes.get(SIZE_EXCEEDED_BEHAVIOR);
+ if (utils.shouldRenderAttribute(sizeExceededBehavior)) {
+ if (!isValidBehaviorValue(sizeExceededBehavior)) {
+ throw new IllegalArgumentException(sizeExceededBehavior + " value of " +
+ SIZE_EXCEEDED_BEHAVIOR + " attribute is not a legal one for component: " +
+ MessageUtil.getLabel(context, queue));
+ }
+
+ data.addQueueAttribute(SIZE_EXCEEDED_BEHAVIOR, sizeExceededBehavior);
+ }
+
+ String onsizeexceeded = queue.getOnsizeexceeded();
+ if (utils.shouldRenderAttribute(onsizeexceeded)) {
+ data.addQueueAttribute("onsizeexceeded", new
JSFunctionDefinition("query", "options",
"event").addToBody(onsizeexceeded));
+ }
+
+ String onrequestqueue = queue.getOnrequestqueue();
+ if (utils.shouldRenderAttribute(onrequestqueue)) {
+ data.addQueueAttribute("onrequestqueue", new
JSFunctionDefinition("query", "options",
"event").addToBody(onrequestqueue));
+ }
+
+ String onrequestdequeue = queue.getOnrequestdequeue();
+ if (utils.shouldRenderAttribute(onrequestdequeue)) {
+ data.addQueueAttribute("onrequestdequeue", new
JSFunctionDefinition("query", "options",
"event").addToBody(onrequestdequeue));
+ }
+
+ for (String attributeName : REQUEST_ATTRIBUTES) {
+ Object value = attributes.get(attributeName);
+ if (utils.shouldRenderAttribute(value)) {
+ data.addRequestAttribute(attributeName, value);
+ }
+ }
+
+ String status = AjaxRendererUtils.getAjaxStatus(queue);
+ if (utils.shouldRenderAttribute(status)) {
+ data.addRequestAttribute(AjaxRendererUtils.STATUS_ATTR_NAME, status);
+ }
+
+ String onBeforeDomUpdate = queue.getOnbeforedomupdate();
+ if (utils.shouldRenderAttribute(onBeforeDomUpdate)) {
+ data.addRequestAttribute(QUEUE_ONBEFOREDOMUPDATE_ATTRIBUTE,
AjaxRendererUtils.buildAjaxOnBeforeDomUpdate(onBeforeDomUpdate));
+ }
+
+ String oncomplete = queue.getOncomplete();
+ if (utils.shouldRenderAttribute(oncomplete)) {
+ data.addRequestAttribute(QUEUE_ONCOMPLETE_ATTRIBUTE,
AjaxRendererUtils.buildAjaxOncomplete(oncomplete));
+ }
+
+ String onsubmit = queue.getOnsubmit();
+ if (utils.shouldRenderAttribute(onsubmit)) {
+ JSFunctionDefinition onsubmitFunction = new
JSFunctionDefinition("request");
+ onsubmitFunction.addToBody(onsubmit);
+
+ data.addRequestAttribute(QUEUE_ONSUBMIT_ATTRIBUTE, onsubmitFunction);
+ }
+
+ String onerror = queue.getOnerror();
+ if (utils.shouldRenderAttribute(onerror)) {
+ JSFunctionDefinition onerrorFunction = new JSFunctionDefinition("request",
"status", "message");
+ onerrorFunction.addToBody(onerror);
+
+ data.addRequestAttribute(QUEUE_ONERROR_ATTRIBUTE, onerrorFunction);
+ }
+
+ return data;
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeBegin(context, component);
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeEnd(context, component);
+
+ UIQueue queue = (UIQueue) component;
+ if (!queue.isDisabled()) {
+ QueueRegistry.getInstance(context).registerQueue(context,
+ queue.getClientName(context),
+ createRendererData(context, queue));
+ }
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,61 @@
+/**
+ * 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.renderkit.html;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * @author Denis Morozov
+ * @since 3.3.0
+ */
+public class QueueRendererData {
+
+ private Map<String, Object> queueAttributes;
+
+ private Map<String, Object> requestAttributes;
+
+ public void addQueueAttribute(String key, Object value) {
+ if (queueAttributes == null) {
+ queueAttributes = new LinkedHashMap<String, Object>();
+ }
+
+ queueAttributes.put(key, value);
+ }
+
+ public void addRequestAttribute(String key, Object value) {
+ if (requestAttributes == null) {
+ requestAttributes = new LinkedHashMap<String, Object>();
+ }
+
+ requestAttributes.put(key, value);
+ }
+
+ public Map<String, Object> getQueueAttributes() {
+ return queueAttributes;
+ }
+
+ public Map<String, Object> getRequestAttributes() {
+ return requestAttributes;
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,81 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.component.UIRepeat;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.renderkit.RendererBase;
+
+/**
+ * @author shura
+ *
+ */
+public class RepeatRenderer extends RendererBase {
+
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException {
+ final UIRepeat repeater = (UIRepeat) component;
+ repeater.captureOrigValue(context);
+ try {
+ DataVisitor visitor = new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey, Object argument) throws
IOException {
+ repeater.setRowKey(rowKey);
+ ListIterator childIterator = repeater.getChildren()
+ .listIterator();
+ while (childIterator.hasNext()) {
+ UIComponent child = (UIComponent) childIterator.next();
+ renderChild(context, child);
+ }
+
+ }
+
+ };
+ repeater.walk(context, visitor, null);
+
+ } finally {
+ repeater.restoreOrigValue(context);
+ repeater.setRowKey(null);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIRepeat.class;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,52 @@
+/**
+ * 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.renderkit.html.scripts;
+
+import org.ajax4jsf.resource.InternetResourceBase;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.ResourceRenderer;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueScript extends InternetResourceBase {
+
+ private static final ResourceRenderer renderer = new QueueScriptResourceRenderer();
+
+ private String key = getClass().getName();
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public ResourceRenderer getRenderer(ResourceContext resourceContext) {
+ return renderer;
+ }
+
+ @Override
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return false;
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,165 @@
+/**
+ * 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.renderkit.html.scripts;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.component.QueueRegistry;
+import org.ajax4jsf.component.UIQueue;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSObject;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.html.QueueRendererData;
+import org.ajax4jsf.resource.BaseResourceRenderer;
+import org.ajax4jsf.resource.InternetResource;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueScriptResourceRenderer extends BaseResourceRenderer {
+
+ public static final String QUEUE_SCRIPT_ID = "org.ajax4jsf.queue_script";
+
+ private void encodeQueue(ResponseWriter writer, String queueName, QueueRendererData
queueData)
+ throws IOException {
+
+ Map<String, Object> queueAttributes = null;
+ Map<String, Object> requestAttributes = null;
+
+ if (queueData != null) {
+ queueAttributes = queueData.getQueueAttributes();
+ requestAttributes = queueData.getRequestAttributes();
+ }
+
+ writer.writeText("if (!EventQueue.getQueue(" +
ScriptUtils.toScript(queueName) + ")) { EventQueue.addQueue(", null);
+ writer.writeText(
+ new JSObject("EventQueue",
+ queueName,
+ queueAttributes,
+ requestAttributes
+ ).toScript(), null);
+ writer.writeText(") };", null);
+ }
+
+ @Override
+ protected void customEncode(InternetResource resource,
+ FacesContext context, Object data) throws IOException {
+ super.customEncode(resource, context, data);
+
+ Map<String, Object> queues = (Map<String, Object>) data;
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer.writeText("if (typeof A4J != 'undefined') { if (A4J.AJAX) { with
(A4J.AJAX) {", null);
+ for (Entry<String, Object> entry : queues.entrySet()) {
+ encodeQueue(writer, entry.getKey(), (QueueRendererData) entry.getValue());
+ }
+ writer.writeText("}}};", null);
+ }
+
+ protected void doEncode(InternetResource resource, FacesContext context,
+ Object data, Map<String, Object> attributes) throws IOException {
+
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, Object> requestMap = externalContext.getRequestMap();
+
+ String resourceKey = resource.getKey();
+ if (requestMap.get(resourceKey) == null) {
+ requestMap.put(resourceKey, Boolean.TRUE);
+
+ QueueRegistry queueRegistry = QueueRegistry.getInstance(context);
+ if (queueRegistry.isShouldCreateDefaultGlobalQueue()) {
+ String encodedGlobalQueueName = context.getExternalContext().encodeNamespace(
+ UIQueue.GLOBAL_QUEUE_NAME);
+
+ if (!queueRegistry.containsQueue(encodedGlobalQueueName)) {
+ queueRegistry.registerQueue(context, encodedGlobalQueueName, null);
+ }
+ }
+
+ if (queueRegistry.hasQueuesToEncode()) {
+ super.encode(resource, context, queueRegistry.getRegisteredQueues(context),
attributes);
+ }
+ }
+ }
+
+ private String encodeQueueScriptId(FacesContext context) {
+ String encodedId = QUEUE_SCRIPT_ID;
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if (!ajaxContext.isAjaxRequest()) {
+ encodedId = context.getExternalContext().encodeNamespace(encodedId);
+ }
+
+ return encodedId;
+ }
+
+ @Override
+ public void encode(InternetResource resource, FacesContext context,
+ Object data, Map<String, Object> attributes) throws IOException {
+
+ Map<String,Object> newAttributes = new LinkedHashMap<String,
Object>(attributes);
+ newAttributes.put(HTML.id_ATTRIBUTE, encodeQueueScriptId(context));
+
+ doEncode(resource, context, data, newAttributes);
+ }
+
+ @Override
+ public void encode(InternetResource resource, FacesContext context,
+ Object data) throws IOException {
+
+ doEncode(resource, context, data,
+ Collections.singletonMap(HTML.id_ATTRIBUTE, (Object) encodeQueueScriptId(context)));
+ }
+
+ @Override
+ protected String[][] getCommonAttrs() {
+ return new String[][] {
+ {HTML.TYPE_ATTR, getContentType()},
+ };
+ }
+
+ @Override
+ protected String getHrefAttr() {
+ return null;
+ }
+
+ @Override
+ protected String getTag() {
+ return HTML.SCRIPT_ELEM;
+ }
+
+ public String getContentType() {
+ return "text/javascript";
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,202 @@
+/**
+ * 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.taglib.html.facelets;
+
+import javax.faces.application.Application;
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.event.ActionEvent;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.UIActionParameter;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:23 $
+ *
+ */
+public class ActionParamHandler extends ComponentHandler {
+
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:23 $
+ *
+ */
+ public static class ActionParamMetaRule extends MetaRule {
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.tag.SuggestionHandler.SuggestionMetaRule#applyRule(java.lang.String,
com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
+ */
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(UIActionParameter.class)) {
+ if ("assignTo".equals(name)) {
+ return new AssignToValueBindingMetadata(attribute);
+ } else if ("converter".equals(name)) {
+ if (attribute.isLiteral()) {
+ return new LiteralConverterMetadata(attribute.getValue());
+ } else {
+ return new DynamicConverterMetadata(attribute);
+ }
+
+ } else if ("actionListener".equals(name)) {
+ return new ActionListenerMetadata(attribute);
+ }
+ }
+
+ return null;
+ }
+
+
+ }
+
+ final static class LiteralConverterMetadata extends Metadata {
+
+ private final String converterId;
+
+ public LiteralConverterMetadata(String converterId) {
+ this.converterId = converterId;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIActionParameter) instance).setConverter(ctx.getFacesContext()
+ .getApplication().createConverter(this.converterId));
+ }
+ }
+
+ final static class DynamicConverterMetadata extends Metadata {
+
+ private final TagAttribute attr;
+
+ public DynamicConverterMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIActionParameter) instance).setConverter((Converter) this.attr
+ .getObject(ctx, Converter.class));
+ }
+ }
+
+ final static class AssignToValueBindingMetadata extends Metadata {
+
+ private final TagAttribute attr;
+
+ public AssignToValueBindingMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIActionParameter)
instance).setAssignToBinding(attr.getValueExpression(ctx,
+ Object.class));
+ }
+ }
+
+ final static class ActionListenerMetadata extends Metadata {
+
+ private static final Class[] SIGNATURE = new Class[] {ActionEvent.class};
+
+ private final TagAttribute attribute;
+
+ public ActionListenerMetadata(TagAttribute attribute) {
+ super();
+ this.attribute = attribute;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIActionParameter) instance).setActionListener(
+ attribute.getMethodExpression(ctx, null, SIGNATURE));
+ }
+ };
+
+ private TagAttribute _assignTo;
+ private TagAttribute _converter;
+ private TagAttribute _actionListener;
+
+ /**
+ * @param config
+ */
+ public ActionParamHandler(ComponentConfig config) {
+ super(config);
+ _assignTo = getAttribute("assignTo");
+ _converter = getAttribute("converter");
+ _actionListener = getAttribute("actionListener");
+
+ if(null != _assignTo) {
+ if (_assignTo.isLiteral()) {
+ throw new TagAttributeException(this.tag, this._assignTo,
Messages.getMessage(Messages.MUST_BE_EXPRESSION_ERROR));
+ }
+ }
+
+ if (null != _actionListener) {
+ if (_actionListener.isLiteral()) {
+ throw new TagAttributeException(this.tag, this._actionListener,
Messages.getMessage(Messages.MUST_BE_EXPRESSION_ERROR));
+ }
+ }
+ // TODO Auto-generated constructor stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent)
{
+ if (parent instanceof ActionSource)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application application = facesContext.getApplication();
+ if (_assignTo != null) {
+ UIActionParameter al = (UIActionParameter)c;
+ // TODO - in jsf 1.2 use ELValueExpression
+//
al.setAssignToBinding(application.createValueBinding(_assignTo.getValue()));
+// if (_converter != null) {
+// Converter converter =
application.createConverter(_converter.getValue(ctx));
+// al.setConverter(converter);
+// }
+ ((ActionSource)parent).addActionListener(al);
+ }
+ }
+ }
+
+ private static final ActionParamMetaRule actionParamMetaRule = new
ActionParamMetaRule();
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tag.AjaxComponentHandler#createMetaRuleset(java.lang.Class)
+ */
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRules = super.createMetaRuleset(type);
+ metaRules.addRule(actionParamMetaRule);
+ return metaRules;
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,120 @@
+/**
+ * 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.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.event.AjaxListener;
+import org.ajax4jsf.event.AjaxListenerHelper;
+import org.ajax4jsf.event.AjaxSource;
+
+/**
+ * Register an ActionListener instance on the UIComponent associated with the
+ * closest parent UIComponent custom action. <p/> See <a
target="_new"
+ *
href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f...
+ * documentation</a>.
+ *
+ * @see javax.faces.event.ActionListener
+ * @see javax.faces.component.AjaxContainer
+ * @author Jacob Hookom
+ * @version $Id: AjaxListenerHandler.java,v 1.1.2.1 2007/02/01 15:31:23 alexsmirnov Exp
$
+ */
+public final class AjaxListenerHandler extends TagHandler {
+
+ private Class listenerType;
+
+ private final TagAttribute type;
+
+ private final TagAttribute binding;
+
+ /**
+ * @param config
+ */
+ public AjaxListenerHandler(TagConfig config) {
+ super(config);
+ this.binding = this.getAttribute("binding");
+ this.type = this.getAttribute("type");
+ if(binding == null && type == null){
+ throw new TagException(this.tag, "One of the attribute 'binding'
or type' is required");
+ }
+ if (binding == null && type != null) {
+ if (!type.isLiteral()) {
+ throw new TagAttributeException(this.tag, this.type,
Messages.getMessage(Messages.MUST_BE_LITERAL_ERROR));
+ }
+ try {
+ this.listenerType = Class.forName(type.getValue());
+ } catch (Exception e) {
+ throw new TagAttributeException(this.tag, this.type, e);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException {
+ if (parent instanceof AjaxSource) {
+ // only process if parent was just created
+ if (parent.getParent() == null) {
+ AjaxSource src = (AjaxSource) parent;
+ AjaxListener listener = null;
+ ValueExpression ve = null;
+ if (this.binding != null) {
+ ve = this.binding.getValueExpression(ctx,
+ AjaxListener.class);
+ // TODO - handle both JSF 1.2/1.1 cases.
+ listener = new AjaxListenerHelper(ve);
+ }
+ if (listener == null) {
+ try {
+ listener = (AjaxListener) listenerType.newInstance();
+ } catch (Exception e) {
+ throw new TagAttributeException(this.tag, this.type,
e.getCause());
+ }
+ if (ve != null) {
+ ve.setValue(ctx, ve);
+ }
+ }
+ src.addAjaxListener(listener);
+ }
+ } else {
+ throw new TagException(this.tag,
Messages.getMessage(Messages.NOT_PARENT_AJAX_COMPONENT_ERROR, parent));
+ }
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,97 @@
+/**
+ * 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.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagHandler;
+
+import org.ajax4jsf.taglib.html.jsp.AjaxSupportTag;
+import org.ajax4jsf.webapp.taglib.AjaxComponentHandler;
+
+/**
+ * "proxy" class for creating UIAjaxSupport component as facet for it's
parent.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+public class AjaxSupportHandler extends TagHandler {
+ /**
+ * A UIComponent for capturing a child UIComponent, representative of the
+ * desired Facet
+ *
+ * @author Jacob Hookom
+ *
+ */
+ private final static class UIFacet extends UIComponentBase {
+ public String getFamily() {
+ return null;
+ }
+ }
+
+ /**
+ * Real tag handler for create component.
+ */
+ private TagHandler _ajaxSupportHandler;
+
+ private TagAttribute _event;
+ /**
+ * @param config
+ */
+ public AjaxSupportHandler(ComponentConfig config) {
+ super(config);
+ _event = getRequiredAttribute("event");
+ _ajaxSupportHandler = new AjaxComponentHandler(config);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException {
+ UIComponent c;
+ // our id
+// String id = ctx.generateUniqueId(this.tagId);
+ UIFacet facet = new UIFacet();
+ // Find facet for support component
+ String facetName = AjaxSupportTag.AJAX_SUPPORT_FACET+_event.getValue();
+ c = parent.getFacet(facetName);
+ if (null != c) {
+ parent.getFacets().remove(facetName);
+ facet.getChildren().add(c);
+ }
+ this._ajaxSupportHandler.apply(ctx, facet);
+ c = (UIComponent) facet.getChildren().get(0);
+ parent.getFacets().put(facetName, c);
+ // Fix for possible incompabilites in different frameworks.
+// c.setParentProperties(parent);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,93 @@
+/**
+ * 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.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * Register a named facet on the UIComponent associated with the closest parent
+ * UIComponent custom action. <p/> See <a target="_new"
+ *
href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f...
+ * documentation</a>.
+ *
+ * @author Jacob Hookom
+ * @version $Id: FacetHandler.java,v 1.1.2.1 2007/02/01 15:31:21 alexsmirnov Exp $
+ */
+public final class FacetHandler extends TagHandler {
+
+ /**
+ * A UIComponent for capturing a child UIComponent, representative of the
+ * desired Facet
+ *
+ * @author Jacob Hookom
+ *
+ */
+ private final static class UIFacet extends UIComponentBase {
+ public String getFamily() {
+ return null;
+ }
+ }
+
+ protected final TagAttribute name;
+
+ public FacetHandler(TagConfig config) {
+ super(config);
+ this.name = this.getRequiredAttribute("name");
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException {
+ UIFacet facet = new UIFacet();
+ UIComponent c;
+ // Check for existing facet
+ String facetName = this.name.getValue(ctx);
+ c = parent.getFacet(facetName);
+ if (null != c) {
+ parent.getFacets().remove(facetName);
+ facet.getChildren().add(c);
+ }
+ this.nextHandler.apply(ctx, facet);
+ int childCount = facet.getChildCount();
+ if (childCount == 1) {
+ c = (UIComponent) facet.getChildren().get(0);
+ parent.getFacets().put(facetName, c);
+ } else {
+ throw new TagException(this.tag,
Messages.getMessage(Messages.FACET_TAG_MANY_CHILDREN_ERROR));
+ }
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,275 @@
+/**
+ * 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.taglib.html.facelets;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+
+/**
+ * @author shura
+ *
+ */
+public class IncludeFaceletContext extends FaceletContext {
+
+ private FaceletContext defaultContext;
+
+ private Map ids;
+
+ /**
+ * @param defaultContext
+ */
+ public IncludeFaceletContext(FaceletContext defaultContext) {
+ this.defaultContext = defaultContext;
+ this.ids = new HashMap();
+ }
+
+ //TODO JSF 2.0 analog?
+// /**
+// * @param client
+// * @see com.sun.facelets.FaceletContext#extendClient(com.sun.facelets.TemplateClient)
+// */
+// public void extendClient(TemplateClient client) {
+// this.defaultContext.extendClient(client);
+// }
+
+ /**
+ * @param base
+ * @return
+ * @see com.sun.facelets.FaceletContext#generateUniqueId(java.lang.String)
+ */
+ public String generateUniqueId(String base) {
+ Integer cnt = (Integer) this.ids.get(base);
+ if (cnt == null) {
+ this.ids.put(base, new Integer(0));
+ return base;
+ } else {
+ int i = cnt.intValue() + 1;
+ this.ids.put(base, new Integer(i));
+ return base + "_" + i;
+ }
+ }
+
+ /**
+ * @param name
+ * @return
+ * @see com.sun.facelets.FaceletContext#getAttribute(java.lang.String)
+ */
+ public Object getAttribute(String name) {
+ return this.defaultContext.getAttribute(name);
+ }
+
+ /**
+ * @param key
+ * @return
+ * @see javax.el.ELContext#getContext(java.lang.Class)
+ */
+ public Object getContext(Class key) {
+ return this.defaultContext.getContext(key);
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getELResolver()
+ */
+ public ELResolver getELResolver() {
+ return this.defaultContext.getELResolver();
+ }
+
+ /**
+ * @return
+ * @see com.sun.facelets.FaceletContext#getExpressionFactory()
+ */
+ public ExpressionFactory getExpressionFactory() {
+ return this.defaultContext.getExpressionFactory();
+ }
+
+ /**
+ * @return
+ * @see com.sun.facelets.FaceletContext#getFacesContext()
+ */
+ public FacesContext getFacesContext() {
+ return this.defaultContext.getFacesContext();
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getFunctionMapper()
+ */
+ public FunctionMapper getFunctionMapper() {
+ return this.defaultContext.getFunctionMapper();
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getLocale()
+ */
+ public Locale getLocale() {
+ return this.defaultContext.getLocale();
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getVariableMapper()
+ */
+ public VariableMapper getVariableMapper() {
+ return this.defaultContext.getVariableMapper();
+ }
+
+ /**
+ * @return
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return this.defaultContext.hashCode();
+ }
+
+ //TODO JSF 2.0 analog?
+// /**
+// * @param parent
+// * @param name
+// * @return
+// * @throws IOException
+// * @throws FaceletException
+// * @throws FacesException
+// * @throws ELException
+// * @see
com.sun.facelets.FaceletContext#includeDefinition(javax.faces.component.UIComponent,
java.lang.String)
+// */
+// public boolean includeDefinition(UIComponent parent, String name) throws IOException,
FaceletException, FacesException, ELException {
+// return this.defaultContext.includeDefinition(parent, name);
+// }
+
+ /**
+ * @param parent
+ * @param relativePath
+ * @throws IOException
+ * @throws FaceletException
+ * @throws FacesException
+ * @throws ELException
+ * @see
com.sun.facelets.FaceletContext#includeFacelet(javax.faces.component.UIComponent,
java.lang.String)
+ */
+ public void includeFacelet(UIComponent parent, String relativePath) throws IOException,
FaceletException, FacesException, ELException {
+ this.defaultContext.includeFacelet(parent, relativePath);
+ }
+
+ /**
+ * @param parent
+ * @param absolutePath
+ * @throws IOException
+ * @throws FaceletException
+ * @throws FacesException
+ * @throws ELException
+ * @see
com.sun.facelets.FaceletContext#includeFacelet(javax.faces.component.UIComponent,
java.net.URL)
+ */
+ public void includeFacelet(UIComponent parent, URL absolutePath) throws IOException,
FaceletException, FacesException, ELException {
+ this.defaultContext.includeFacelet(parent, absolutePath);
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#isPropertyResolved()
+ */
+ public boolean isPropertyResolved() {
+ return this.defaultContext.isPropertyResolved();
+ }
+
+ //TODO JSF 2.0 analog?
+// /**
+// * @param client
+// * @see com.sun.facelets.FaceletContext#popClient(com.sun.facelets.TemplateClient)
+// */
+// public void popClient(TemplateClient client) {
+// this.defaultContext.popClient(client);
+// }
+//
+// /**
+// * @param client
+// * @see com.sun.facelets.FaceletContext#pushClient(com.sun.facelets.TemplateClient)
+// */
+// public void pushClient(TemplateClient client) {
+// this.defaultContext.pushClient(client);
+// }
+
+ /**
+ * @param key
+ * @param contextObject
+ * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
+ */
+ public void putContext(Class key, Object contextObject) {
+ this.defaultContext.putContext(key, contextObject);
+ }
+
+ /**
+ * @param name
+ * @param value
+ * @see com.sun.facelets.FaceletContext#setAttribute(java.lang.String,
java.lang.Object)
+ */
+ public void setAttribute(String name, Object value) {
+ this.defaultContext.setAttribute(name, value);
+ }
+
+ /**
+ * @param fnMapper
+ * @see com.sun.facelets.FaceletContext#setFunctionMapper(javax.el.FunctionMapper)
+ */
+ public void setFunctionMapper(FunctionMapper fnMapper) {
+ this.defaultContext.setFunctionMapper(fnMapper);
+ }
+
+ /**
+ * @param locale
+ * @see javax.el.ELContext#setLocale(java.util.Locale)
+ */
+ public void setLocale(Locale locale) {
+ this.defaultContext.setLocale(locale);
+ }
+
+ /**
+ * @param resolved
+ * @see javax.el.ELContext#setPropertyResolved(boolean)
+ */
+ public void setPropertyResolved(boolean resolved) {
+ this.defaultContext.setPropertyResolved(resolved);
+ }
+
+ /**
+ * @param varMapper
+ * @see com.sun.facelets.FaceletContext#setVariableMapper(javax.el.VariableMapper)
+ */
+ public void setVariableMapper(VariableMapper varMapper) {
+ this.defaultContext.setVariableMapper(varMapper);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,89 @@
+/**
+ * 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.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.ajax4jsf.component.UIInclude;
+
+/**
+ * @author shura
+ *
+ */
+public class IncludeHandler extends ComponentHandler {
+
+ private TagAttribute viewId;
+
+ public IncludeHandler(ComponentConfig config) {
+ super(config);
+ this.viewId = getRequiredAttribute("viewId");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
com.sun.facelets.tag.jsf.ComponentHandler#onComponentCreated(com.sun.facelets.FaceletContext,
+ * javax.faces.component.UIComponent,
+ * javax.faces.component.UIComponent)
+ */
+ public void onComponentCreated(FaceletContext ctx, UIComponent c,
+ UIComponent parent) {
+ // TODO Auto-generated method stub
+ super.onComponentCreated(ctx, c, parent);
+ }
+
+ public void applyNextHandler(FaceletContext ctx, UIComponent component)
+ throws IOException, FacesException, ELException {
+ String path;
+ if (component instanceof UIInclude) {
+ UIInclude include = (UIInclude) component;
+ path = include.getViewId();
+ if(include.isWasNavigation()){
+ component.getChildren().clear();
+ }
+ } else {
+ path = (String) component.getAttributes().get("viewId");
+ }
+ VariableMapper orig = ctx.getVariableMapper();
+ ctx.setVariableMapper(new VariableMapperWrapper(orig));
+ try {
+ this.nextHandler.apply(ctx, component);
+ ctx.includeFacelet(component, path);
+ } catch (Exception e) {
+ throw new FacesException("UIInclude component "
+ + component.getClientId(ctx.getFacesContext())
+ + " could't include page with path " + path, e);
+ } finally {
+ ctx.setVariableMapper(orig);
+ }
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,82 @@
+/**
+ * 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.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.event.AjaxPhaseListener;
+
+/**
+ * @author shura
+ *
+ */
+public class KeepAliveHandler extends TagHandler {
+
+ private final TagAttribute beanName;
+
+ private final TagAttribute ajaxOnly;
+ /**
+ * @param config
+ */
+ public KeepAliveHandler(TagConfig config) {
+ super(config);
+ this.beanName = this.getRequiredAttribute("beanName");
+ if (beanName != null) {
+ if (!beanName.isLiteral()) {
+ throw new TagAttributeException(this.tag, this.beanName,
Messages.getMessage(Messages.MUST_BE_LITERAL_ERROR));
+ }
+ }
+ this.ajaxOnly = getAttribute("ajaxOnly");
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException {
+ // Get bean instance from EL expression.
+ String name = beanName.getValue();
+ boolean isAjaxOnly = ajaxOnly!=null?ajaxOnly.getBoolean(ctx):false;
+ FacesContext facesContext = ctx.getFacesContext();
+ String beanExpression = "#{"+name+"}";
+ ValueBinding valueBinding =
facesContext.getApplication().createValueBinding(beanExpression);
+ Object bean = valueBinding.getValue(facesContext);
+ String beanAttributeName = (isAjaxOnly ? AjaxPhaseListener.AJAX_BEAN_PREFIX :
AjaxPhaseListener.VIEW_BEAN_PREFIX)
+ + name;
+ // Put bean instance to ViewRoot.
+ facesContext.getViewRoot().getAttributes().put(beanAttributeName, bean);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,118 @@
+/**
+ * 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.taglib.html.facelets;
+
+import java.io.OutputStream;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.ajax4jsf.component.UIMediaOutput;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+public class MediaOutputHandler extends ComponentHandler {
+
+ private static final MetaRule mmediaMetaRule = new MMediaMetaRule();
+ /**
+ * @param config
+ */
+ public MediaOutputHandler(ComponentConfig config) {
+ super(config);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tag.AjaxComponentHandler#createMetaRuleset(java.lang.Class)
+ */
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRules = super.createMetaRuleset(type);
+ metaRules.addRule(mmediaMetaRule);
+ return metaRules;
+ }
+
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+ static class MMediaMetaRule extends MetaRule{
+
+ /**
+ *
+ */
+ public MMediaMetaRule() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
+ */
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(UIMediaOutput.class)) {
+
+
+ if ("createContent".equals(name)) {
+ return new MMediaActionMapper(attribute);
+ }
+ }
+ return null;
+ }
+
+ }
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+ static class MMediaActionMapper extends Metadata {
+
+ private static final Class<?>[] MMEDIA_ACTION_SIG = new Class[]
{OutputStream.class,Object.class};
+
+ private final TagAttribute _send;
+ /**
+ * @param attribute
+ */
+ public MMediaActionMapper(TagAttribute attribute) {
+ _send = attribute;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext,
java.lang.Object)
+ */
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIMediaOutput)
instance).setCreateContentExpression(this._send.getMethodExpression(ctx, null,
+ MMEDIA_ACTION_SIG));
+ }
+
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/RowKeyConverterRule.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/RowKeyConverterRule.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/RowKeyConverterRule.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/RowKeyConverterRule.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,31 @@
+/**
+ * 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.taglib.html.facelets;
+
+
+/**
+ * Apply rowKeyConverter to component
+ * @author Maksim Kaszynski
+ */
+@Deprecated
+public class RowKeyConverterRule extends org.ajax4jsf.webapp.taglib.RowKeyConverterRule
{
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/VariableMapperWrapper.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/VariableMapperWrapper.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/VariableMapperWrapper.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/VariableMapperWrapper.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,65 @@
+/**
+ * Licensed under the Common Development and Distribution License,
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.sun.com/cddl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+
+class VariableMapperWrapper extends VariableMapper {
+
+ private VariableMapper mapper;
+
+ private Map<String, ValueExpression> vars = null;
+
+ public VariableMapperWrapper(VariableMapper mapper) {
+ this.mapper = mapper;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.VariableMapper#resolveVariable(java.lang.String)
+ */
+ @Override
+ public ValueExpression resolveVariable(String variable) {
+ ValueExpression ve = null;
+ try {
+ if (this.vars != null) {
+ ve = (ValueExpression) this.vars.get(variable);
+ }
+ if (ve == null) {
+ return this.mapper.resolveVariable(variable);
+ }
+ return ve;
+ } catch (StackOverflowError e) {
+ throw new ELException("Could not Resolve Variable [Overflow]: " + variable,
e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
+ */
+ @Override
+ public ValueExpression setVariable(String variable,
+ ValueExpression expression) {
+
+ if (this.vars == null) {
+ this.vars = new HashMap<String, ValueExpression>();
+ }
+ return (ValueExpression) this.vars.put(variable, expression);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/package-info.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/package-info.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/package-info.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/package-info.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,4 @@
+/**
+ * Classes defining the rendering model for HTML
+ */
+package org.ajax4jsf.taglib.html.facelets;
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,163 @@
+/**
+ * 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.taglib.html.jsp;
+
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.webapp.UIComponentClassicTagBase;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.UIActionParameter;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
+
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:31 $
+ *
+ */
+public class ActionParamTag extends UIComponentTagBase
+{
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ return "org.ajax4jsf.components.ActionParameter";
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+ return null;
+ }
+ // UIComponent attributes --> already implemented in UIComponentTagBase
+
+ // UIParameter attributes
+ // value already implemented in UIComponentTagBase
+ private ValueExpression _name;
+ private ValueExpression _assignTo;
+ private ValueExpression _converter;
+ private ValueExpression _noEscape;
+ private MethodExpression _actionListener;
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setStringProperty(component, "name", _name);
+ setBooleanProperty(component, "noEscape", _noEscape);
+ if (_actionListener != null) {
+ ((UIActionParameter) component).setActionListener(_actionListener);
+ }
+
+ //Find parent UIComponentTag
+ UIComponentClassicTagBase componentTag =
+ UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
+ if (componentTag == null)
+ {
+ throw new
IllegalArgumentException(Messages.getMessage(Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR,
"ActionParameterTag"));
+ }
+
+ if (componentTag.getCreated())
+ {
+ //Component was just created, so we add the Listener
+ UIComponent parentComponent = componentTag.getComponentInstance();
+ if (parentComponent instanceof ActionSource)
+ {
+
+ if (_assignTo != null) {
+ if (_assignTo.isLiteralText()) throw new
IllegalArgumentException(Messages.getMessage(Messages.NO_VALUE_REFERENCE_ERROR_2,
_assignTo));
+ UIActionParameter al = (UIActionParameter)component;
+ al.setAssignToBinding(_assignTo);
+ if (_converter != null)
+ {
+ if (!_converter.isLiteralText()) {
+ component.setValueExpression("converter", _converter);
+ } else {
+ Converter conv =
FacesContext.getCurrentInstance().getApplication().createConverter(_converter.getExpressionString());
+ al.setConverter(conv);
+ }
+ }
+ ((ActionSource)parentComponent).addActionListener(al);
+ }
+ }
+ }
+
+ }
+
+ public void setName(ValueExpression name)
+ {
+ _name = name;
+ }
+
+ /**
+ * @param converter The converter to set.
+ */
+ public void setConverter(ValueExpression converter)
+ {
+ this._converter = converter;
+ }
+
+ /**
+ * @param noEscape The noEscape to set.
+ */
+ public void setNoEscape(ValueExpression noEscape)
+ {
+ this._noEscape = noEscape;
+ }
+
+ /**
+ * @param property The property to set.
+ */
+ public void setAssignTo(ValueExpression property)
+ {
+ this._assignTo = property;
+ }
+
+ /**
+ * @param property The property to set.
+ */
+ public void setActionListener(MethodExpression listener) {
+ this._actionListener = listener;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.myfaces.taglib.UIComponentTagBase#release()
+ */
+ public void release()
+ {
+ _name = null;
+ _assignTo = null;
+ _converter = null;
+ _noEscape = null;
+ _actionListener = null;
+ super.release();
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,55 @@
+/**
+ * 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.taglib.html.jsp;
+
+import org.ajax4jsf.component.UIAjaxForm;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
+
+
+/**
+ * Tag for creating Ajax version of HTML Form.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:32 $
+ *
+ */
+public class AjaxFormTag extends UIComponentTagBase
+{
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ // TODO Auto-generated method stub
+ return UIAjaxForm.COMPONENT_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+ // TODO Auto-generated method stub
+ return "javax.faces.Form";
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,111 @@
+/**
+ * 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.taglib.html.jsp;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.webapp.UIComponentClassicTagBase;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.event.AjaxListener;
+import org.ajax4jsf.event.AjaxListenerHelper;
+import org.ajax4jsf.event.AjaxSource;
+
+
+/**
+ * @author shura
+ *
+ * Custom tag for append AJAX request listeners to AjaxContainer.
+ *
+ */
+public class AjaxListenerTag extends TagSupport {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2576519366310474212L;
+ /**
+ * class name for ajax events listener.
+ */
+ private ValueExpression type = null;
+
+ private ValueExpression binding = null;
+
+ /**
+ *
+ */
+ public AjaxListenerTag() {
+ }
+
+ public void setType(ValueExpression type) {
+ this.type = type;
+ }
+
+ /**
+ * @param binding the binding to set
+ */
+ public void setBinding(ValueExpression binding) {
+ this.binding = binding;
+ }
+
+ public int doStartTag() throws JspException {
+ if (type == null) {
+ throw new
JspException(Messages.getMessage(Messages.NULL_TYPE_ATTRIBUTE_ERROR));
+ }
+
+ //Find parent UIComponentTag
+ UIComponentClassicTagBase componentTag =
+ UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
+ if (componentTag == null) {
+ throw new JspException(
+ Messages.getMessage(Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR,
"AjaxListenerTag"));
+ }
+
+ if (componentTag.getCreated()) {
+ //Component was just created, so we add the Listener
+ UIComponent component = componentTag.getComponentInstance();
+ if (component instanceof AjaxSource) {
+ AjaxListener listener;
+ if(null != binding){
+ listener = new AjaxListenerHelper(binding);
+ } else {
+ try {
+ String className = (String)
type.getValue(FacesContext.getCurrentInstance().getELContext());
+ listener = (AjaxListener) Class.forName(className).newInstance();
+ } catch (Exception e) {
+ throw new
JspException(Messages.getMessage(Messages.INSTANTIATE_LISTENER_ERROR, type,
component.getId()), e);
+ }
+ }
+ ((AjaxSource) component).addAjaxListener(listener);
+ } else {
+ throw new
JspException(Messages.getMessage(Messages.NOT_PARENT_AJAX_COMPONENT_ERROR,
component.getId()));
+ }
+ }
+
+ return Tag.SKIP_BODY;
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,88 @@
+/**
+ * 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.taglib.html.jsp;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.renderkit.html.AjaxPageRenderer;
+
+
+/**
+ * @author shura
+ *
+ * Other variant of AJAX View - render full html page with root <html>,
+ * <head> ( filled from "head" facet ) and <body> areas.
+ *
+ */
+public class AjaxPageTag extends AjaxRegionTag {
+
+ private ValueExpression onload;
+ private ValueExpression onunload;
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType() {
+ return AjaxPageRenderer.RENDERER_TYPE;
+ }
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.Tag#release()
+ */
+ public void release() {
+ this.onload = null;
+ this.onunload = null;
+ super.release();
+ }
+ /* (non-Javadoc)
+ * @see
javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ setStringProperty(component, "onload", this.onload);
+ setStringProperty(component, "onunload", this.onunload);
+ }
+ /**
+ * @return Returns the onload.
+ */
+ public ValueExpression getOnload() {
+ return onload;
+ }
+ /**
+ * @return Returns the onunload.
+ */
+ public ValueExpression getOnunload() {
+ return onunload;
+ }
+ /**
+ * @param onload The onload to set.
+ */
+ public void setOnload(ValueExpression onload) {
+ this.onload = onload;
+ }
+ /**
+ * @param onunload The onunload to set.
+ */
+ public void setOnunload(ValueExpression onunload) {
+ this.onunload = onunload;
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,158 @@
+/**
+ * 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.taglib.html.jsp;
+
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.AjaxContainer;
+import org.ajax4jsf.component.UIAjaxRegion;
+import org.ajax4jsf.renderkit.html.AjaxRegionRenderer;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
+
+
+/**
+ * @author shura
+ * Tag for create root Ajax component. must be immediate in produced html/body.
+ * Example use in jsp:
+ *
+ * For produce correct html code in any ( ajax and non-ajax requests ),
+ * better result with <ajax:page> tag.
+ */
+public class AjaxRegionTag extends UIComponentTagBase {
+
+ private MethodExpression ajaxListener = null;
+
+ private ValueExpression reRender = null;
+
+ private ValueExpression immediate = null;
+
+ private ValueExpression selfRendered = null;
+
+ private ValueExpression javascriptLocation = null;
+
+ /**
+ *
+ */
+ public AjaxRegionTag() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType() {
+ return UIAjaxRegion.COMPONENT_TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType() {
+ return AjaxRegionRenderer.RENDERER_TYPE;
+ }
+
+ // set component properties
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.jsp.tagext.Tag#release()
+ */
+ public void release() {
+ // release reources properties
+ super.release();
+ this.reRender = null;
+ this.ajaxListener = null;
+ this.immediate = null;
+ this.selfRendered = null;
+ this.javascriptLocation = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ setBooleanProperty(component, "immediate", this.immediate);
+ setStringProperty(component, "ajaxAreas", this.reRender);
+ setBooleanProperty(component,"selfRendered",this.selfRendered);
+ setStringProperty(component, "javascriptLocation",
this.javascriptLocation);
+ if (ajaxListener != null) {
+ if (!(component instanceof AjaxContainer)) {
+ throw new
IllegalArgumentException(Messages.getMessage(Messages.NOT_AJAX_CONTAINER_ERROR,
component.getClientId(getFacesContext())));
+ }
+ if (ajaxListener.isLiteralText()) {
+
getFacesContext().getExternalContext().log(Messages.getMessage(Messages.INVALID_EXPRESSION,
ajaxListener));
+ }
+ ((AjaxContainer) component).setAjaxListener(ajaxListener);
+
+ }
+ }
+
+ /**
+ * @param ajaxAreas
+ * The ajaxAreas to set.
+ */
+ public void setReRender(ValueExpression ajaxAreas) {
+ this.reRender = ajaxAreas;
+ }
+
+ /**
+ * @param ajaxListener
+ * The ajaxListener to set.
+ */
+ public void setAjaxListener(MethodExpression ajaxListener) {
+ this.ajaxListener = ajaxListener;
+ }
+
+ /**
+ * @param immediate
+ * The immediate to set.
+ */
+ public void setImmediate(ValueExpression immediate) {
+ this.immediate = immediate;
+ }
+
+ /**
+ * @param selfRendered The selfRendered to set.
+ */
+ public void setSelfRendered(ValueExpression selfRendered) {
+ this.selfRendered = selfRendered;
+ }
+
+// public String getJavascriptLocation() {
+// return javascriptLocation;
+// }
+//
+ public void setJavascriptLocation(ValueExpression javascriptLocation) {
+ this.javascriptLocation = javascriptLocation;
+ }
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,190 @@
+/**
+ * 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.taglib.html.jsp;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.component.UIAjaxStatus;
+import org.ajax4jsf.renderkit.html.AjaxStatusRenderer;
+import org.ajax4jsf.webapp.taglib.HtmlComponentTagBase;
+
+
+/**
+ *
+ * Jsp Tag for create request state component.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:30 $
+ *
+ */
+public class AjaxStatusTag extends HtmlComponentTagBase
+{
+
+ private ValueExpression _for = null;
+ /**
+ * Text to output on start request
+ */
+ private ValueExpression _startText = null;
+ /**
+ * Text to display on complete request
+ */
+ private ValueExpression _stopText = null;
+
+ /**
+ * Style for display on start request
+ */
+ private ValueExpression _startStyle = null;
+ /**
+ * Style for displaying on complete
+ */
+ private ValueExpression _stopStyle = null;
+ /**
+ * Style class for display on request
+ */
+ private ValueExpression _startStyleClass = null;
+ /**
+ * Style class for display on complete request
+ */
+ private ValueExpression _stopStyleClass = null;
+
+ /**
+ * Force id to render in Html as is
+ */
+ private ValueExpression _forceId = null;
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ // TODO Auto-generated method stub
+ return UIAjaxStatus.COMPONENT_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+ // TODO Auto-generated method stub
+ return AjaxStatusRenderer.RENDERER_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.components.taglib.html.HtmlComponentTagBase#release()
+ */
+ public void release()
+ {
+ super.release();
+ this._for = null;
+ this._startStyle = null;
+ this._startStyleClass = null;
+ this._startText = null;
+ this._stopStyle = null;
+ this._stopStyleClass = null;
+ this._stopText = null;
+ this._forceId = null;
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.components.taglib.html.HtmlComponentTagBase#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setStringProperty(component, "for", _for);
+ setStringProperty(component, "startText", _startText);
+ setStringProperty(component, "stopText", _stopText);
+ setStringProperty(component, "startStyle", _startStyle);
+ setStringProperty(component, "stopStyle", _stopStyle);
+ setStringProperty(component, "startStyleClass", _startStyleClass);
+ setStringProperty(component, "stopStyleClass", _stopStyleClass);
+ setBooleanProperty(component, "forceId", _forceId);
+
+ }
+
+
+ /**
+ * @param _for The _for to set.
+ */
+ public void setFor(ValueExpression _for)
+ {
+ this._for = _for;
+ }
+
+ /**
+ * @param style The _startStyle to set.
+ */
+ public void setStartStyle(ValueExpression style)
+ {
+ _startStyle = style;
+ }
+
+ /**
+ * @param styleClass The _startStyleClass to set.
+ */
+ public void setStartStyleClass(ValueExpression styleClass)
+ {
+ _startStyleClass = styleClass;
+ }
+
+ /**
+ * @param text The _startText to set.
+ */
+ public void setStartText(ValueExpression text)
+ {
+ _startText = text;
+ }
+
+ /**
+ * @param stopText The stopText to set.
+ */
+ public void setStopText(ValueExpression stopText)
+ {
+ this._stopText = stopText;
+ }
+
+ /**
+ * @param style The _stopStyle to set.
+ */
+ public void setStopStyle(ValueExpression style)
+ {
+ _stopStyle = style;
+ }
+
+ /**
+ * @param styleClass The _stopStyleClass to set.
+ */
+ public void setStopStyleClass(ValueExpression styleClass)
+ {
+ _stopStyleClass = styleClass;
+ }
+
+ /**
+ * @param forceId The forceId to set.
+ */
+ public void setForceId(ValueExpression forceId)
+ {
+ this._forceId = forceId;
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,288 @@
+/**
+ * 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.taglib.html.jsp;
+
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.webapp.UIComponentClassicTagBase;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.UIAjaxSupport;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
+
+
+/**
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:32 $
+ *
+ */
+public class AjaxSupportTag extends UIComponentTagBase {
+
+ static final String[] EVENT_HANDLER_ATTRIBUTES =
+ {
+ HTML.ondblclick_ATTRIBUTE,
+ HTML.onmousedown_ATTRIBUTE,
+ HTML.onmouseup_ATTRIBUTE,
+ HTML.onmouseover_ATTRIBUTE,
+ HTML.onmousemove_ATTRIBUTE,
+ HTML.onmouseout_ATTRIBUTE,
+ HTML.onkeypress_ATTRIBUTE,
+ HTML.onkeydown_ATTRIBUTE,
+ HTML.onkeyup_ATTRIBUTE,
+ HTML.onclick_ATTRIBUTE,
+ HTML.onchange_ATTRIBUTE,
+ HTML.onblur_ATTRIBUTE,
+ HTML.onfocus_ATTRIBUTE,
+ HTML.onselect_ATTRIBUTE
+ };
+
+ public static final String AJAX_SUPPORT_FACET = "org.ajax4jsf.ajax.SUPPORT";
+ /**
+ * Id ( in form of findComponent method param ) of JSF component,
+ * updated by this component ( parnt tag ) action.
+ */
+ private ValueExpression reRender = null;
+
+ /**
+ * Generate script for given event ( onclick, onenter ... )
+ */
+ private String event = null;
+
+
+ /**
+ * Id of request status component.
+ */
+ private ValueExpression status = null;
+
+ /**
+ * JavaScript function for call after request completed.
+ */
+ private ValueExpression oncomplete = null ;
+
+ private MethodExpression action = null;
+ private MethodExpression actionListener = null;
+ private ValueExpression limitToList = null;
+ private ValueExpression disableDefault = null;
+ private ValueExpression value = null;
+ private ValueExpression immediate = null;
+ private ValueExpression ajaxSingle = null;
+
+
+
+
+ /**
+ * @param type The type to set.
+ */
+ public void setDisableDefault(ValueExpression ajaxType)
+ {
+ this.disableDefault = ajaxType;
+ }
+
+ /**
+ * @param reRender
+ * The targetId to set.
+ */
+ public void setReRender(ValueExpression ajaxId) {
+ this.reRender = ajaxId;
+ }
+
+
+ /**
+ * @param event The event to set.
+ */
+ public void setEvent(String event)
+ {
+ this.event = event;
+ }
+
+ /**
+ * @param oncomplete The oncomplete to set.
+ */
+ public void setOncomplete(ValueExpression oncomplete)
+ {
+ this.oncomplete = oncomplete;
+ }
+
+ /**
+ * @param status The status to set.
+ */
+ public void setStatus(ValueExpression status)
+ {
+ this.status = status;
+ }
+
+ /**
+ * @param limitToList The submitForm to set.
+ */
+ public void setLimitToList(ValueExpression limitToList)
+ {
+ this.limitToList = limitToList;
+ }
+
+ /**
+ * @param action The action to set.
+ */
+ public void setAction(MethodExpression action)
+ {
+ this.action = action;
+ }
+
+ /**
+ * @param actionListener The actionListener to set.
+ */
+ public void setActionListener(MethodExpression actionListener)
+ {
+ this.actionListener = actionListener;
+ }
+
+ protected void setParentProperties(UIAjaxSupport uiComponent) {
+
+ //Find parent UIComponentTag
+ UIComponentClassicTagBase componentTag = null;
+ try {
+ componentTag =
UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
+ if (componentTag == null) {
+ throw new IllegalArgumentException(
+ Messages.getMessage(Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR,
"AjaxSupportTag"));
+ }
+
+ if (componentTag.getCreated()) {
+ //Component was just created, so we add the Listener
+ UIComponent component = componentTag.getComponentInstance();
+ uiComponent.setParentProperties(component);
+ }
+ } catch (ClassCastException e) {
+ // JSF 1.2 - tags have other parent.
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.Tag#release()
+ */
+ public void release() {
+ this.reRender = null;
+ this.oncomplete = null;
+ this.event = null;
+ this.status =null;
+ this.action = null;
+ this.actionListener = null;
+ this.limitToList = null;
+ this.disableDefault = null;
+ this.value = null;
+ this.immediate=null;
+ this.ajaxSingle = null;
+ super.release();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+
+ return UIAjaxSupport.COMPONENT_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+
+ return UIAjaxSupport.DEFAULT_RENDERER_TYPE;
+ }
+
+ /**
+ * @param value The value to set.
+ */
+ public void setValue(ValueExpression value) {
+ this.value = value;
+ }
+
+ /**
+ * @param immediate The immediate to set.
+ */
+ public void setImmediate(ValueExpression immediate) {
+ this.immediate = immediate;
+ }
+
+ /**
+ * @param ajaxSingle The ajaxSingle to set.
+ */
+ public void setAjaxSingle(ValueExpression ajaxSingle) {
+ this.ajaxSingle = ajaxSingle;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.components.taglib.UIComponentTagBase#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setStringProperty(component, "event", event);
+ setReRenderProperty(component);
+ setStringProperty(component, "status", status);
+ setStringProperty(component, "oncomplete", oncomplete);
+ setBooleanProperty(component, "disableDefault", disableDefault );
+ setBooleanProperty(component, "limitToList", limitToList);
+ setActionProperty(component, action);
+ setActionListenerProperty(component, actionListener);
+ setValueProperty(component,value);
+ setBooleanProperty(component,"immediate",immediate);
+ setBooleanProperty(component,"ajaxSingle",ajaxSingle);
+
+ setParentProperties((UIAjaxSupport) component);
+ }
+
+
+ private void setReRenderProperty(UIComponent component) {
+ if (reRender != null) {
+ if (reRender.isLiteralText()) {
+ setStringProperty(component, "reRender", reRender);
+ } else {
+ //FIXME: Why do we evaluate reRender right now?
+ //Collection can change any time.
+ ((UIAjaxSupport) component).setReRender(
AjaxRendererUtils.asSet(reRender.getValue(getELContext())));
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getFacetName()
+ */
+ protected String getFacetName() {
+ // TODO Auto-generated method stub
+ if (null != event) {
+ return AJAX_SUPPORT_FACET + event;
+ } else {
+ return AJAX_SUPPORT_FACET;
+ }
+ }
+
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,261 @@
+/**
+ * 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.taglib.html.jsp;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+
+import org.ajax4jsf.component.UIInclude;
+import org.ajax4jsf.webapp.taglib.UIComponentTagBase;
+
+/**
+ * @author shura
+ *
+ */
+public class IncludeTag extends UIComponentTagBase {
+
+ /**
+ * @author shura
+ *
+ */
+ private static final class NullJspWriter extends JspWriter {
+
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ private NullJspWriter() {
+ super(1024, false);
+ }
+
+ public void clear() throws IOException {
+ }
+
+ public void clearBuffer() throws IOException {
+ }
+
+ public void close() throws IOException {
+ }
+
+ public void flush() throws IOException {
+ }
+
+ public int getRemaining() {
+ return 0;
+ }
+
+ public void newLine() throws IOException {
+ }
+
+ public void print(boolean arg0) throws IOException {
+ }
+
+ public void print(char arg0) throws IOException {
+ }
+
+ public void print(int arg0) throws IOException {
+ }
+
+ public void print(long arg0) throws IOException {
+ }
+
+ public void print(float arg0) throws IOException {
+ }
+
+ public void print(double arg0) throws IOException {
+ }
+
+ public void print(char[] arg0) throws IOException {
+ }
+
+ public void print(String arg0) throws IOException {
+ }
+
+ public void print(Object arg0) throws IOException {
+ }
+
+ public void println() throws IOException {
+ }
+
+ public void println(boolean arg0) throws IOException {
+ }
+
+ public void println(char arg0) throws IOException {
+ }
+
+ public void println(int arg0) throws IOException {
+ }
+
+ public void println(long arg0) throws IOException {
+ }
+
+ public void println(float arg0) throws IOException {
+ }
+
+ public void println(double arg0) throws IOException {
+ }
+
+ public void println(char[] arg0) throws IOException {
+ }
+
+ public void println(String arg0) throws IOException {
+ }
+
+ public void println(Object arg0) throws IOException {
+ }
+
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ }
+ }
+
+ private ValueExpression viewId;
+
+ /**
+ * @param viewId
+ * the viewId to set
+ */
+ public void setViewId(ValueExpression viewId) {
+ this.viewId = viewId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.taglib.UIComponentTagBase#release()
+ */
+ public void release() {
+ super.release();
+ viewId = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.webapp.taglib.UIComponentTagBase#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ UIInclude include = (UIInclude) component;
+ if (this.viewId != null) {
+ if (this.viewId.isLiteralText()) {
+ try {
+
+ String value = (String) getFacesContext().getApplication()
+ .getExpressionFactory().coerceToType(
+ this.viewId.getExpressionString(),
+ String.class);
+
+ include.setViewId(value);
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+ } else {
+ component.setValueExpression("viewId", this.viewId);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#doEndTag()
+ */
+ public int doEndTag() throws JspException {
+ int i = super.doEndTag();
+ return i;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#doStartTag()
+ */
+ public int doStartTag() throws JspException {
+ int i = super.doStartTag();
+ String resourcePath;
+ UIComponent component = getComponentInstance();
+ UIInclude includeComponent = null;
+ if (component instanceof UIInclude) {
+ includeComponent = (UIInclude) component;
+ resourcePath = includeComponent.getViewId();
+ if(includeComponent.isWasNavigation()){
+ component.getChildren().clear();
+ }
+ } else {
+ resourcePath = (String) component.getAttributes().get("viewId");
+ }
+ JspWriter out;
+ if (component.isRendered()) {
+ out = this.pageContext.getOut();
+ } else {
+ // All content of response will be skip.
+ out = new NullJspWriter();
+ }
+ ServletRequest request = this.pageContext.getRequest();
+ ServletResponse response = this.pageContext.getResponse();
+ RequestDispatcher rd = request.getRequestDispatcher(resourcePath);
+ FacesContext facesContext = getFacesContext();
+ if(null == rd){
+ throw new JspException("UIInclude component
"+component.getClientId(facesContext)+ " could't include page with path
"+resourcePath);
+ }
+ try {
+ ServletResponseWrapperInclude responseWrapper = new ServletResponseWrapperInclude(
+ response, out);
+ rd.include(request, responseWrapper);
+ // Write buffered data, if any;
+ responseWrapper.flushBuffer();
+ } catch (Exception e) {
+ throw new JspException(e);
+ }
+ return i;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType() {
+ return UIInclude.COMPONENT_TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType() {
+ return null;
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,131 @@
+/**
+ * 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.taglib.html.jsp;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.faces.application.Application;
+import javax.faces.context.FacesContext;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.event.AjaxPhaseListener;
+
+/**
+ * @author shura
+ *
+ */
+public class KeepAliveTag extends TagSupport {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4322021112358067548L;
+
+ private String beanName = null;
+
+ private ValueExpression ajaxOnly = null;
+
+ /**
+ * @return the ajaxOnly
+ */
+ public ValueExpression getAjaxOnly() {
+ return ajaxOnly;
+ }
+
+ /**
+ * @param ajaxOnly the ajaxOnly to set
+ */
+ public void setAjaxOnly(ValueExpression ajaxOnly) {
+ this.ajaxOnly = ajaxOnly;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getBeanName() {
+ return beanName;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setBeanName(String name) {
+ this.beanName = name;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
+ */
+ public int doStartTag() throws JspException {
+ if (beanName == null) {
+ throw new
JspException(Messages.getMessage(Messages.NULL_TYPE_ATTRIBUTE_ERROR));
+ }
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application application = facesContext.getApplication();
+ ExpressionFactory factory = application.getExpressionFactory();
+ ELContext elContext = facesContext.getELContext();
+ ValueExpression beanNameEL =
+ factory.createValueExpression(elContext, beanName, String.class);
+ if(!beanNameEL.isLiteralText()){
+ throw new JspException(Messages.getMessage(Messages.NAME_MUST_BE_LITERAL));
+ }
+ boolean isAjaxOnly = false;
+ if (null != ajaxOnly) {
+ if (ajaxOnly.isLiteralText())
+ {
+ //TODO: More sophisticated way to convert boolean value (yes/no, 1/0,
on/off, etc.)
+ isAjaxOnly = Boolean.parseBoolean(ajaxOnly.getExpressionString());
+ }
+ else
+ {
+ isAjaxOnly = Boolean.TRUE.equals(ajaxOnly.getValue(elContext));
+ }
+
+ }
+ // Get bean instance from EL expression.
+ String beanExpression = "#{"+beanName+"}";
+ ValueExpression valueExpression =
+ factory.createValueExpression(elContext, beanExpression, Object.class);
+ Object bean = valueExpression.getValue(elContext);
+ // Put bean instance to ViewRoot.
+ String beanAttributeName = (isAjaxOnly ? AjaxPhaseListener.AJAX_BEAN_PREFIX :
AjaxPhaseListener.VIEW_BEAN_PREFIX)
+ + beanName;
+ facesContext.getViewRoot().getAttributes().put(beanAttributeName, bean);
+ return Tag.SKIP_BODY;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.TagSupport#release()
+ */
+ public void release() {
+ beanName = null;
+ ajaxOnly = null;
+ super.release();
+ }
+
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,168 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+import javax.servlet.jsp.JspWriter;
+
+import org.ajax4jsf.io.FastBufferOutputStream;
+
+
+
+/**
+ * ServletResponseWrapper used by the JSP 'include' action.
+ *
+ * This wrapper response object is passed to RequestDispatcher.include(), so
+ * that the output of the included resource is appended to that of the including
+ * page.
+ *
+ * @author Pierre Delisle
+ */
+
+public class ServletResponseWrapperInclude extends HttpServletResponseWrapper {
+
+ /**
+ * PrintWriter which appends to the JspWriter of the including page.
+ */
+ private PrintWriter _printWriter;
+
+ private FastBufferOutputStream _bytes ;
+
+ private ServletOutputStream _servletStream;
+
+ private JspWriter _jspWriter;
+
+ private boolean useWriter = false;
+
+ private boolean useStream = false;
+
+ public ServletResponseWrapperInclude(ServletResponse response,
+ JspWriter jspWriter) {
+ super((HttpServletResponse) response);
+ this._printWriter = new PrintWriter(jspWriter);
+ this._jspWriter = jspWriter;
+ }
+
+ /**
+ * Returns a wrapper around the JspWriter of the including page.
+ */
+ public PrintWriter getWriter() throws IOException {
+ if (useStream) {
+ throw new IllegalStateException();
+ }
+ useWriter = true;
+ return _printWriter;
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException {
+ if(useWriter){
+ throw new IllegalStateException();
+ }
+ if (!useStream) {
+ _bytes = new FastBufferOutputStream(getBufferSize());
+ _servletStream = new ServletOutputStream(){
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#flush()
+ */
+ public void flush() throws IOException {
+ // TODO Auto-generated method stub
+ super.flush();
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public void write(byte[] b, int off, int len) throws IOException {
+ // TODO Auto-generated method stub
+ _bytes.write(b, off, len);
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[])
+ */
+ public void write(byte[] b) throws IOException {
+ // TODO Auto-generated method stub
+ _bytes.write(b);
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(int)
+ */
+ public void write(int b) throws IOException {
+ _bytes.write(b);
+ }
+
+ };
+ useStream = true;
+ }
+ return _servletStream;
+ }
+
+ /**
+ * Clears the output buffer of the JspWriter associated with the including
+ * page.
+ */
+ public void resetBuffer() {
+ try {
+ _jspWriter.clearBuffer();
+ useWriter = false;
+ useStream = false;
+ _bytes = null;
+ } catch (IOException ioe) {
+ }
+ }
+
+ public void reset() {
+ // TODO Auto-generated method stub
+ resetBuffer();
+ }
+
+ public void flushBuffer() throws IOException {
+ if (useStream) {
+ // TODO - detect encoding ?
+ _bytes.writeTo(_jspWriter, getCharacterEncoding());
+ _bytes = new FastBufferOutputStream(getBufferSize());
+ }
+ }
+
+ // Override ignored methods.
+ public void setBufferSize(int arg0) {
+ }
+
+ public void setContentLength(int arg0) {
+ }
+ public void setContentType(String arg0) {
+ }
+ public void setStatus(int arg0) {
+ }
+ public void setLocale(Locale arg0) {
+ }
+ public void sendRedirect(String arg0) throws IOException {
+ throw new IllegalStateException();
+ }
+// public void setStatus(int arg0, String arg1) {
+// }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/package-info.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/package-info.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/package-info.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/jsp/package-info.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,4 @@
+/**
+ * Tag library contains JSP tags that are useful in creating dynamic reusable components
+ */
+package org.ajax4jsf.taglib.html.jsp;
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonGradientImage.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonGradientImage.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonGradientImage.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonGradientImage.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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.renderkit.html.gradientimages;
+
+import org.richfaces.renderkit.html.images.BaseControlBackgroundImage;
+import org.richfaces.skin.Skin;
+
+public class ButtonGradientImage extends BaseControlBackgroundImage {
+
+ public ButtonGradientImage() {
+ super(Skin.additionalBackgroundColor, "trimColor", 8);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonInverseGradientImage.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonInverseGradientImage.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonInverseGradientImage.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/ButtonInverseGradientImage.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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.renderkit.html.gradientimages;
+
+import org.richfaces.renderkit.html.images.BaseControlBackgroundImage;
+import org.richfaces.skin.Skin;
+
+public class ButtonInverseGradientImage extends BaseControlBackgroundImage {
+
+ public ButtonInverseGradientImage() {
+ super("trimColor", Skin.additionalBackgroundColor, 8);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderGradientImage.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderGradientImage.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderGradientImage.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderGradientImage.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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.renderkit.html.gradientimages;
+
+import org.richfaces.renderkit.html.images.BaseControlBackgroundImage;
+import org.richfaces.skin.Skin;
+
+public class HeaderGradientImage extends BaseControlBackgroundImage {
+
+ public HeaderGradientImage() {
+ super(Skin.headerGradientColor, Skin.headerBackgroundColor, 8);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderInverseGradientImage.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderInverseGradientImage.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderInverseGradientImage.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/HeaderInverseGradientImage.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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.renderkit.html.gradientimages;
+
+import org.richfaces.renderkit.html.images.BaseControlBackgroundImage;
+import org.richfaces.skin.Skin;
+
+public class HeaderInverseGradientImage extends BaseControlBackgroundImage {
+
+ public HeaderInverseGradientImage() {
+ super(Skin.headerBackgroundColor, Skin.headerGradientColor, 8);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/InputGradientImage.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/InputGradientImage.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/InputGradientImage.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/InputGradientImage.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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.renderkit.html.gradientimages;
+
+import org.richfaces.renderkit.html.images.BaseControlBackgroundImage;
+import org.richfaces.skin.Skin;
+
+public class InputGradientImage extends BaseControlBackgroundImage {
+
+ public InputGradientImage() {
+ super(Skin.additionalBackgroundColor, Skin.controlBackgroundColor, 8);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuGradientImage.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuGradientImage.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuGradientImage.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuGradientImage.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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.renderkit.html.gradientimages;
+
+import org.richfaces.renderkit.html.images.BaseControlBackgroundImage;
+import org.richfaces.skin.Skin;
+
+public class MenuGradientImage extends BaseControlBackgroundImage {
+
+ public MenuGradientImage() {
+ super("tabBackgroundColor", Skin.additionalBackgroundColor, 8);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuInverseGradientImage.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuInverseGradientImage.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuInverseGradientImage.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/MenuInverseGradientImage.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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.renderkit.html.gradientimages;
+
+import org.richfaces.renderkit.html.images.BaseControlBackgroundImage;
+import org.richfaces.skin.Skin;
+
+public class MenuInverseGradientImage extends BaseControlBackgroundImage {
+
+ public MenuInverseGradientImage() {
+ super(Skin.additionalBackgroundColor, "tabBackgroundColor", 8);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabGradientImage.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabGradientImage.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabGradientImage.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabGradientImage.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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.renderkit.html.gradientimages;
+
+import org.richfaces.renderkit.html.images.BaseControlBackgroundImage;
+import org.richfaces.skin.Skin;
+
+public class TabGradientImage extends BaseControlBackgroundImage {
+
+ public TabGradientImage() {
+ super("tabBackgroundColor", Skin.generalBackgroundColor, 8);
+ }
+
+}
Copied:
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabInverseGradientImage.java
(from rev 15053,
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabInverseGradientImage.java)
===================================================================
---
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabInverseGradientImage.java
(rev 0)
+++
root/ui-sandbox/trunk/components/core/src/main/java/org/richfaces/renderkit/html/gradientimages/TabInverseGradientImage.java 2009-07-31
11:19:57 UTC (rev 15073)
@@ -0,0 +1,33 @@
+/**
+ * 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.renderkit.html.gradientimages;
+
+import org.richfaces.renderkit.html.images.BaseControlBackgroundImage;
+import org.richfaces.skin.Skin;
+
+public class TabInverseGradientImage extends BaseControlBackgroundImage {
+
+ public TabInverseGradientImage() {
+ super(Skin.generalBackgroundColor, "tabBackgroundColor", 8);
+ }
+
+}