Merging of SWF-367 back into trunk. This has all of the SWF 2.0 goodies.

This commit is contained in:
Ben Hale
2007-10-11 01:16:37 +00:00
parent b9513cd42b
commit 58d1ea3acc
984 changed files with 11849 additions and 39596 deletions

View File

@@ -1,58 +0,0 @@
package org.springframework.faces.el;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.ExpressionFactory;
import javax.el.FunctionMapper;
import javax.el.VariableMapper;
import javax.faces.context.FacesContext;
import org.springframework.binding.expression.el.DefaultELContextFactory;
import org.springframework.binding.expression.el.ELExpressionParser;
/**
* A JSF-aware ExpressionParser that allows JSF 1.1 managed beans to be referenced in expressions in the FlowDefinition.
* @author Jeremy Grelle
*/
public class Jsf11ELExpressionParser extends ELExpressionParser {
/**
* Creates a new JSF 1.1 compatible expression parser
* @param expressionFactory the unified EL expression factory implementation
*/
public Jsf11ELExpressionParser(ExpressionFactory expressionFactory) {
super(expressionFactory, new Jsf11ELContextFactory());
}
/**
* Inner helper class that plus in the EL Resolver that resolves expressions using JSF 1.1 APIs.
*/
private static class Jsf11ELContextFactory extends DefaultELContextFactory {
public ELContext getEvaluationContext(Object target) {
return new Jsf11ELContext(FacesContext.getCurrentInstance());
}
private static class Jsf11ELContext extends ELContext {
private ELResolver baseResolver;
public Jsf11ELContext(FacesContext context) {
baseResolver = new Jsf11ELResolverAdapter(context);
}
public ELResolver getELResolver() {
return baseResolver;
}
public FunctionMapper getFunctionMapper() {
return null;
}
public VariableMapper getVariableMapper() {
return null;
}
}
}
}

View File

@@ -1,135 +0,0 @@
package org.springframework.faces.el;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.PropertyNotWritableException;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.PropertyNotFoundException;
import javax.faces.el.PropertyResolver;
import javax.faces.el.VariableResolver;
/**
* An adapter for using JSF 1.1 {@link VariableResolver}s and {@link PropertyResolver}s in an {@link ELContext}.
* @author Jeremy Grelle0
*/
public class Jsf11ELResolverAdapter extends ELResolver {
private FacesContext facesContext;
/**
* Creates a new adapter that adapts JSF 1.1 EL constructs to the Unified EL Resolver construct.
* @param facesContext the current faces context
*/
public Jsf11ELResolverAdapter(FacesContext facesContext) {
this.facesContext = facesContext;
}
public Class getCommonPropertyType(ELContext context, Object base) {
return Object.class;
}
public Iterator getFeatureDescriptors(ELContext context, Object base) {
return Collections.EMPTY_LIST.iterator();
}
public Class getType(ELContext context, Object base, Object property) {
if (property == null) {
return null;
}
try {
context.setPropertyResolved(true);
if (base == null) {
Object var = getVariableResolver().resolveVariable(facesContext, property.toString());
return (var != null) ? var.getClass() : null;
} else {
if (base instanceof List || base.getClass().isArray()) {
return getPropertyResolver().getType(base, Integer.parseInt(property.toString()));
} else {
return getPropertyResolver().getType(base, property);
}
}
} catch (PropertyNotFoundException ex) {
throw new javax.el.PropertyNotFoundException(ex.getMessage(), ex.getCause());
} catch (EvaluationException ex) {
throw new ELException(ex.getMessage(), ex.getCause());
}
}
public Object getValue(ELContext context, Object base, Object property) {
if (property == null) {
return null;
}
try {
context.setPropertyResolved(true);
if (base == null) {
return getVariableResolver().resolveVariable(facesContext, property.toString());
} else {
if (base instanceof List || base.getClass().isArray()) {
return getPropertyResolver().getValue(base, Integer.parseInt(property.toString()));
} else {
return getPropertyResolver().getValue(base, property);
}
}
} catch (PropertyNotFoundException ex) {
throw new javax.el.PropertyNotFoundException(ex.getMessage(), ex.getCause());
} catch (EvaluationException ex) {
throw new ELException(ex.getMessage(), ex.getCause());
}
}
public boolean isReadOnly(ELContext context, Object base, Object property) {
if (property == null) {
return true;
}
try {
context.setPropertyResolved(true);
if (base == null) {
return false; // VariableResolver provides no way to determine isReadOnly
} else {
if (base instanceof List || base.getClass().isArray()) {
return getPropertyResolver().isReadOnly(base, Integer.parseInt(property.toString()));
} else {
return getPropertyResolver().isReadOnly(base, property);
}
}
} catch (PropertyNotFoundException ex) {
throw new javax.el.PropertyNotFoundException(ex.getMessage(), ex.getCause());
} catch (EvaluationException ex) {
throw new ELException(ex.getMessage(), ex.getCause());
}
}
public void setValue(ELContext context, Object base, Object property, Object value) {
if (property == null) {
throw new PropertyNotWritableException("Property is Null");
}
try {
context.setPropertyResolved(true);
if (base instanceof List || base.getClass().isArray()) {
getPropertyResolver().setValue(base, Integer.parseInt(property.toString()), value);
} else {
getPropertyResolver().setValue(base, property, value);
}
} catch (PropertyNotFoundException ex) {
throw new javax.el.PropertyNotFoundException(ex.getMessage(), ex.getCause());
} catch (EvaluationException ex) {
throw new ELException(ex.getMessage(), ex.getCause());
}
}
private VariableResolver getVariableResolver() {
return facesContext.getApplication().getVariableResolver();
}
private PropertyResolver getPropertyResolver() {
return facesContext.getApplication().getPropertyResolver();
}
}

View File

@@ -1,34 +0,0 @@
package org.springframework.faces.el;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.faces.context.FacesContext;
import org.springframework.binding.expression.el.DefaultELContextFactory;
import org.springframework.binding.expression.el.ELExpressionParser;
/**
* A JSF-aware ExpressionParser that allows JSF 1.2 managed beans to be referenced in expressions in the FlowDefinition.
* @author Jeremy Grelle
*/
public class Jsf12ELExpressionParser extends ELExpressionParser {
/**
* Creates a JSF 1.2 expression parser
* @param expressionFactory the unified EL expression factory implementation to use
*/
public Jsf12ELExpressionParser(ExpressionFactory expressionFactory) {
super(expressionFactory, new Jsf12ELContextFactory());
}
/**
* Simple little helper that grabs the current EL context from the faces context to support EL expression
* evaluation.
*/
private static class Jsf12ELContextFactory extends DefaultELContextFactory {
public ELContext getEvaluationContext(Object target) {
return FacesContext.getCurrentInstance().getELContext();
}
}
}

View File

@@ -4,34 +4,32 @@ import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;
import org.apache.shale.remoting.Mechanism;
import org.apache.shale.remoting.XhtmlHelper;
import org.springframework.faces.ui.resource.FlowResourceHelper;
public class ExtJsRenderer extends Renderer {
private static final String EXT_CSS = "/org/springframework/faces/ui/ext/resources/css/ext-all.css";
private static final String EXT_CSS = "/ext/resources/css/ext-all.css";
private static final String EXT_SCRIPT = "/org/springframework/faces/ui/ext/ext.js";
private static final String EXT_SCRIPT = "/ext/ext.js";
private static final String SPRING_FACES_SCRIPT = "/org/springframework/faces/ui/SpringFaces.js";
private static final String SPRING_FACES_SCRIPT = "/spring-faces/SpringFaces.js";
private XhtmlHelper resourceHelper = new XhtmlHelper();
private FlowResourceHelper resourceHelper = new FlowResourceHelper();
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
ExtJsComponent extJsComponent = (ExtJsComponent) component;
ResponseWriter writer = context.getResponseWriter();
if (extJsComponent.getIncludeExtStyles().equals(Boolean.TRUE)) {
resourceHelper.renderStyleLink(context, EXT_CSS);
}
if (extJsComponent.getIncludeExtStyles().equals(Boolean.TRUE))
resourceHelper.linkStylesheet(context, extJsComponent, writer, Mechanism.CLASS_RESOURCE, EXT_CSS);
if (extJsComponent.getIncludeExtScript().equals(Boolean.TRUE)) {
resourceHelper.renderScriptLink(context, EXT_SCRIPT);
}
if (extJsComponent.getIncludeExtScript().equals(Boolean.TRUE))
resourceHelper.linkJavascript(context, extJsComponent, writer, Mechanism.CLASS_RESOURCE, EXT_SCRIPT);
resourceHelper.linkJavascript(context, extJsComponent, writer, Mechanism.CLASS_RESOURCE, SPRING_FACES_SCRIPT);
resourceHelper.renderScriptLink(context, SPRING_FACES_SCRIPT);
}
}

View File

@@ -16,11 +16,13 @@ public class ExtValidateAllRenderer extends ExtJsRenderer {
ResponseWriter writer = context.getResponseWriter();
if (component.getChildCount() == 0)
if (component.getChildCount() == 0) {
throw new FacesException("A Spring Faces advisor expects to have at least one child component.");
}
if (!(component.getChildren().get(0) instanceof UICommand))
if (!(component.getChildren().get(0) instanceof UICommand)) {
throw new FacesException("ValidateAll expects to have a child of type UICommand.");
}
UIComponent advisedChild = (UIComponent) component.getChildren().get(0);

View File

@@ -1,48 +0,0 @@
SpringFaces = {};
SpringFaces.advisors = [];
SpringFaces.ExtGenericFieldAdvisor = function(config){
Ext.apply(this, config);
};
SpringFaces.ExtGenericFieldAdvisor.prototype = {
targetElId : "",
msgElId : "",
decoratorType : "",
decorator : null,
decoratorAttrs : "",
apply : function(){
var target = document.getElementById(this.targetElId);
var msgEl = document.getElementById(this.msgElId);
this.decorator = eval("new "+ this.decoratorType + "(" + this.decoratorAttrs +");" );
this.decorator.msgTarget=msgEl;
this.decorator.applyTo(target);
}
};
SpringFaces.applyAdvisors = function(){
for (var x=0; x<SpringFaces.advisors.length; x++) {
SpringFaces.advisors[x].apply();
}
};
SpringFaces.validateAll = function(){
var valid = true;
for(x in SpringFaces.advisors) {
if (SpringFaces.advisors[x].decorator &&
!SpringFaces.advisors[x].decorator.validate()) {
valid = false;
}
}
return valid;
};
Ext.onReady(SpringFaces.applyAdvisors);

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 B

Some files were not shown because too many files have changed in this diff Show More