Author: alexsmirnov
Date: 2008-03-05 18:37:50 -0500 (Wed, 05 Mar 2008)
New Revision: 6579
Added:
trunk/framework/api/src/test/
trunk/framework/api/src/test/java/
trunk/framework/api/src/test/java/org/
trunk/framework/api/src/test/java/org/ajax4jsf/
trunk/framework/api/src/test/java/org/ajax4jsf/framework/
trunk/framework/api/src/test/java/org/ajax4jsf/framework/util/
trunk/framework/api/src/test/java/org/ajax4jsf/framework/util/javascript/
trunk/framework/impl/src/main/java/org/ajax4jsf/context/JsfOneTwoInvoker.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/JsfOneOneInvoker.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
Log:
Move ScriptUtil tests to api project.
Start to use invokeOnComponent for a region/ajaxSingle processing.
Copied: trunk/framework/api/src/test/java/org/ajax4jsf/framework/util/javascript (from rev
6573, trunk/framework/impl/src/test/java/org/ajax4jsf/framework/util/javascript)
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java 2008-03-05
23:13:02 UTC (rev 6578)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java 2008-03-05
23:37:50 UTC (rev 6579)
@@ -252,7 +252,7 @@
private InvokerCallback _decodeInvoker = new InvokerCallback() {
- public void invoke(FacesContext context, UIComponent component) {
+ public void invokeContextCallback(FacesContext context, UIComponent component) {
component.processDecodes(context);
}
@@ -283,7 +283,7 @@
private InvokerCallback _updatesInvoker = new InvokerCallback() {
- public void invoke(FacesContext context, UIComponent component) {
+ public void invokeContextCallback(FacesContext context, UIComponent component) {
component.processUpdates(context);
}
@@ -311,7 +311,7 @@
private InvokerCallback _validatorsInvoker = new InvokerCallback() {
- public void invoke(FacesContext context, UIComponent component) {
+ public void invokeContextCallback(FacesContext context, UIComponent component) {
component.processValidators(context);
}
@@ -365,7 +365,7 @@
// }
private InvokerCallback _ajaxInvoker = new InvokerCallback() {
- public void invoke(FacesContext context, UIComponent component) {
+ public void invokeContextCallback(FacesContext context, UIComponent component) {
try {
if (component instanceof AjaxContainer) {
AjaxContainer ajax = (AjaxContainer) component;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2008-03-05
23:13:02 UTC (rev 6578)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2008-03-05
23:37:50 UTC (rev 6579)
@@ -64,7 +64,6 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.ajax4jsf.util.ELUtils;
import org.ajax4jsf.webapp.BaseFilter;
import org.ajax4jsf.webapp.FilterServletResponseWrapper;
import org.apache.commons.logging.Log;
@@ -88,11 +87,6 @@
//as they have their own advanced styling
private static final Pattern USER_AGENTS = Pattern.compile(" AppleWebKit/|^Opera/|
Opera ");
- private static final String INIT_PARAMETER_PREFIX = "_init_parameter_";
-
- //Object to put into application map as a value of cached parameter if it is null
- private static final Object NULL = new Object();
-
private static final Log log = LogFactory.getLog(AjaxContext.class);
private static ComponentInvoker invoker;
@@ -126,7 +120,7 @@
static {
try {
// Attempt to create JSF1.2 specific invoker.
- invoker = new JsfOneOneInvoker();
+ invoker = new JsfOneTwoInvoker();
} catch (Exception e) {
invoker = new JsfOneOneInvoker();
}
@@ -188,7 +182,7 @@
private InvokerCallback _ajaxInvoker = new InvokerCallback() {
- public void invoke(FacesContext context, UIComponent component) {
+ public void invokeContextCallback(FacesContext context, UIComponent component) {
if (component instanceof AjaxContainer) {
AjaxContainer ajax = (AjaxContainer) component;
renderAjaxRegion(context, component, true);
@@ -212,7 +206,7 @@
final boolean useFilterWriter) {
InvokerCallback ajaxInvoker = new InvokerCallback() {
- public void invoke(FacesContext context, UIComponent component) {
+ public void invokeContextCallback(FacesContext context, UIComponent component) {
if (component instanceof AjaxContainer) {
renderAjaxRegion(context, component, useFilterWriter);
} else {
@@ -426,15 +420,15 @@
boolean useStdControlsSkinning = false;
- String stdControlsSkinning = getInitParameterValue(context,
InternetResourceBuilder.STD_CONTROLS_SKINNING_PARAM);
- if (stdControlsSkinning != null) {
+ String stdControlsSkinning =
externalContext.getInitParameter(InternetResourceBuilder.STD_CONTROLS_SKINNING_PARAM);
+ if (stdControlsSkinning != null && stdControlsSkinning.length() != 0) {
useStdControlsSkinning =
InternetResourceBuilder.ENABLE.equals(stdControlsSkinning);
}
boolean useStdControlsSkinningClasses = true;
- String stdControlsSkinningClasses = getInitParameterValue(context,
InternetResourceBuilder.STD_CONTROLS_SKINNING_CLASSES_PARAM);
- if (stdControlsSkinningClasses != null) {
+ String stdControlsSkinningClasses =
externalContext.getInitParameter(InternetResourceBuilder.STD_CONTROLS_SKINNING_CLASSES_PARAM);
+ if (stdControlsSkinningClasses != null && stdControlsSkinningClasses.length()
!= 0) {
useStdControlsSkinningClasses =
InternetResourceBuilder.ENABLE.equals(stdControlsSkinningClasses);
}
@@ -898,55 +892,4 @@
return true;
}
}
-
- private String evaluate(FacesContext context, Object parameterValue) {
- if (parameterValue == NULL || parameterValue == null) {
- return null;
- } else if (parameterValue instanceof ValueExpression) {
- ValueExpression expression = (ValueExpression) parameterValue;
-
- return (String) expression.getValue(context.getELContext());
- } else {
- return parameterValue.toString();
- }
- }
-
- private String getInitParameterValue(FacesContext context, String parameterName) {
-
- String key = INIT_PARAMETER_PREFIX + parameterName;
-
- ExternalContext externalContext = context.getExternalContext();
- Map<String, Object> applicationMap = externalContext.getApplicationMap();
- Object mutex = externalContext.getRequest();
- Object parameterValue = null;
-
- synchronized (mutex) {
- parameterValue = applicationMap.get(key);
-
- if (parameterValue == null) {
-
- String initParameter = externalContext.getInitParameter(parameterName);
- if (initParameter != null) {
-
- if (ELUtils.isValueReference(initParameter)) {
- Application application = context.getApplication();
- ExpressionFactory expressionFactory = application.getExpressionFactory();
-
- parameterValue = expressionFactory.createValueExpression(context.getELContext(),
- initParameter,
- String.class);
- } else {
- parameterValue = initParameter;
- }
-
- } else {
- parameterValue = NULL;
- }
-
- applicationMap.put(key, parameterValue);
- }
- }
-
- return evaluate(context, parameterValue);
- }
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java 2008-03-05
23:13:02 UTC (rev 6578)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java 2008-03-05
23:37:50 UTC (rev 6579)
@@ -21,6 +21,7 @@
package org.ajax4jsf.context;
+import javax.faces.component.ContextCallback;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -30,14 +31,14 @@
* @author shura
*
*/
-public interface InvokerCallback {
+public interface InvokerCallback extends ContextCallback {
/**
* Process method on given component.
* @param context
* @param component
*/
- public void invoke(FacesContext context, UIComponent component);
+ public void invokeContextCallback(FacesContext context, UIComponent component);
/**
* Default processing on UIVewRoot
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/JsfOneOneInvoker.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/context/JsfOneOneInvoker.java 2008-03-05
23:13:02 UTC (rev 6578)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/context/JsfOneOneInvoker.java 2008-03-05
23:37:50 UTC (rev 6579)
@@ -75,7 +75,7 @@
*/
public boolean invokeOnComponent(UIComponent root, FacesContext context, InvokerCallback
callback, String regionId) {
if(regionId.equals(root.getClientId(context))){
- callback.invoke(context, root);
+ callback.invokeContextCallback(context, root);
return true;
}
for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/context/JsfOneTwoInvoker.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/JsfOneTwoInvoker.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/context/JsfOneTwoInvoker.java 2008-03-05
23:37:50 UTC (rev 6579)
@@ -0,0 +1,74 @@
+/**
+ * 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.context;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.component.AjaxViewRoot;
+import org.ajax4jsf.context.AjaxContext;
+
+/**
+ * @author shura
+ *
+ */
+public class JsfOneTwoInvoker implements ComponentInvoker {
+
+
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
javax.faces.context.FacesContext, org.ajax4jsf.framework.ajax.InvokerCallback,
javax.faces.event.PhaseId)
+ */
+ public void invokeOnRegionOrRoot(AjaxViewRoot viewRoot, FacesContext context,
InvokerCallback callback) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ String submittedRegionClientId = ajaxContext.getSubmittedRegionClientId(context);
+ if(null == submittedRegionClientId ||
viewRoot.getClientId(context).equals(submittedRegionClientId)){
+ // This is a not AJAX request, or active region is root.
+ callback.invokeRoot(context);
+ } else {
+ if(!invokeOnComponent(viewRoot, context, callback, submittedRegionClientId)){
+ // Region not found - perform default actions.
+ // TODO - log errors.
+ callback.invokeRoot(context);
+ }
+ }
+
+ }
+
+ public void invokeOnRegion(FacesContext context, InvokerCallback callback, String
regionId) {
+ UIViewRoot viewRoot = context.getViewRoot();
+ invokeOnComponent(viewRoot,context,callback,regionId);
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxInvoker#invokeOnComponent(javax.faces.component.UIComponent,
javax.faces.context.FacesContext, org.ajax4jsf.framework.ajax.InvokerCallback,
java.lang.String)
+ */
+ public boolean invokeOnComponent(UIComponent root, FacesContext context, InvokerCallback
callback, String regionId) {
+ return root.invokeOnComponent(context, regionId, callback);
+ }
+
+}
Property changes on:
trunk/framework/impl/src/main/java/org/ajax4jsf/context/JsfOneTwoInvoker.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2008-03-05
23:13:02 UTC (rev 6578)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2008-03-05
23:37:50 UTC (rev 6579)
@@ -117,18 +117,24 @@
* @return
* @throws IOException
*/
- public synchronized PreparedTemplate getTemplate(InternetResource base, ResourceContext
context) throws IOException {
+ public synchronized PreparedTemplate getTemplate(InternetResource base,
+ ResourceContext context) throws IOException {
PreparedTemplate template;
- // if(base.isCacheable()){
- template = (PreparedTemplate) base.getProperty(COMPILED_TEMPLATE_PROPERTY);
- // }
- if(null == template){
- HtmlCompiler compiler = new HtmlCompiler();
- InputStream resourceAsStream = base.getResourceAsStream(context);
- template = compiler.compile(resourceAsStream, base.getKey());
- base.setProperty(COMPILED_TEMPLATE_PROPERTY, template);
- resourceAsStream.close();
- }
+ // if(base.isCacheable()){
+ template = (PreparedTemplate) base
+ .getProperty(COMPILED_TEMPLATE_PROPERTY);
+ // }
+ if (null == template) {
+ HtmlCompiler compiler = new HtmlCompiler();
+ InputStream resourceAsStream = base.getResourceAsStream(context);
+ if (null != resourceAsStream) {
+ template = compiler.compile(resourceAsStream, base.getKey());
+ base.setProperty(COMPILED_TEMPLATE_PROPERTY, template);
+ resourceAsStream.close();
+ } else {
+ throw new IOException("CSS Template "+base.getKey()+" not
found");
+ }
+ }
return template;
}
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java 2008-03-05
23:13:02 UTC (rev 6578)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java 2008-03-05
23:37:50 UTC (rev 6579)
@@ -71,7 +71,7 @@
private InvokerCallback _ajaxInvoker = new InvokerCallback() {
- public void invoke(FacesContext context, UIComponent component) {
+ public void invokeContextCallback(FacesContext context, UIComponent component) {
try {
if (component instanceof AjaxContainer) {
AjaxContainer ajax = (AjaxContainer) component;