JBoss Rich Faces SVN: r15255 - root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit.
by richfaces-svn-commits@lists.jboss.org
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
- *
- */
-@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
+ *
+ */
+@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;
+ }
+}
15 years, 4 months
JBoss Rich Faces SVN: r15254 - root/framework/trunk/api/src/main/java/org/ajax4jsf/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-08-21 10:48:31 -0400 (Fri, 21 Aug 2009)
New Revision: 15254
Modified:
root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java
Log:
add new ajax methods
Modified: root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java 2009-08-21 14:46:12 UTC (rev 15253)
+++ root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java 2009-08-21 14:48:31 UTC (rev 15254)
@@ -26,4 +26,17 @@
public boolean isDisabled();
public void setDisabled(boolean disabled);
+
+ public void setQueueId(String queueId);
+
+ public String getQueueId();
+
+ public void setStatusId(String queueId);
+
+ public String getStatusId();
+
+ public String getSimilarityGroupingId();
+
+ public void setSimilarityGroupingId(String similarityGroupingId);
+
}
15 years, 4 months
JBoss Rich Faces SVN: r15253 - in root/ui/trunk/components/core/src/main/java/org/ajax4jsf: facelets/tag and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-08-21 10:46:12 -0400 (Fri, 21 Aug 2009)
New Revision: 15253
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java
Log:
add queueId, statusId, similarityGroupingId attributes
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-08-21 14:24:03 UTC (rev 15252)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-08-21 14:46:12 UTC (rev 15253)
@@ -15,11 +15,85 @@
public class AjaxBehavior extends javax.faces.component.behavior.AjaxBehavior implements AjaxClientBehavior{
public static final String BEHAVIOR_ID = "org.ajax4jsf.behavior.Ajax";
+
public static final String LIMIT_RENDER = "limitRender";
+ public static final String QUEUE_ID = "queueId";
+
+ public static final String STATUS_ID = "statusId";
+
+ public static final String SIMILARITY_GROPING = "similarityGroupingId";
+
private Boolean limitRender;
+ private String queueId;
+
+ private String statusId;
+ private String similarityGroupingId;
+
+ public String getSimilarityGroupingId() {
+ if(this.similarityGroupingId != null) {
+ return this.similarityGroupingId;
+ }
+
+ ValueExpression ex = getValueExpression(SIMILARITY_GROPING);
+ if(ex != null) {
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+ String value = ((String)ex.getValue(elContext));
+ return value;
+ }
+
+ return this.similarityGroupingId;
+ }
+
+ public void setSimilarityGroupingId(String similarityGroupingId) {
+ this.similarityGroupingId = similarityGroupingId;
+ clearInitialState();
+ }
+
+ public String getStatusId() {
+ if(this.statusId != null) {
+ return this.statusId;
+ }
+
+ ValueExpression ex = getValueExpression(STATUS_ID);
+ if(ex != null) {
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+ String value = ((String)ex.getValue(elContext));
+ return value;
+ }
+
+ return this.statusId;
+ }
+
+ public void setStatusId(String statusId) {
+ this.statusId = statusId;
+ clearInitialState();
+ }
+
+ public String getQueueId() {
+ if(this.queueId != null) {
+ return this.queueId;
+ }
+
+ ValueExpression ex = getValueExpression(QUEUE_ID);
+ if(ex != null) {
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+ String value = ((String)ex.getValue(elContext));
+ return value;
+ }
+
+ return this.queueId;
+ }
+
+
+ public void setQueueId(String queueId) {
+ this.queueId = queueId;
+ clearInitialState();
+ }
+
+
public boolean isLimitRender() {
if(this.limitRender != null) {
return this.limitRender.booleanValue();
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2009-08-21 14:24:03 UTC (rev 15252)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2009-08-21 14:46:12 UTC (rev 15253)
@@ -42,6 +42,9 @@
private final TagAttribute immediate;
private final TagAttribute listener;
private final TagAttribute limitRender;
+ private final TagAttribute queueId;
+ private final TagAttribute statusId;
+ private final TagAttribute similarityGroupingId;
private final boolean wrapping;
@@ -56,6 +59,9 @@
this.immediate = this.getAttribute("immediate");
this.listener = this.getAttribute("listener");
this.limitRender = this.getAttribute("limitRender");
+ this.queueId = this.getAttribute("queueId");
+ this.statusId = this.getAttribute("statusId");
+ this.similarityGroupingId = this.getAttribute("similarityGroupingId");
this.wrapping = isWrapping();
}
@@ -158,7 +164,10 @@
setBehaviorAttribute(fContext, ajaxBehavior, this.execute, Object.class);
setBehaviorAttribute(fContext, ajaxBehavior, this.render, Object.class);
setBehaviorAttribute(fContext, ajaxBehavior, this.limitRender, Boolean.class);
-
+ setBehaviorAttribute(fContext, ajaxBehavior, this.queueId, String.class);
+ setBehaviorAttribute(fContext, ajaxBehavior, this.statusId, String.class);
+ setBehaviorAttribute(fContext, ajaxBehavior, this.similarityGroupingId, String.class);
+
registerBehaviorListener(fContext, ajaxBehavior, listener);
return ajaxBehavior;
15 years, 4 months
JBoss Rich Faces SVN: r15252 - in root/ui/trunk/components/core/src/main/java/org/ajax4jsf: facelets/tag and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-08-21 10:24:03 -0400 (Fri, 21 Aug 2009)
New Revision: 15252
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java
Log:
fix limitRender
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-08-21 14:22:29 UTC (rev 15251)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-08-21 14:24:03 UTC (rev 15252)
@@ -5,22 +5,24 @@
import javax.faces.component.behavior.FacesBehavior;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.component.AjaxClientBehavior;
+
/**
* @author Anton Belevich
*
*/
@FacesBehavior(value="org.ajax4jsf.behavior.Ajax")
-public class AjaxBehavior extends javax.faces.component.behavior.AjaxBehavior {
+public class AjaxBehavior extends javax.faces.component.behavior.AjaxBehavior implements AjaxClientBehavior{
public static final String BEHAVIOR_ID = "org.ajax4jsf.behavior.Ajax";
public static final String LIMIT_RENDER = "limitRender";
- private boolean limitRender;
+ private Boolean limitRender;
public boolean isLimitRender() {
- if(this.limitRender) {
- return this.limitRender;
+ if(this.limitRender != null) {
+ return this.limitRender.booleanValue();
}
ValueExpression ex = getValueExpression(LIMIT_RENDER);
@@ -30,7 +32,7 @@
return value != null ? value.booleanValue() : false;
}
- return this.limitRender;
+ return false;
}
@@ -56,7 +58,7 @@
values = new Object[] { superState };
}
} else {
- values = new Object[1];
+ values = new Object[2];
values[0] = superState;
values[1] = limitRender;
}
@@ -65,6 +67,26 @@
}
@Override
+ public void setValueExpression(String name, ValueExpression expression) {
+ if(expression != null && expression.isLiteralText()) {
+ if(LIMIT_RENDER.equals(name)) {
+ Object value = getExpressionLiteralValue(expression);
+ this.limitRender = value != null ? (Boolean)value : Boolean.FALSE ;
+ }
+ }
+ super.setValueExpression(name, expression);
+ }
+
+ protected Object getExpressionLiteralValue(ValueExpression expression) {
+ Object value = null;
+ if(expression != null) {
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+ value = expression.getValue(elContext);
+ }
+ return value;
+ }
+
+ @Override
public void restoreState(FacesContext context, Object state) {
if (state != null) {
@@ -77,4 +99,4 @@
}
}
}
-}
+}
\ No newline at end of file
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2009-08-21 14:22:29 UTC (rev 15251)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2009-08-21 14:24:03 UTC (rev 15252)
@@ -1,7 +1,10 @@
package org.ajax4jsf.facelets.tag;
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
import java.io.IOException;
import java.util.Collection;
+import java.util.List;
import javax.el.ELContext;
import javax.el.MethodExpression;
@@ -12,8 +15,11 @@
import javax.faces.event.AbortProcessingException;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.event.AjaxBehaviorListener;
+import javax.faces.view.AttachedObjectTarget;
import javax.faces.view.BehaviorHolderAttachedObjectHandler;
+import javax.faces.view.BehaviorHolderAttachedObjectTarget;
import javax.faces.view.facelets.BehaviorConfig;
+import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.CompositeFaceletHandler;
import javax.faces.view.facelets.FaceletContext;
import javax.faces.view.facelets.TagAttribute;
@@ -22,11 +28,9 @@
import org.ajax4jsf.component.behavior.AjaxBehavior;
-/**
- * @author Anton Belevich
- *
- */
+import com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler;
+
public class AjaxHandler extends TagHandler implements BehaviorHolderAttachedObjectHandler {
private final TagAttribute event;
@@ -38,6 +42,8 @@
private final TagAttribute immediate;
private final TagAttribute listener;
private final TagAttribute limitRender;
+ private final boolean wrapping;
+
public AjaxHandler(BehaviorConfig config) {
super(config);
@@ -50,23 +56,85 @@
this.immediate = this.getAttribute("immediate");
this.listener = this.getAttribute("listener");
this.limitRender = this.getAttribute("limitRender");
+ this.wrapping = isWrapping();
}
public void apply(FaceletContext fContext, UIComponent parent) throws IOException {
String eventName = getEventName();
- if(!isWrapping()) {
- applyAttachedObject(fContext, parent, eventName);
+ if(this.wrapping) {
+ nextHandler.apply(fContext, parent);
} else {
- this.nextHandler.apply(fContext, parent);
+ applyNested(fContext, parent, eventName);
}
}
+ private void applyNested(FaceletContext ctx, UIComponent parent, String eventName) {
+
+ if (!ComponentHandler.isNew(parent)) {
+ return;
+ }
+
+ if (UIComponent.isCompositeComponent(parent)) {
+
+ BeanInfo componentBeanInfo = (BeanInfo) parent.getAttributes().get(UIComponent.BEANINFO_KEY);
+ if (null == componentBeanInfo) {
+ throw new TagException(tag, "Error: enclosing composite component does not have BeanInfo attribute");
+ }
+ BeanDescriptor componentDescriptor = componentBeanInfo.getBeanDescriptor();
+ if (null == componentDescriptor) {
+ throw new TagException(tag, "Error: enclosing composite component BeanInfo does not have BeanDescriptor");
+ }
+
+ List<AttachedObjectTarget> targetList = (List<AttachedObjectTarget>) componentDescriptor.getValue(AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY);
+
+ if (null == targetList) {
+ throw new TagException(tag, "Error: enclosing composite component does not support behavior events");
+ }
+
+ boolean supportedEvent = false;
+ for (AttachedObjectTarget target : targetList) {
+ if (target instanceof BehaviorHolderAttachedObjectTarget) {
+ BehaviorHolderAttachedObjectTarget behaviorTarget = (BehaviorHolderAttachedObjectTarget) target;
+ if ((null != eventName && eventName.equals(behaviorTarget.getName()))
+ || (null == eventName && behaviorTarget.isDefaultEvent())) {
+ supportedEvent = true;
+ break;
+ }
+ }
+ }
+
+ if (supportedEvent) {
+ CompositeComponentTagHandler.getAttachedObjectHandlers(parent).add(this);
+ } else {
+ throw new TagException(tag, "Error: enclosing composite component does not support event " + eventName);
+ }
+
+ } else if (parent instanceof ClientBehaviorHolder) {
+ applyAttachedObject(ctx, parent, eventName);
+ } else {
+ throw new TagException(this.tag,"Unable to attach <f:ajax> to non-ClientBehaviorHolder parent");
+ }
+ }
+
+
+// private void applyWrapping(FaceletContext ctx, UIComponent parent, String eventName) throws IOException {
+// AjaxBehavior ajaxBehavior = createAjaxBehavior(ctx, eventName);
+//
+// FacesContext context = ctx.getFacesContext();
+// AjaxBehaviors ajaxBehaviors = AjaxBehaviors.getAjaxBehaviors(context, true);
+// ajaxBehaviors.pushBehavior(context, ajaxBehavior, eventName);
+//
+// nextHandler.apply(ctx, parent);
+//
+// ajaxBehaviors.popBehavior();
+// }
+
public void applyAttachedObject(FaceletContext fContext, UIComponent parent, String eventName) {
ClientBehaviorHolder bHolder = (ClientBehaviorHolder) parent;
if (null == eventName) {
eventName = bHolder.getDefaultEventName();
if (null == eventName) {
- throw new TagException(this.tag, "Event attribute could not be determined: " + eventName);
+ throw new TagException(this.tag, "Event attribute could not be determined: " + eventName);
}
} else {
Collection<String> eventNames = bHolder.getEventNames();
@@ -74,12 +142,12 @@
throw new TagException(this.tag, eventName + "event is not supported for the " + parent.getClass().getSimpleName());
}
}
- AjaxBehavior ajaxBehavior = createBehavior(fContext, parent, eventName);
+ AjaxBehavior ajaxBehavior = createAjaxBehavior(fContext, eventName);
bHolder.addClientBehavior(eventName, ajaxBehavior);
}
- public AjaxBehavior createBehavior(FaceletContext fContext, UIComponent parent, String eventName) {
+ public AjaxBehavior createAjaxBehavior(FaceletContext fContext, String eventName) {
Application application = fContext.getFacesContext().getApplication();
AjaxBehavior ajaxBehavior = (AjaxBehavior)application.createBehavior(AjaxBehavior.BEHAVIOR_ID);
15 years, 4 months
JBoss Rich Faces SVN: r15251 - in root/framework/trunk: impl/src/main/java/org/richfaces/context and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-08-21 10:22:29 -0400 (Fri, 21 Aug 2009)
New Revision: 15251
Added:
root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
Log:
add interface for behavior
Added: root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java (rev 0)
+++ root/framework/trunk/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java 2009-08-21 14:22:29 UTC (rev 15251)
@@ -0,0 +1,29 @@
+ package org.ajax4jsf.component;
+
+import java.util.Collection;
+
+import javax.faces.component.behavior.ClientBehavior;
+
+/**
+ * @author Anton Belevich
+ * interface for our ajax behaviors
+ *
+ */
+public interface AjaxClientBehavior extends ClientBehavior {
+
+ public boolean isLimitRender();
+
+ public void setLimitRender(boolean limitRender);
+
+ public void setExecute(Collection<String> execute);
+
+ public Collection<String> getExecute();
+
+ public void setRender(Collection<String> render);
+
+ public Collection<String> getRender();
+
+ public boolean isDisabled();
+
+ public void setDisabled(boolean disabled);
+}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-08-21 13:50:00 UTC (rev 15250)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-08-21 14:22:29 UTC (rev 15251)
@@ -29,7 +29,6 @@
import java.util.Map;
import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.AjaxBehavior;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.component.visit.VisitCallback;
@@ -41,6 +40,7 @@
import javax.faces.context.PartialViewContextWrapper;
import javax.faces.event.PhaseId;
+import org.ajax4jsf.component.AjaxClientBehavior;
import org.ajax4jsf.component.AjaxOutput;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils;
@@ -104,19 +104,19 @@
}
- private AjaxBehavior findBehavior(UIComponent target) {
- AjaxBehavior result = null;
+ private AjaxClientBehavior findBehavior(UIComponent target) {
+ AjaxClientBehavior result = null;
if (behaviorEvent != null) {
if (target instanceof ClientBehaviorHolder) {
ClientBehaviorHolder behaviorHolder = (ClientBehaviorHolder) target;
List<ClientBehavior> behaviors = behaviorHolder.getClientBehaviors().get(behaviorEvent);
if (behaviors != null) {
for (ClientBehavior behavior : behaviors) {
- if (behavior instanceof AjaxBehavior) {
- AjaxBehavior ajaxBehavior = (AjaxBehavior) behavior;
+ if (behavior instanceof AjaxClientBehavior) {
+ AjaxClientBehavior ajaxBehavior = (AjaxClientBehavior) behavior;
if (!ajaxBehavior.isDisabled()) {
//TODO need more reliable algorithm
- result = (AjaxBehavior) behavior;
+ result = (AjaxClientBehavior) behavior;
break;
}
}
@@ -132,11 +132,11 @@
return result;
}
- protected abstract Object getBehaviorAttributeValue(AjaxBehavior behavior);
+ protected abstract Object getBehaviorAttributeValue(AjaxClientBehavior behavior);
protected abstract Object getAttributeValue(UIComponent component);
- protected void doVisit(FacesContext context, UIComponent target, AjaxBehavior behavior) {
+ protected void doVisit(FacesContext context, UIComponent target, AjaxClientBehavior behavior) {
Object attributeObject = null;
if (behavior != null) {
attributeObject = getBehaviorAttributeValue(behavior);
@@ -173,7 +173,7 @@
}
public final VisitResult visit(VisitContext visitContext, UIComponent target) {
- AjaxBehavior ajaxBehavior = null;
+ AjaxClientBehavior ajaxBehavior = null;
if (behaviorEvent != null) {
ajaxBehavior = findBehavior(target);
}
@@ -214,7 +214,7 @@
}
@Override
- protected Object getBehaviorAttributeValue(AjaxBehavior behavior) {
+ protected Object getBehaviorAttributeValue(AjaxClientBehavior behavior) {
return behavior.getExecute();
}
}
@@ -233,9 +233,13 @@
@Override
protected void doVisit(FacesContext context, UIComponent target,
- AjaxBehavior behavior) {
+ AjaxClientBehavior behavior) {
+
super.doVisit(context, target, behavior);
limitToList = AjaxRendererUtils.isAjaxLimitToList(target);
+ if(behavior != null) {
+ limitToList = behavior.isLimitRender();
+ }
}
@Override
@@ -244,7 +248,7 @@
}
@Override
- protected Object getBehaviorAttributeValue(AjaxBehavior behavior) {
+ protected Object getBehaviorAttributeValue(AjaxClientBehavior behavior) {
return behavior.getRender();
}
}
15 years, 4 months
JBoss Rich Faces SVN: r15250 - branches/community/3.3.X/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/util/parser.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2009-08-21 09:50:00 -0400 (Fri, 21 Aug 2009)
New Revision: 15250
Modified:
branches/community/3.3.X/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/util/parser/TLDParser.java
Log:
Modified: branches/community/3.3.X/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/util/parser/TLDParser.java 2009-08-21 12:50:18 UTC (rev 15249)
+++ branches/community/3.3.X/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/util/parser/TLDParser.java 2009-08-21 13:50:00 UTC (rev 15250)
@@ -4,9 +4,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
public class TLDParser {
@@ -21,13 +18,10 @@
}
public AttributesList getAllAttributes() {
-
- tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
- InputStream input = null;
+ allAttributes.clear();
try {
- input = richfacesUI.getInputStream(tld);
-
- InputStreamReader isr = new InputStreamReader(input);
+
+ Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());
BufferedReader reader = new BufferedReader(isr);
String line, attr;
Attribute attribute = new Attribute();
@@ -95,12 +89,6 @@
return allAttributes;
}
- public String getExtPath() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String resource = "META-INF/richfaces.tld";
- return loader.getResource(resource).toString();
- }
-
public String getComponent() {
return component;
}
@@ -108,23 +96,4 @@
public void setComponent(String component) {
this.component = component;
}
-
- public JarFile getRichfacesUI() {
- String temp = null;
- int position;
- try {
- if ((position = getExtPath().indexOf('!')) != -1) {
- if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
- temp = getExtPath().substring("jar:file:\\".length(), position);
- } else {
- temp = "/" + getExtPath().substring("jar:file:/".length(), position);
- }
-
- }
- richfacesUI = new JarFile(temp);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return richfacesUI;
- }
}
15 years, 4 months
JBoss Rich Faces SVN: r15249 - in branches/community/3.3.X/test-applications: jsp/src/main/java/util/parser and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2009-08-21 08:50:18 -0400 (Fri, 21 Aug 2009)
New Revision: 15249
Modified:
branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java
branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java
branches/community/3.3.X/test-applications/test-jsp/src/main/java/util/parser/TLDParser.java
Log:
Modified: branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java 2009-08-21 12:06:49 UTC (rev 15248)
+++ branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java 2009-08-21 12:50:18 UTC (rev 15249)
@@ -16,6 +16,7 @@
}
public AttributesList getAllAttributes() {
+ allAttributes.clear();
try {
Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());
Modified: branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java 2009-08-21 12:06:49 UTC (rev 15248)
+++ branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java 2009-08-21 12:50:18 UTC (rev 15249)
@@ -16,7 +16,7 @@
}
public AttributesList getAllAttributes() {
-
+ allAttributes.clear();
try {
Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());
@@ -116,4 +116,4 @@
this.component = component;
}
-}
+}
\ No newline at end of file
Modified: branches/community/3.3.X/test-applications/test-jsp/src/main/java/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/test-jsp/src/main/java/util/parser/TLDParser.java 2009-08-21 12:06:49 UTC (rev 15248)
+++ branches/community/3.3.X/test-applications/test-jsp/src/main/java/util/parser/TLDParser.java 2009-08-21 12:50:18 UTC (rev 15249)
@@ -21,56 +21,27 @@
package util.parser;
+
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
+import java.io.Reader;
-/**
- * The Class TLDParser parses richfaces.tld file to provide AttributeList object
- * for selected component.
- */
public class TLDParser {
- /** The component's name. */
- protected String component;
+ protected String component;
+ protected AttributesList allAttributes;
- /** The tld object represents a richfaces.tld file. */
- protected JarEntry tld;
-
- /** The richfacesUI object represents a richfaces-ui.jar file. */
- protected JarFile richfacesUI;
-
- /** The all attributes. */
- protected AttributesList allAttributes;
-
- /**
- * Instantiates a new tLD parser.
- *
- * @param str
- * the component's name
- */
public TLDParser(String str) {
this.component = str;
allAttributes = new AttributesList();
}
- /**
- * Gets the all attributes from richfaces.tld file for selected component.
- *
- * @return the all attributes
- */
public AttributesList getAllAttributes() {
allAttributes.clear();
- tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
- InputStream input = null;
try {
- input = richfacesUI.getInputStream(tld);
-
- InputStreamReader isr = new InputStreamReader(input);
+
+ Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());
BufferedReader reader = new BufferedReader(isr);
String line, attr;
Attribute attribute = new Attribute();
@@ -92,56 +63,36 @@
position + 6, end).trim());
}
// find attribute description
- if ((position = line
- .indexOf("<description>")) != -1) {
-
- if ((end = line
- .indexOf("</description>")) != -1) {
- attribute
- .setDescription(line
- .substring(
- position + 13,
- line
- .length() - 14));
- } else {
- sb.append(line.substring(
- position + 13,
- line.length()).trim()
- .replaceAll("\t", ""));
+ if ((position = line.indexOf("<description>")) != -1) {
+
+ if((end = line.indexOf("</description>")) != -1){
+ attribute.setDescription(line.substring(position + 13, line.length()-14));
+ }else{
+ sb.append(line.substring(position + 13, line.length()).trim().replaceAll("\t", ""));
line = reader.readLine();
- while ((end = line
- .indexOf("</description>")) == -1) {
- sb.append(line.substring(0,
- line.length())
- .replaceAll("\t", ""));
+ while ((end = line.indexOf("</description>")) == -1) {
+ sb.append(line.substring(0, line.length()).replaceAll("\t", ""));
line = reader.readLine();
}
- sb.append(line.substring(0,
- line.length() - 14).trim()
- .replaceAll("\t", ""));
-
- attribute.setDescription(sb
- .toString());
+ sb.append(line.substring(0, line.length() - 14).trim().replaceAll("\t", ""));
+
+ attribute.setDescription(sb.toString());
sb.delete(0, sb.length());
- }
- }
+ }
+ }
// find attribute type
if ((position = line.indexOf("<type>")) != -1) {
end = line.indexOf("</type>");
- attribute.setType(line.substring(
- position + 6, end).trim());
+ attribute.setType(line.substring(position + 6, end).trim());
}
// find attribute method-signature
- if ((position = line
- .indexOf("<method-signature>")) != -1) {
- end = line
- .indexOf("</method-signature>");
- attribute.setType(line.substring(
- position + 18, end).trim());
+ if ((position = line.indexOf("<method-signature>")) != -1) {
+ end = line.indexOf("</method-signature>");
+ attribute.setType(line.substring(position + 18, end).trim());
}
} while (!((line = reader.readLine())
.contains("</attribute>")));
- // define initial attribute status
+ // define attribute status
attribute.setStatus(Status.NOT_TESTED);
allAttributes.add(attribute);
attribute = new Attribute();
@@ -157,90 +108,12 @@
}
return allAttributes;
}
-
- /**
- * Gets the richfaces.tld resource.
- *
- * @return the richfaces.tld resource
- */
- public String getExtPath() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String resource = "META-INF/richfaces.tld";
- return loader.getResource(resource).toString();
- }
-
- /**
- * Gets the component's name.
- *
- * @return the component's name
- */
+
public String getComponent() {
return component;
}
- /**
- * Sets the component's name.
- *
- * @param component
- * the new component's name
- */
public void setComponent(String component) {
this.component = component;
- }
-
- /**
- * Gets the richfacesUI object representing a richfaces-ui.jar file.
- *
- * @return the richfaces ui
- */
- public JarFile getRichfacesUI() {
- String temp = null;
- int position;
- try {
- if ((position = getExtPath().indexOf('!')) != -1) {
- if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
- temp = getExtPath().substring("jar:file:\\".length(), position);
- } else {
- temp = "/" + getExtPath().substring("jar:file:/".length(), position);
- }
- }
- richfacesUI = new JarFile(temp);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return richfacesUI;
- }
-
- /**
- * Gets the all possible handlers from richfaces.tld file.
- *
- * @return the all possible handlers
- */
- public ArrayList<String> getAllHandlers() {
- tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
- InputStream input = null;
- ArrayList<String> handlers = new ArrayList<String>();
-
- try {
- input = richfacesUI.getInputStream(tld);
- InputStreamReader isr = new InputStreamReader(input);
- BufferedReader reader = new BufferedReader(isr);
- String line, temp;
- int start, end;
- while ((line = reader.readLine()) != null) {
- if ((start = line.indexOf("<name>")) != -1) {
- end = line.indexOf("</name>");
- temp = line.substring(start + 6, end).trim();
- if (temp.startsWith("on") && !handlers.contains(temp)) {
- handlers.add(temp);
- }
- }
- }
- return handlers;
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-}
+ }
+}
\ No newline at end of file
15 years, 4 months
JBoss Rich Faces SVN: r15248 - branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2009-08-21 08:06:49 -0400 (Fri, 21 Aug 2009)
New Revision: 15248
Modified:
branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java
Log:
platform independent retrieving richfaces.tld
Modified: branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java 2009-08-21 12:02:18 UTC (rev 15247)
+++ branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java 2009-08-21 12:06:49 UTC (rev 15248)
@@ -2,16 +2,12 @@
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
+import java.io.Reader;
public class TLDParser {
- protected String component;
- protected JarEntry tld;
- protected JarFile richfacesUI;
+ protected String component;
protected AttributesList allAttributes;
public TLDParser(String str) {
@@ -21,12 +17,9 @@
public AttributesList getAllAttributes() {
- tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
- InputStream input = null;
try {
- input = richfacesUI.getInputStream(tld);
- InputStreamReader isr = new InputStreamReader(input);
+ Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());
BufferedReader reader = new BufferedReader(isr);
String line, attr;
Attribute attribute = new Attribute();
@@ -113,13 +106,8 @@
}
return allAttributes;
}
+
- public String getExtPath() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String resource = "META-INF/richfaces.tld";
- return loader.getResource(resource).toString();
- }
-
public String getComponent() {
return component;
}
@@ -127,23 +115,5 @@
public void setComponent(String component) {
this.component = component;
}
-
- public JarFile getRichfacesUI() {
- String temp = null;
- int position;
- try {
- if ((position = getExtPath().indexOf('!')) != -1) {
- if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
- temp = getExtPath().substring("jar:file:\\".length(), position);
- } else {
- temp = "/" + getExtPath().substring("jar:file:/".length(), position);
- }
-
- }
- richfacesUI = new JarFile(temp);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return richfacesUI;
- }
+
}
15 years, 4 months
JBoss Rich Faces SVN: r15247 - branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2009-08-21 08:02:18 -0400 (Fri, 21 Aug 2009)
New Revision: 15247
Modified:
branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java
Log:
correction: platform independent richfaces.tld retrieving.
Modified: branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java 2009-08-21 11:38:06 UTC (rev 15246)
+++ branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java 2009-08-21 12:02:18 UTC (rev 15247)
@@ -2,18 +2,12 @@
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
-import java.util.ArrayList;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
public class TLDParser {
- protected String component;
- protected JarEntry tld;
- protected JarFile richfacesUI;
+ protected String component;
protected AttributesList allAttributes;
public TLDParser(String str) {
@@ -22,13 +16,8 @@
}
public AttributesList getAllAttributes() {
-
-// tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
-// InputStream input = null;
try {
-// input = richfacesUI.getInputStream(tld);
-
- //InputStreamReader isr = new InputStreamReader(input);
+
Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());
BufferedReader reader = new BufferedReader(isr);
String line, attr;
@@ -96,46 +85,12 @@
}
return allAttributes;
}
-
- public String getExtPath() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String resource = "META-INF/richfaces.tld";
- String temp = loader.getResource(resource).toString();
- //in case you put project war on server
- if(temp.startsWith("vfszip")){
- temp = temp.substring("vfszip:/".length(),temp.length()-"/META-INF/richfaces.tld".length());
- System.out.println("TEMP:"+temp);
- }else {
- //in case you run project from eclipse IDE
- temp = temp.substring("jar:file:/".length(),temp.length()-"!/META-INF/richfaces.tld".length());
- System.out.println("TEMP:"+temp);
- }
- return temp;
- }
-
+
public String getComponent() {
return component;
}
public void setComponent(String component) {
this.component = component;
- }
-
- public JarFile getRichfacesUI() {
- try {
- /*if ((position = getExtPath().indexOf('!')) != -1) {
- if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
- temp = getExtPath().substring("jar:file:\\".length(), position);
- System.out.println("windows path 2:" + temp);
- } else {
- temp = "/" + getExtPath().substring("jar:file:/".length(), position);
- System.out.println("linux path:" + temp);
- }
- }*/
- richfacesUI = new JarFile("/WEB-INF/lib/richfaces-ui-3.3.2-20090820.123703-70.jar");
- } catch (IOException e) {
- e.printStackTrace();
- }
- return richfacesUI;
- }
+ }
}
15 years, 4 months
JBoss Rich Faces SVN: r15246 - branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2009-08-21 07:38:06 -0400 (Fri, 21 Aug 2009)
New Revision: 15246
Modified:
branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java
Log:
Modified: branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java 2009-08-21 11:22:33 UTC (rev 15245)
+++ branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java 2009-08-21 11:38:06 UTC (rev 15246)
@@ -4,6 +4,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.Reader;
import java.util.ArrayList;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -22,12 +23,13 @@
public AttributesList getAllAttributes() {
- tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
- InputStream input = null;
+// tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
+// InputStream input = null;
try {
- input = richfacesUI.getInputStream(tld);
+// input = richfacesUI.getInputStream(tld);
- InputStreamReader isr = new InputStreamReader(input);
+ //InputStreamReader isr = new InputStreamReader(input);
+ Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());
BufferedReader reader = new BufferedReader(isr);
String line, attr;
Attribute attribute = new Attribute();
@@ -97,8 +99,18 @@
public String getExtPath() {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String resource = "META-INF/richfaces.tld";
- return loader.getResource(resource).toString();
+ String resource = "META-INF/richfaces.tld";
+ String temp = loader.getResource(resource).toString();
+ //in case you put project war on server
+ if(temp.startsWith("vfszip")){
+ temp = temp.substring("vfszip:/".length(),temp.length()-"/META-INF/richfaces.tld".length());
+ System.out.println("TEMP:"+temp);
+ }else {
+ //in case you run project from eclipse IDE
+ temp = temp.substring("jar:file:/".length(),temp.length()-"!/META-INF/richfaces.tld".length());
+ System.out.println("TEMP:"+temp);
+ }
+ return temp;
}
public String getComponent() {
@@ -109,19 +121,18 @@
this.component = component;
}
- public JarFile getRichfacesUI() {
- String temp = null;
- int position;
+ public JarFile getRichfacesUI() {
try {
- if ((position = getExtPath().indexOf('!')) != -1) {
- if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
+ /*if ((position = getExtPath().indexOf('!')) != -1) {
+ if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
temp = getExtPath().substring("jar:file:\\".length(), position);
+ System.out.println("windows path 2:" + temp);
} else {
temp = "/" + getExtPath().substring("jar:file:/".length(), position);
+ System.out.println("linux path:" + temp);
}
-
- }
- richfacesUI = new JarFile(temp);
+ }*/
+ richfacesUI = new JarFile("/WEB-INF/lib/richfaces-ui-3.3.2-20090820.123703-70.jar");
} catch (IOException e) {
e.printStackTrace();
}
15 years, 4 months