Author: abelevich
Date: 2009-08-21 10:52:37 -0400 (Fri, 21 Aug 2009)
New Revision: 15255
Added:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
Removed:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBeahaviorRenderer.java
Log:
rename
Deleted:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBeahaviorRenderer.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBeahaviorRenderer.java 2009-08-21
14:48:31 UTC (rev 15254)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBeahaviorRenderer.java 2009-08-21
14:52:37 UTC (rev 15255)
@@ -1,103 +0,0 @@
-package org.ajax4jsf.renderkit;
-
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.ActionSource;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorContext;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AjaxBehaviorEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.render.ClientBehaviorRenderer;
-import javax.faces.render.FacesBehaviorRenderer;
-import javax.faces.render.RenderKitFactory;
-
-import org.ajax4jsf.component.behavior.AjaxBehavior;
-import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.context.PartialViewContextFactoryImpl;
-import org.richfaces.context.PartialViewContextImpl;
-
-/**
- * @author Anton Belevich
- *
- */
-(a)FacesBehaviorRenderer(rendererType="org.ajax4jsf.behavior.Ajax",renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT)
-@ResourceDependencies({
- @ResourceDependency(name="jquery.js", target="head"),
- @ResourceDependency(name="richfaces.js", target="head")
-})
-public class AjaxBeahaviorRenderer extends ClientBehaviorRenderer {
- @Override
- public void decode(FacesContext context, UIComponent component, ClientBehavior behavior)
{
-
- if (null == context || null == component || null == behavior) {
- throw new NullPointerException();
- }
-
- if (!(behavior instanceof AjaxBehavior)) {
- throw new
IllegalArgumentException("org.ajax4jsf.component.behavior.AjaxBehavior required:
" + behavior);
- }
-
- AjaxBehavior ajaxBehavior = (AjaxBehavior)behavior;
-
- if (ajaxBehavior.isDisabled()) {
- return;
- }
-
- component.queueEvent(createEvent(component, ajaxBehavior));
- }
-
- private static AjaxBehaviorEvent createEvent(UIComponent component, AjaxBehavior
ajaxBehavior) {
- AjaxBehaviorEvent event = new AjaxBehaviorEvent(component, ajaxBehavior);
- PhaseId phaseId = isImmediate(component, ajaxBehavior) ?
PhaseId.APPLY_REQUEST_VALUES : PhaseId.INVOKE_APPLICATION;
- event.setPhaseId(phaseId);
-
- return event;
- }
-
- private static boolean isImmediate(UIComponent component, AjaxBehavior ajaxBehavior) {
- boolean immediate = false;
-
- if (ajaxBehavior.isImmediateSet()) {
- immediate = ajaxBehavior.isImmediate();
- } else if (component instanceof EditableValueHolder) {
- immediate = ((EditableValueHolder)component).isImmediate();
- } else if (component instanceof ActionSource) {
- immediate = ((ActionSource)component).isImmediate();
- }
- return immediate;
- }
-
- @Override
- public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior behavior)
{
- String script = null;
- if(behavior instanceof AjaxBehavior) {
- script = buildAjaxCommand(behaviorContext, (AjaxBehavior)behavior);
- }
- return script;
- }
-
- public String buildAjaxCommand(ClientBehaviorContext bContext, AjaxBehavior behavior) {
- UIComponent parent = bContext.getComponent();
- FacesContext context = bContext.getFacesContext();
-
- JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(parent, context,
AjaxRendererUtils.AJAX_FUNCTION_NAME);
-
- AjaxEventOptions options = buildOptions(context, bContext);
- ajaxFunction.addParameter(options);
-
- return ajaxFunction.toString();
- }
-
- public AjaxEventOptions buildOptions(FacesContext context, ClientBehaviorContext
bContext) {
- UIComponent parent = bContext.getComponent();
- String eventName = bContext.getEventName();
-
- AjaxEventOptions options = AjaxRendererUtils.buildEventOptions(context, parent);
- options.setParameter(PartialViewContextImpl.BEHAVIOR_EVENT_PARAMETER, eventName);
- options.setParameter(PartialViewContextFactoryImpl.RICHFACES_AJAX,
parent.getClientId());
- return options;
- }
-}
Added:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
(rev 0)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2009-08-21
14:52:37 UTC (rev 15255)
@@ -0,0 +1,103 @@
+package org.ajax4jsf.renderkit;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.ActionSource;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AjaxBehaviorEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.render.ClientBehaviorRenderer;
+import javax.faces.render.FacesBehaviorRenderer;
+import javax.faces.render.RenderKitFactory;
+
+import org.ajax4jsf.component.behavior.AjaxBehavior;
+import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.context.PartialViewContextFactoryImpl;
+import org.richfaces.context.PartialViewContextImpl;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+(a)FacesBehaviorRenderer(rendererType="org.ajax4jsf.behavior.Ajax",renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT)
+@ResourceDependencies({
+ @ResourceDependency(name="jquery.js", target="head"),
+ @ResourceDependency(name="richfaces.js", target="head")
+})
+public class AjaxBehaviorRenderer extends ClientBehaviorRenderer {
+ @Override
+ public void decode(FacesContext context, UIComponent component, ClientBehavior behavior)
{
+
+ if (null == context || null == component || null == behavior) {
+ throw new NullPointerException();
+ }
+
+ if (!(behavior instanceof AjaxBehavior)) {
+ throw new
IllegalArgumentException("org.ajax4jsf.component.behavior.AjaxBehavior required:
" + behavior);
+ }
+
+ AjaxBehavior ajaxBehavior = (AjaxBehavior)behavior;
+
+ if (ajaxBehavior.isDisabled()) {
+ return;
+ }
+
+ component.queueEvent(createEvent(component, ajaxBehavior));
+ }
+
+ private static AjaxBehaviorEvent createEvent(UIComponent component, AjaxBehavior
ajaxBehavior) {
+ AjaxBehaviorEvent event = new AjaxBehaviorEvent(component, ajaxBehavior);
+ PhaseId phaseId = isImmediate(component, ajaxBehavior) ?
PhaseId.APPLY_REQUEST_VALUES : PhaseId.INVOKE_APPLICATION;
+ event.setPhaseId(phaseId);
+
+ return event;
+ }
+
+ private static boolean isImmediate(UIComponent component, AjaxBehavior ajaxBehavior) {
+ boolean immediate = false;
+
+ if (ajaxBehavior.isImmediateSet()) {
+ immediate = ajaxBehavior.isImmediate();
+ } else if (component instanceof EditableValueHolder) {
+ immediate = ((EditableValueHolder)component).isImmediate();
+ } else if (component instanceof ActionSource) {
+ immediate = ((ActionSource)component).isImmediate();
+ }
+ return immediate;
+ }
+
+ @Override
+ public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior behavior)
{
+ String script = null;
+ if(behavior instanceof AjaxBehavior) {
+ script = buildAjaxCommand(behaviorContext, (AjaxBehavior)behavior);
+ }
+ return script;
+ }
+
+ public String buildAjaxCommand(ClientBehaviorContext bContext, AjaxBehavior behavior) {
+ UIComponent parent = bContext.getComponent();
+ FacesContext context = bContext.getFacesContext();
+
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(parent, context,
AjaxRendererUtils.AJAX_FUNCTION_NAME);
+
+ AjaxEventOptions options = buildOptions(context, bContext);
+ ajaxFunction.addParameter(options);
+
+ return ajaxFunction.toString();
+ }
+
+ public AjaxEventOptions buildOptions(FacesContext context, ClientBehaviorContext
bContext) {
+ UIComponent parent = bContext.getComponent();
+ String eventName = bContext.getEventName();
+
+ AjaxEventOptions options = AjaxRendererUtils.buildEventOptions(context, parent);
+ options.setParameter(PartialViewContextImpl.BEHAVIOR_EVENT_PARAMETER, eventName);
+ options.setParameter(PartialViewContextFactoryImpl.RICHFACES_AJAX,
parent.getClientId());
+ return options;
+ }
+}