You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mb...@apache.org on 2007/03/16 14:24:21 UTC
svn commit: r518967 [3/20] - in /myfaces/core/branches/jsf12:
api/src/main/java-templates/javax/faces/component/
api/src/main/java/javax/faces/application/
api/src/main/java/javax/faces/component/
api/src/main/java/javax/faces/context/ api/src/main/jav...
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToMethodExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToMethodExpression.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToMethodExpression.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToMethodExpression.java Fri Mar 16 06:24:10 2007
@@ -1,241 +1,241 @@
-/*
- * Copyright 2006 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 javax.faces.component;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.MethodExpression;
-import javax.el.MethodInfo;
-import javax.el.MethodNotFoundException;
-import javax.el.PropertyNotFoundException;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.MethodBinding;
-
-/**
- * Converts a MethodBinding to a MethodExpression
- *
- * TODO: find a way to share the implementation of class with impl.
- *
- * @author Stan Silvert
- */
-@SuppressWarnings("deprecation")
-class _MethodBindingToMethodExpression extends MethodExpression implements StateHolder
-{
- private static final Class[] EXPECTED_TYPES = new Class[] { MethodBinding.class, StateHolder.class };
-
- private MethodBinding methodBinding;
-
- private boolean _transientFlag;
-
- private transient MethodInfo methodInfo;
-
- /**
- * No-arg constructor used during restoreState
- */
- protected _MethodBindingToMethodExpression()
- {
- }
-
- /** Creates a new instance of MethodBindingToMethodExpression */
- public _MethodBindingToMethodExpression(MethodBinding methodBinding)
- {
- checkNullArgument(methodBinding, "methodBinding");
- this.methodBinding = methodBinding;
- }
-
- /**
- * Return the wrapped MethodBinding.
- */
- public MethodBinding getMethodBinding()
- {
- return methodBinding;
- }
-
- void setMethodBinding(MethodBinding methodBinding)
- {
- this.methodBinding = methodBinding;
- }
-
- /**
- * Note: MethodInfo.getParamTypes() may incorrectly return an empty class array if invoke() has not been called.
- *
- * @throws IllegalStateException
- * if expected params types have not been determined.
- */
- public MethodInfo getMethodInfo(ELContext context) throws PropertyNotFoundException, MethodNotFoundException,
- ELException
- {
- checkNullArgument(context, "elcontext");
- checkNullState(methodBinding, "methodBinding");
-
- if (methodInfo == null)
- {
- final FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
- if (facesContext != null)
- {
- methodInfo = invoke(new Invoker<MethodInfo>()
- {
- public MethodInfo invoke()
- {
- return new MethodInfo(null, methodBinding.getType(facesContext), null);
- }
- });
- }
- }
- return methodInfo;
- }
-
- public Object invoke(ELContext context, final Object[] params) throws PropertyNotFoundException,
- MethodNotFoundException, ELException
- {
- checkNullArgument(context, "elcontext");
- checkNullState(methodBinding, "methodBinding");
- final FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
- if (facesContext != null)
- {
- return invoke(new Invoker<Object>()
- {
- public Object invoke()
- {
- return methodBinding.invoke(facesContext, params);
- }
- });
- }
- return null;
- }
-
- public boolean isLiteralText()
- {
- if (methodBinding == null)
- throw new IllegalStateException("methodBinding is null");
- String expr = methodBinding.getExpressionString();
- return !(expr.startsWith("#{") && expr.endsWith("}"));
- }
-
- public String getExpressionString()
- {
- return methodBinding.getExpressionString();
- }
-
- public Object saveState(FacesContext context)
- {
- if (!isTransient())
- {
- if (methodBinding instanceof StateHolder)
- {
- Object[] state = new Object[2];
- state[0] = methodBinding.getClass().getName();
- state[1] = ((StateHolder) methodBinding).saveState(context);
- return state;
- }
- else
- {
- return methodBinding;
- }
- }
- return null;
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- if (state instanceof MethodBinding)
- {
- methodBinding = (MethodBinding) state;
- methodInfo = null;
- }
- else if (state != null)
- {
- Object[] values = (Object[]) state;
- methodBinding = (MethodBinding) _ClassUtils.newInstance(values[0].toString(), EXPECTED_TYPES);
- ((StateHolder) methodBinding).restoreState(context, values[1]);
- methodInfo = null;
- }
- }
-
- public void setTransient(boolean transientFlag)
- {
- _transientFlag = transientFlag;
- }
-
- public boolean isTransient()
- {
- return _transientFlag;
- }
-
- @Override
- public int hashCode()
- {
- final int PRIME = 31;
- int result = 1;
- result = PRIME * result + ((methodBinding == null) ? 0 : methodBinding.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final _MethodBindingToMethodExpression other = (_MethodBindingToMethodExpression) obj;
- if (methodBinding == null)
- {
- if (other.methodBinding != null)
- return false;
- }
- else if (!methodBinding.equals(other.methodBinding))
- return false;
- return true;
- }
-
- private void checkNullState(Object notNullInstance, String instanceName)
- {
- if (notNullInstance == null)
- throw new IllegalStateException(instanceName + " is null");
- }
-
- private void checkNullArgument(Object notNullInstance, String instanceName)
- {
- if (notNullInstance == null)
- throw new IllegalArgumentException(instanceName + " is null");
- }
-
- private <T> T invoke(Invoker<T> invoker)
- {
- try
- {
- return invoker.invoke();
- }
- catch (javax.faces.el.MethodNotFoundException e)
- {
- throw new MethodNotFoundException(e.getMessage(), e);
- }
- catch (EvaluationException e)
- {
- throw new ELException(e.getMessage(), e);
- }
- }
-
- private interface Invoker<T>
- {
- T invoke();
- }
-}
+/*
+ * Copyright 2006 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 javax.faces.component;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.MethodInfo;
+import javax.el.MethodNotFoundException;
+import javax.el.PropertyNotFoundException;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+
+/**
+ * Converts a MethodBinding to a MethodExpression
+ *
+ * TODO: find a way to share the implementation of class with impl.
+ *
+ * @author Stan Silvert
+ */
+@SuppressWarnings("deprecation")
+class _MethodBindingToMethodExpression extends MethodExpression implements StateHolder
+{
+ private static final Class[] EXPECTED_TYPES = new Class[] { MethodBinding.class, StateHolder.class };
+
+ private MethodBinding methodBinding;
+
+ private boolean _transientFlag;
+
+ private transient MethodInfo methodInfo;
+
+ /**
+ * No-arg constructor used during restoreState
+ */
+ protected _MethodBindingToMethodExpression()
+ {
+ }
+
+ /** Creates a new instance of MethodBindingToMethodExpression */
+ public _MethodBindingToMethodExpression(MethodBinding methodBinding)
+ {
+ checkNullArgument(methodBinding, "methodBinding");
+ this.methodBinding = methodBinding;
+ }
+
+ /**
+ * Return the wrapped MethodBinding.
+ */
+ public MethodBinding getMethodBinding()
+ {
+ return methodBinding;
+ }
+
+ void setMethodBinding(MethodBinding methodBinding)
+ {
+ this.methodBinding = methodBinding;
+ }
+
+ /**
+ * Note: MethodInfo.getParamTypes() may incorrectly return an empty class array if invoke() has not been called.
+ *
+ * @throws IllegalStateException
+ * if expected params types have not been determined.
+ */
+ public MethodInfo getMethodInfo(ELContext context) throws PropertyNotFoundException, MethodNotFoundException,
+ ELException
+ {
+ checkNullArgument(context, "elcontext");
+ checkNullState(methodBinding, "methodBinding");
+
+ if (methodInfo == null)
+ {
+ final FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
+ if (facesContext != null)
+ {
+ methodInfo = invoke(new Invoker<MethodInfo>()
+ {
+ public MethodInfo invoke()
+ {
+ return new MethodInfo(null, methodBinding.getType(facesContext), null);
+ }
+ });
+ }
+ }
+ return methodInfo;
+ }
+
+ public Object invoke(ELContext context, final Object[] params) throws PropertyNotFoundException,
+ MethodNotFoundException, ELException
+ {
+ checkNullArgument(context, "elcontext");
+ checkNullState(methodBinding, "methodBinding");
+ final FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
+ if (facesContext != null)
+ {
+ return invoke(new Invoker<Object>()
+ {
+ public Object invoke()
+ {
+ return methodBinding.invoke(facesContext, params);
+ }
+ });
+ }
+ return null;
+ }
+
+ public boolean isLiteralText()
+ {
+ if (methodBinding == null)
+ throw new IllegalStateException("methodBinding is null");
+ String expr = methodBinding.getExpressionString();
+ return !(expr.startsWith("#{") && expr.endsWith("}"));
+ }
+
+ public String getExpressionString()
+ {
+ return methodBinding.getExpressionString();
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ if (!isTransient())
+ {
+ if (methodBinding instanceof StateHolder)
+ {
+ Object[] state = new Object[2];
+ state[0] = methodBinding.getClass().getName();
+ state[1] = ((StateHolder) methodBinding).saveState(context);
+ return state;
+ }
+ else
+ {
+ return methodBinding;
+ }
+ }
+ return null;
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ if (state instanceof MethodBinding)
+ {
+ methodBinding = (MethodBinding) state;
+ methodInfo = null;
+ }
+ else if (state != null)
+ {
+ Object[] values = (Object[]) state;
+ methodBinding = (MethodBinding) _ClassUtils.newInstance(values[0].toString(), EXPECTED_TYPES);
+ ((StateHolder) methodBinding).restoreState(context, values[1]);
+ methodInfo = null;
+ }
+ }
+
+ public void setTransient(boolean transientFlag)
+ {
+ _transientFlag = transientFlag;
+ }
+
+ public boolean isTransient()
+ {
+ return _transientFlag;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((methodBinding == null) ? 0 : methodBinding.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final _MethodBindingToMethodExpression other = (_MethodBindingToMethodExpression) obj;
+ if (methodBinding == null)
+ {
+ if (other.methodBinding != null)
+ return false;
+ }
+ else if (!methodBinding.equals(other.methodBinding))
+ return false;
+ return true;
+ }
+
+ private void checkNullState(Object notNullInstance, String instanceName)
+ {
+ if (notNullInstance == null)
+ throw new IllegalStateException(instanceName + " is null");
+ }
+
+ private void checkNullArgument(Object notNullInstance, String instanceName)
+ {
+ if (notNullInstance == null)
+ throw new IllegalArgumentException(instanceName + " is null");
+ }
+
+ private <T> T invoke(Invoker<T> invoker)
+ {
+ try
+ {
+ return invoker.invoke();
+ }
+ catch (javax.faces.el.MethodNotFoundException e)
+ {
+ throw new MethodNotFoundException(e.getMessage(), e);
+ }
+ catch (EvaluationException e)
+ {
+ throw new ELException(e.getMessage(), e);
+ }
+ }
+
+ private interface Invoker<T>
+ {
+ T invoke();
+ }
+}
Propchange: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToMethodExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToValueChangeListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToValueChangeListener.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToValueChangeListener.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToValueChangeListener.java Fri Mar 16 06:24:10 2007
@@ -1,43 +1,43 @@
-/*
- * Copyright 2006 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 javax.faces.component;
-
-import javax.faces.el.MethodBinding;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ValueChangeEvent;
-import javax.faces.event.ValueChangeListener;
-
-/**
- * Converts a MethodBinding to a ValueChangeListener
- *
- * @author Stan Silvert
- */
-class _MethodBindingToValueChangeListener extends _MethodBindingToListener implements ValueChangeListener {
-
- public _MethodBindingToValueChangeListener() {
- super();
- }
-
- public _MethodBindingToValueChangeListener(MethodBinding methodBinding) {
- super(methodBinding);
- }
-
- public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
- invokeMethodBinding(event);
- }
-
-}
+/*
+ * Copyright 2006 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 javax.faces.component;
+
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.event.ValueChangeListener;
+
+/**
+ * Converts a MethodBinding to a ValueChangeListener
+ *
+ * @author Stan Silvert
+ */
+class _MethodBindingToValueChangeListener extends _MethodBindingToListener implements ValueChangeListener {
+
+ public _MethodBindingToValueChangeListener() {
+ super();
+ }
+
+ public _MethodBindingToValueChangeListener(MethodBinding methodBinding) {
+ super(methodBinding);
+ }
+
+ public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
+ invokeMethodBinding(event);
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodBindingToValueChangeListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodExpressionToMethodBinding.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodExpressionToMethodBinding.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodExpressionToMethodBinding.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodExpressionToMethodBinding.java Fri Mar 16 06:24:10 2007
@@ -1,104 +1,104 @@
-/*
- * Copyright 2006 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 javax.faces.component;
-
-import javax.el.ELException;
-import javax.el.MethodExpression;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.MethodNotFoundException;
-
-/**
- * Converts a MethodExpression to a MethodBinding.
- * See JSF 1.2 spec section 5.8.4
- *
- * ATTENTION: If you make changes to this class, treat
- * org.apache.myfaces.el.convert.MethodExpressionToMethodBinding
- * accordingly.
- *
- * @author Stan Silvert
- * @see org.apache.myfaces.el.convert.MethodExpressionToMethodBinding
- */
-class _MethodExpressionToMethodBinding extends MethodBinding implements StateHolder {
-
- private MethodExpression methodExpression;
-
- private boolean isTransient = false;
-
- public _MethodExpressionToMethodBinding() {
- methodExpression = null;
- }
-
- /** Creates a new instance of MethodExpressionToMethodBinding */
- public _MethodExpressionToMethodBinding(MethodExpression methodExpression) {
- this.methodExpression = methodExpression;
- }
-
- @Override
- public String getExpressionString()
- {
- return methodExpression.getExpressionString();
- }
-
- public Class getType(FacesContext facesContext)
- throws MethodNotFoundException {
-
- try {
- return methodExpression.getMethodInfo(facesContext.getELContext()).getReturnType();
- } catch (javax.el.MethodNotFoundException e) {
- throw new javax.faces.el.MethodNotFoundException(e);
- } catch (ELException e) {
- throw new EvaluationException(e);
- }
- }
-
- public Object invoke(FacesContext facesContext, Object[] params)
- throws EvaluationException, MethodNotFoundException {
-
- try {
- return methodExpression.invoke(facesContext.getELContext(), params);
- } catch (javax.el.MethodNotFoundException e) {
- throw new javax.faces.el.MethodNotFoundException(e);
- } catch (ELException e) {
- throw new EvaluationException(e);
- }
- }
-
-// -------- StateHolder methods -------------------------------------------
-
- public void restoreState(FacesContext context, Object state) {
- if(state != null)
- methodExpression = (MethodExpression)state;
- }
-
- public Object saveState(FacesContext context) {
- if(!isTransient)
- return methodExpression;
- return null;
- }
-
- public void setTransient(boolean newTransientValue) {
- isTransient = newTransientValue;
- }
-
- public boolean isTransient() {
- return isTransient;
- }
-
-}
+/*
+ * Copyright 2006 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 javax.faces.component;
+
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.MethodNotFoundException;
+
+/**
+ * Converts a MethodExpression to a MethodBinding.
+ * See JSF 1.2 spec section 5.8.4
+ *
+ * ATTENTION: If you make changes to this class, treat
+ * org.apache.myfaces.el.convert.MethodExpressionToMethodBinding
+ * accordingly.
+ *
+ * @author Stan Silvert
+ * @see org.apache.myfaces.el.convert.MethodExpressionToMethodBinding
+ */
+class _MethodExpressionToMethodBinding extends MethodBinding implements StateHolder {
+
+ private MethodExpression methodExpression;
+
+ private boolean isTransient = false;
+
+ public _MethodExpressionToMethodBinding() {
+ methodExpression = null;
+ }
+
+ /** Creates a new instance of MethodExpressionToMethodBinding */
+ public _MethodExpressionToMethodBinding(MethodExpression methodExpression) {
+ this.methodExpression = methodExpression;
+ }
+
+ @Override
+ public String getExpressionString()
+ {
+ return methodExpression.getExpressionString();
+ }
+
+ public Class getType(FacesContext facesContext)
+ throws MethodNotFoundException {
+
+ try {
+ return methodExpression.getMethodInfo(facesContext.getELContext()).getReturnType();
+ } catch (javax.el.MethodNotFoundException e) {
+ throw new javax.faces.el.MethodNotFoundException(e);
+ } catch (ELException e) {
+ throw new EvaluationException(e);
+ }
+ }
+
+ public Object invoke(FacesContext facesContext, Object[] params)
+ throws EvaluationException, MethodNotFoundException {
+
+ try {
+ return methodExpression.invoke(facesContext.getELContext(), params);
+ } catch (javax.el.MethodNotFoundException e) {
+ throw new javax.faces.el.MethodNotFoundException(e);
+ } catch (ELException e) {
+ throw new EvaluationException(e);
+ }
+ }
+
+// -------- StateHolder methods -------------------------------------------
+
+ public void restoreState(FacesContext context, Object state) {
+ if(state != null)
+ methodExpression = (MethodExpression)state;
+ }
+
+ public Object saveState(FacesContext context) {
+ if(!isTransient)
+ return methodExpression;
+ return null;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ isTransient = newTransientValue;
+ }
+
+ public boolean isTransient() {
+ return isTransient;
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_MethodExpressionToMethodBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_PrimitiveArrayIterator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_PrimitiveArrayIterator.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_PrimitiveArrayIterator.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_PrimitiveArrayIterator.java Fri Mar 16 06:24:10 2007
@@ -1,56 +1,56 @@
-/*
- * Copyright 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 javax.faces.component;
-
-import java.lang.reflect.Array;
-import java.util.Iterator;
-
-/**
- * This utility iterator uses reflection to iterate over primitive arrays.
- */
-class _PrimitiveArrayIterator implements Iterator
-{
- public _PrimitiveArrayIterator(Object primitiveArray)
- {
- if (primitiveArray == null ||
- !primitiveArray.getClass().isArray())
- {
- throw new IllegalArgumentException("Requires a primitive array");
- }
-
- _primitiveArray = primitiveArray;
- _size = Array.getLength(primitiveArray);
- }
-
- public boolean hasNext()
- {
- return (_position < _size);
- }
-
- public Object next()
- {
- return Array.get(_primitiveArray, _position++);
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- private Object _primitiveArray;
- private int _size;
- private int _position;
-}
+/*
+ * Copyright 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 javax.faces.component;
+
+import java.lang.reflect.Array;
+import java.util.Iterator;
+
+/**
+ * This utility iterator uses reflection to iterate over primitive arrays.
+ */
+class _PrimitiveArrayIterator implements Iterator
+{
+ public _PrimitiveArrayIterator(Object primitiveArray)
+ {
+ if (primitiveArray == null ||
+ !primitiveArray.getClass().isArray())
+ {
+ throw new IllegalArgumentException("Requires a primitive array");
+ }
+
+ _primitiveArray = primitiveArray;
+ _size = Array.getLength(primitiveArray);
+ }
+
+ public boolean hasNext()
+ {
+ return (_position < _size);
+ }
+
+ public Object next()
+ {
+ return Array.get(_primitiveArray, _position++);
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private Object _primitiveArray;
+ private int _size;
+ private int _position;
+}
Propchange: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_PrimitiveArrayIterator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueBindingToValueExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueBindingToValueExpression.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueBindingToValueExpression.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueBindingToValueExpression.java Fri Mar 16 06:24:10 2007
@@ -1,275 +1,275 @@
-/*
- * Copyright 2006 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 javax.faces.component;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.PropertyNotFoundException;
-import javax.el.PropertyNotWritableException;
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.ValueBinding;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Wraps a ValueBinding inside a ValueExpression. Also allows access to the original ValueBinding object.
- *
- * Although ValueExpression implements Serializable, this class implements StateHolder instead.
- *
- * ATTENTION: If you make changes to this class, treat {@link _ValueBindingToValueExpression} accordingly.
- *
- * @author Stan Silvert
- * @see javax.faces.component._ValueBindingToValueExpression
- */
-@SuppressWarnings("deprecation")
-class _ValueBindingToValueExpression extends ValueExpression implements StateHolder
-{
- private static final long serialVersionUID = 8071429285360496554L;
-
- private static final Log logger = LogFactory.getLog(_ValueBindingToValueExpression.class);
-
- private ValueBinding _valueBinding;
-
- private boolean _transient;
-
- /**
- * No-arg constructor used during restoreState
- */
- protected _ValueBindingToValueExpression()
- {
- }
-
- private ValueBinding getNotNullValueBinding()
- {
- if (_valueBinding == null)
- {
- throw new IllegalStateException("value binding is null");
- }
- return _valueBinding;
- }
-
- /** Creates a new instance of ValueBindingToValueExpression */
- public _ValueBindingToValueExpression(ValueBinding valueBinding)
- {
- if (valueBinding == null)
- {
- throw new IllegalArgumentException("value binding must not be null");
- }
- this._valueBinding = valueBinding;
- }
-
- public ValueBinding getValueBinding()
- {
- return _valueBinding;
- }
-
- @Override
- public boolean isReadOnly(final ELContext context) throws NullPointerException, PropertyNotFoundException,
- ELException
- {
- return invoke(new Invoker<Boolean>()
- {
- public Boolean invoke()
- {
- return getNotNullValueBinding().isReadOnly(getFacesContext(context));
- }
- });
- }
-
- @Override
- public Object getValue(final ELContext context) throws NullPointerException, PropertyNotFoundException, ELException
- {
- return invoke(new Invoker<Object>()
- {
- public Object invoke()
- {
- return getNotNullValueBinding().getValue(getFacesContext(context));
- }
- });
- }
-
- @Override
- public Class<?> getType(final ELContext context) throws NullPointerException, PropertyNotFoundException,
- ELException
- {
- return invoke(new Invoker<Class<?>>()
- {
- public Class<?> invoke()
- {
- return getNotNullValueBinding().getType(getFacesContext(context));
- }
- });
- }
-
- @Override
- public void setValue(final ELContext context, final Object value) throws NullPointerException,
- PropertyNotFoundException, PropertyNotWritableException, ELException
- {
- invoke(new Invoker<Object>()
- {
- public Object invoke()
- {
- getNotNullValueBinding().setValue(getFacesContext(context), value);
- return null;
- }
- });
- }
-
- @Override
- public int hashCode()
- {
- final int PRIME = 31;
- int result = 1;
- result = PRIME * result + (_transient ? 1231 : 1237);
- result = PRIME * result + ((_valueBinding == null) ? 0 : _valueBinding.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final _ValueBindingToValueExpression other = (_ValueBindingToValueExpression) obj;
- if (_transient != other._transient)
- return false;
- if (_valueBinding == null)
- {
- if (other._valueBinding != null)
- return false;
- }
- else if (!_valueBinding.equals(other._valueBinding))
- return false;
- return true;
- }
-
- @Override
- public boolean isLiteralText()
- {
- return false;
- }
-
- @Override
- public String getExpressionString()
- {
- return getNotNullValueBinding().getExpressionString();
- }
-
- @Override
- public Class<?> getExpectedType()
- {
- if (_valueBinding != null)
- {
- try
- {
- Object value = getNotNullValueBinding().getValue(FacesContext.getCurrentInstance());
- if (value != null)
- {
- return value.getClass();
- }
- }
- catch (Throwable e)
- {
- logger.warn("Could not determine expected type for '" + _valueBinding.getExpressionString() + "': "
- + e.getMessage(), e);
- }
- }
- return null;
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- if (state instanceof ValueBinding)
- {
- _valueBinding = (ValueBinding) state;
- }
- else if (state != null)
- {
- Object[] stateArray = (Object[]) state;
- _valueBinding = (ValueBinding) _ClassUtils.newInstance((String) stateArray[0], ValueBinding.class);
- ((StateHolder) _valueBinding).restoreState(context, stateArray[1]);
- }
- }
-
- public Object saveState(FacesContext context)
- {
- if (!_transient)
- {
- if (_valueBinding instanceof StateHolder)
- {
- Object[] state = new Object[2];
- state[0] = _valueBinding.getClass().getName();
- state[1] = ((StateHolder) _valueBinding).saveState(context);
- return state;
- }
- return _valueBinding;
- }
- return null;
- }
-
- public void setTransient(boolean newTransientValue)
- {
- _transient = newTransientValue;
- }
-
- public boolean isTransient()
- {
- return _transient;
- }
-
- private FacesContext getFacesContext(ELContext context)
- {
- if (context == null)
- {
- throw new IllegalArgumentException("el context must not be null.");
- }
- FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
- if (context == null)
- {
- throw new IllegalStateException("faces context not available in el context.");
- }
- return facesContext;
- }
-
- private <T> T invoke(Invoker<T> invoker)
- {
- try
- {
- return invoker.invoke();
- }
- catch (javax.faces.el.PropertyNotFoundException e)
- {
- throw new PropertyNotFoundException(e.getMessage(), e);
- }
- catch (EvaluationException e)
- {
- throw new ELException(e.getMessage(), e);
- }
- }
-
- private interface Invoker<T>
- {
- T invoke();
- }
+/*
+ * Copyright 2006 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 javax.faces.component;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.ValueBinding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Wraps a ValueBinding inside a ValueExpression. Also allows access to the original ValueBinding object.
+ *
+ * Although ValueExpression implements Serializable, this class implements StateHolder instead.
+ *
+ * ATTENTION: If you make changes to this class, treat {@link _ValueBindingToValueExpression} accordingly.
+ *
+ * @author Stan Silvert
+ * @see javax.faces.component._ValueBindingToValueExpression
+ */
+@SuppressWarnings("deprecation")
+class _ValueBindingToValueExpression extends ValueExpression implements StateHolder
+{
+ private static final long serialVersionUID = 8071429285360496554L;
+
+ private static final Log logger = LogFactory.getLog(_ValueBindingToValueExpression.class);
+
+ private ValueBinding _valueBinding;
+
+ private boolean _transient;
+
+ /**
+ * No-arg constructor used during restoreState
+ */
+ protected _ValueBindingToValueExpression()
+ {
+ }
+
+ private ValueBinding getNotNullValueBinding()
+ {
+ if (_valueBinding == null)
+ {
+ throw new IllegalStateException("value binding is null");
+ }
+ return _valueBinding;
+ }
+
+ /** Creates a new instance of ValueBindingToValueExpression */
+ public _ValueBindingToValueExpression(ValueBinding valueBinding)
+ {
+ if (valueBinding == null)
+ {
+ throw new IllegalArgumentException("value binding must not be null");
+ }
+ this._valueBinding = valueBinding;
+ }
+
+ public ValueBinding getValueBinding()
+ {
+ return _valueBinding;
+ }
+
+ @Override
+ public boolean isReadOnly(final ELContext context) throws NullPointerException, PropertyNotFoundException,
+ ELException
+ {
+ return invoke(new Invoker<Boolean>()
+ {
+ public Boolean invoke()
+ {
+ return getNotNullValueBinding().isReadOnly(getFacesContext(context));
+ }
+ });
+ }
+
+ @Override
+ public Object getValue(final ELContext context) throws NullPointerException, PropertyNotFoundException, ELException
+ {
+ return invoke(new Invoker<Object>()
+ {
+ public Object invoke()
+ {
+ return getNotNullValueBinding().getValue(getFacesContext(context));
+ }
+ });
+ }
+
+ @Override
+ public Class<?> getType(final ELContext context) throws NullPointerException, PropertyNotFoundException,
+ ELException
+ {
+ return invoke(new Invoker<Class<?>>()
+ {
+ public Class<?> invoke()
+ {
+ return getNotNullValueBinding().getType(getFacesContext(context));
+ }
+ });
+ }
+
+ @Override
+ public void setValue(final ELContext context, final Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException, ELException
+ {
+ invoke(new Invoker<Object>()
+ {
+ public Object invoke()
+ {
+ getNotNullValueBinding().setValue(getFacesContext(context), value);
+ return null;
+ }
+ });
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + (_transient ? 1231 : 1237);
+ result = PRIME * result + ((_valueBinding == null) ? 0 : _valueBinding.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final _ValueBindingToValueExpression other = (_ValueBindingToValueExpression) obj;
+ if (_transient != other._transient)
+ return false;
+ if (_valueBinding == null)
+ {
+ if (other._valueBinding != null)
+ return false;
+ }
+ else if (!_valueBinding.equals(other._valueBinding))
+ return false;
+ return true;
+ }
+
+ @Override
+ public boolean isLiteralText()
+ {
+ return false;
+ }
+
+ @Override
+ public String getExpressionString()
+ {
+ return getNotNullValueBinding().getExpressionString();
+ }
+
+ @Override
+ public Class<?> getExpectedType()
+ {
+ if (_valueBinding != null)
+ {
+ try
+ {
+ Object value = getNotNullValueBinding().getValue(FacesContext.getCurrentInstance());
+ if (value != null)
+ {
+ return value.getClass();
+ }
+ }
+ catch (Throwable e)
+ {
+ logger.warn("Could not determine expected type for '" + _valueBinding.getExpressionString() + "': "
+ + e.getMessage(), e);
+ }
+ }
+ return null;
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ if (state instanceof ValueBinding)
+ {
+ _valueBinding = (ValueBinding) state;
+ }
+ else if (state != null)
+ {
+ Object[] stateArray = (Object[]) state;
+ _valueBinding = (ValueBinding) _ClassUtils.newInstance((String) stateArray[0], ValueBinding.class);
+ ((StateHolder) _valueBinding).restoreState(context, stateArray[1]);
+ }
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ if (!_transient)
+ {
+ if (_valueBinding instanceof StateHolder)
+ {
+ Object[] state = new Object[2];
+ state[0] = _valueBinding.getClass().getName();
+ state[1] = ((StateHolder) _valueBinding).saveState(context);
+ return state;
+ }
+ return _valueBinding;
+ }
+ return null;
+ }
+
+ public void setTransient(boolean newTransientValue)
+ {
+ _transient = newTransientValue;
+ }
+
+ public boolean isTransient()
+ {
+ return _transient;
+ }
+
+ private FacesContext getFacesContext(ELContext context)
+ {
+ if (context == null)
+ {
+ throw new IllegalArgumentException("el context must not be null.");
+ }
+ FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
+ if (context == null)
+ {
+ throw new IllegalStateException("faces context not available in el context.");
+ }
+ return facesContext;
+ }
+
+ private <T> T invoke(Invoker<T> invoker)
+ {
+ try
+ {
+ return invoker.invoke();
+ }
+ catch (javax.faces.el.PropertyNotFoundException e)
+ {
+ throw new PropertyNotFoundException(e.getMessage(), e);
+ }
+ catch (EvaluationException e)
+ {
+ throw new ELException(e.getMessage(), e);
+ }
+ }
+
+ private interface Invoker<T>
+ {
+ T invoke();
+ }
}
Propchange: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueBindingToValueExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueExpressionToValueBinding.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueExpressionToValueBinding.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueExpressionToValueBinding.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueExpressionToValueBinding.java Fri Mar 16 06:24:10 2007
@@ -1,235 +1,235 @@
-/*
- * Copyright 2006 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 javax.faces.component;
-
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyNotFoundException;
-import javax.faces.el.ValueBinding;
-
-/**
- * Converter for legacy ValueBinding objects. See JSF 1.2 section 5.8.3
- *
- * ATTENTION: If you make changes to this class, treat javax.faces.component.ValueExpressionToValueBinding accordingly.
- *
- * @author Stan Silvert
- * @see javax.faces.component.ValueExpressionToValueBinding
- */
-@SuppressWarnings("deprecation")
-class _ValueExpressionToValueBinding extends ValueBinding implements StateHolder
-{
-
- private ValueExpression _valueExpression;
-
- private boolean isTransient = false;
-
- // required no-arg constructor for StateHolder
- protected _ValueExpressionToValueBinding()
- {
- _valueExpression = null;
- }
-
- @Override
- public int hashCode()
- {
- final int PRIME = 31;
- int result = 1;
- result = PRIME * result + ((_valueExpression == null) ? 0 : _valueExpression.hashCode());
- result = PRIME * result + (isTransient ? 1231 : 1237);
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final _ValueExpressionToValueBinding other = (_ValueExpressionToValueBinding) obj;
- if (_valueExpression == null)
- {
- if (other._valueExpression != null)
- return false;
- }
- else if (!_valueExpression.equals(other._valueExpression))
- return false;
- if (isTransient != other.isTransient)
- return false;
- return true;
- }
-
- /**
- * @return the valueExpression
- */
- public ValueExpression getValueExpression()
- {
- return getNotNullValueExpression();
- }
-
- /**
- * @return the valueExpression
- */
- private ValueExpression getNotNullValueExpression()
- {
- if (_valueExpression == null)
- {
- throw new IllegalStateException("value expression is null");
- }
- return _valueExpression;
- }
-
- @Override
- public String getExpressionString()
- {
- return getNotNullValueExpression().getExpressionString();
- }
-
- /** Creates a new instance of ValueExpressionToValueBinding */
- public _ValueExpressionToValueBinding(ValueExpression valueExpression)
- {
- if (valueExpression == null)
- {
- throw new IllegalArgumentException("value expression must not be null.");
- }
- _valueExpression = valueExpression;
- }
-
- @Override
- public void setValue(FacesContext facesContext, Object value) throws EvaluationException, PropertyNotFoundException
- {
- try
- {
- getNotNullValueExpression().setValue(facesContext.getELContext(), value);
- }
- catch (javax.el.PropertyNotFoundException e)
- {
- throw new javax.faces.el.PropertyNotFoundException(e);
- }
- catch (ELException e)
- {
- throw new EvaluationException(e);
- }
- }
-
- @Override
- public boolean isReadOnly(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
- {
-
- try
- {
- return getNotNullValueExpression().isReadOnly(facesContext.getELContext());
- }
- catch (javax.el.PropertyNotFoundException e)
- {
- throw new javax.faces.el.PropertyNotFoundException(e);
- }
- catch (ELException e)
- {
- throw new EvaluationException(e);
- }
-
- }
-
- @Override
- public Object getValue(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
- {
- try
- {
- return getNotNullValueExpression().getValue(facesContext.getELContext());
- }
- catch (javax.el.PropertyNotFoundException e)
- {
- throw new javax.faces.el.PropertyNotFoundException(e);
- }
- catch (ELException e)
- {
- throw new EvaluationException(e);
- }
- }
-
- @Override
- public Class getType(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
- {
- try
- {
- return getNotNullValueExpression().getType(facesContext.getELContext());
- }
- catch (javax.el.PropertyNotFoundException e)
- {
- throw new javax.faces.el.PropertyNotFoundException(e);
- }
- catch (ELException e)
- {
- throw new EvaluationException(e);
- }
- }
-
- // -------- StateHolder methods -------------------------------------------
-
- public void restoreState(FacesContext facesContext, Object state)
- {
- if (state != null)
- {
- if (state instanceof ValueExpression)
- {
- _valueExpression = (ValueExpression) state;
- }
- else
- {
- Object[] stateArray = (Object[]) state;
- _valueExpression = (ValueExpression) _ClassUtils.newInstance((String) stateArray[0],
- ValueExpression.class);
- ((StateHolder) _valueExpression).restoreState(facesContext, stateArray[1]);
- }
- }
- }
-
- public Object saveState(FacesContext context)
- {
- if (!isTransient)
- {
- if (_valueExpression instanceof StateHolder)
- {
- Object[] state = new Object[2];
- state[0] = _valueExpression.getClass().getName();
- state[1] = ((StateHolder) _valueExpression).saveState(context);
- return state;
- }
- else
- {
- return _valueExpression;
- }
- }
- return null;
- }
-
- public void setTransient(boolean newTransientValue)
- {
- isTransient = newTransientValue;
- }
-
- public boolean isTransient()
- {
- return isTransient;
- }
-
-}
+/*
+ * Copyright 2006 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 javax.faces.component;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
+
+/**
+ * Converter for legacy ValueBinding objects. See JSF 1.2 section 5.8.3
+ *
+ * ATTENTION: If you make changes to this class, treat javax.faces.component.ValueExpressionToValueBinding accordingly.
+ *
+ * @author Stan Silvert
+ * @see javax.faces.component.ValueExpressionToValueBinding
+ */
+@SuppressWarnings("deprecation")
+class _ValueExpressionToValueBinding extends ValueBinding implements StateHolder
+{
+
+ private ValueExpression _valueExpression;
+
+ private boolean isTransient = false;
+
+ // required no-arg constructor for StateHolder
+ protected _ValueExpressionToValueBinding()
+ {
+ _valueExpression = null;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((_valueExpression == null) ? 0 : _valueExpression.hashCode());
+ result = PRIME * result + (isTransient ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final _ValueExpressionToValueBinding other = (_ValueExpressionToValueBinding) obj;
+ if (_valueExpression == null)
+ {
+ if (other._valueExpression != null)
+ return false;
+ }
+ else if (!_valueExpression.equals(other._valueExpression))
+ return false;
+ if (isTransient != other.isTransient)
+ return false;
+ return true;
+ }
+
+ /**
+ * @return the valueExpression
+ */
+ public ValueExpression getValueExpression()
+ {
+ return getNotNullValueExpression();
+ }
+
+ /**
+ * @return the valueExpression
+ */
+ private ValueExpression getNotNullValueExpression()
+ {
+ if (_valueExpression == null)
+ {
+ throw new IllegalStateException("value expression is null");
+ }
+ return _valueExpression;
+ }
+
+ @Override
+ public String getExpressionString()
+ {
+ return getNotNullValueExpression().getExpressionString();
+ }
+
+ /** Creates a new instance of ValueExpressionToValueBinding */
+ public _ValueExpressionToValueBinding(ValueExpression valueExpression)
+ {
+ if (valueExpression == null)
+ {
+ throw new IllegalArgumentException("value expression must not be null.");
+ }
+ _valueExpression = valueExpression;
+ }
+
+ @Override
+ public void setValue(FacesContext facesContext, Object value) throws EvaluationException, PropertyNotFoundException
+ {
+ try
+ {
+ getNotNullValueExpression().setValue(facesContext.getELContext(), value);
+ }
+ catch (javax.el.PropertyNotFoundException e)
+ {
+ throw new javax.faces.el.PropertyNotFoundException(e);
+ }
+ catch (ELException e)
+ {
+ throw new EvaluationException(e);
+ }
+ }
+
+ @Override
+ public boolean isReadOnly(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
+ {
+
+ try
+ {
+ return getNotNullValueExpression().isReadOnly(facesContext.getELContext());
+ }
+ catch (javax.el.PropertyNotFoundException e)
+ {
+ throw new javax.faces.el.PropertyNotFoundException(e);
+ }
+ catch (ELException e)
+ {
+ throw new EvaluationException(e);
+ }
+
+ }
+
+ @Override
+ public Object getValue(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
+ {
+ try
+ {
+ return getNotNullValueExpression().getValue(facesContext.getELContext());
+ }
+ catch (javax.el.PropertyNotFoundException e)
+ {
+ throw new javax.faces.el.PropertyNotFoundException(e);
+ }
+ catch (ELException e)
+ {
+ throw new EvaluationException(e);
+ }
+ }
+
+ @Override
+ public Class getType(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException
+ {
+ try
+ {
+ return getNotNullValueExpression().getType(facesContext.getELContext());
+ }
+ catch (javax.el.PropertyNotFoundException e)
+ {
+ throw new javax.faces.el.PropertyNotFoundException(e);
+ }
+ catch (ELException e)
+ {
+ throw new EvaluationException(e);
+ }
+ }
+
+ // -------- StateHolder methods -------------------------------------------
+
+ public void restoreState(FacesContext facesContext, Object state)
+ {
+ if (state != null)
+ {
+ if (state instanceof ValueExpression)
+ {
+ _valueExpression = (ValueExpression) state;
+ }
+ else
+ {
+ Object[] stateArray = (Object[]) state;
+ _valueExpression = (ValueExpression) _ClassUtils.newInstance((String) stateArray[0],
+ ValueExpression.class);
+ ((StateHolder) _valueExpression).restoreState(facesContext, stateArray[1]);
+ }
+ }
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ if (!isTransient)
+ {
+ if (_valueExpression instanceof StateHolder)
+ {
+ Object[] state = new Object[2];
+ state[0] = _valueExpression.getClass().getName();
+ state[1] = ((StateHolder) _valueExpression).saveState(context);
+ return state;
+ }
+ else
+ {
+ return _valueExpression;
+ }
+ }
+ return null;
+ }
+
+ public void setTransient(boolean newTransientValue)
+ {
+ isTransient = newTransientValue;
+ }
+
+ public boolean isTransient()
+ {
+ return isTransient;
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/component/_ValueExpressionToValueBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/ResponseWriterWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/ResponseWriterWrapper.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/ResponseWriterWrapper.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/ResponseWriterWrapper.java Fri Mar 16 06:24:10 2007
@@ -1,100 +1,100 @@
-/*
- * Copyright 2006 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 javax.faces.context;
-
-import javax.faces.component.UIComponent;
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
- *
- * @author Stan Silvert
- */
-public abstract class ResponseWriterWrapper extends ResponseWriter {
-
- protected abstract ResponseWriter getWrapped();
-
- public void endElement(String name) throws IOException {
- getWrapped().endElement(name);
- }
-
- public void writeComment(Object comment) throws IOException {
- getWrapped().writeComment(comment);
- }
-
- public void startElement(String name, UIComponent component) throws IOException {
- getWrapped().startElement(name, component);
- }
-
- public void writeText(Object text, String property) throws IOException {
- getWrapped().writeText(text, property);
- }
-
- public void writeText(char[] text, int off, int len) throws IOException {
- getWrapped().writeText(text, off, len);
- }
-
- public void write(char[] cbuf, int off, int len) throws IOException {
- getWrapped().write(cbuf, off, len);
- }
-
- public ResponseWriter cloneWithWriter(Writer writer) {
- return getWrapped().cloneWithWriter(writer);
- }
-
- public void writeURIAttribute(String name, Object value, String property) throws IOException {
- getWrapped().writeURIAttribute(name, value,property);
- }
-
- public void close() throws IOException {
- getWrapped().close();
- }
-
- public void endDocument() throws IOException {
- getWrapped().endDocument();
- }
-
- public void flush() throws IOException {
- getWrapped().flush();
- }
-
- public String getCharacterEncoding() {
- return getWrapped().getCharacterEncoding();
- }
-
- public String getContentType() {
- return getWrapped().getContentType();
- }
-
- public void startDocument() throws IOException {
- getWrapped().startDocument();
- }
-
- public void writeAttribute(String name, Object value, String property) throws IOException {
- getWrapped().writeAttribute(name, value, property);
- }
-
- /**
- * @since 1.2
- */
- public void writeText(Object object, UIComponent component, String string) throws IOException
- {
- getWrapped().writeText(object, component, string);
- }
-
-}
+/*
+ * Copyright 2006 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 javax.faces.context;
+
+import javax.faces.component.UIComponent;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ *
+ * @author Stan Silvert
+ */
+public abstract class ResponseWriterWrapper extends ResponseWriter {
+
+ protected abstract ResponseWriter getWrapped();
+
+ public void endElement(String name) throws IOException {
+ getWrapped().endElement(name);
+ }
+
+ public void writeComment(Object comment) throws IOException {
+ getWrapped().writeComment(comment);
+ }
+
+ public void startElement(String name, UIComponent component) throws IOException {
+ getWrapped().startElement(name, component);
+ }
+
+ public void writeText(Object text, String property) throws IOException {
+ getWrapped().writeText(text, property);
+ }
+
+ public void writeText(char[] text, int off, int len) throws IOException {
+ getWrapped().writeText(text, off, len);
+ }
+
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ getWrapped().write(cbuf, off, len);
+ }
+
+ public ResponseWriter cloneWithWriter(Writer writer) {
+ return getWrapped().cloneWithWriter(writer);
+ }
+
+ public void writeURIAttribute(String name, Object value, String property) throws IOException {
+ getWrapped().writeURIAttribute(name, value,property);
+ }
+
+ public void close() throws IOException {
+ getWrapped().close();
+ }
+
+ public void endDocument() throws IOException {
+ getWrapped().endDocument();
+ }
+
+ public void flush() throws IOException {
+ getWrapped().flush();
+ }
+
+ public String getCharacterEncoding() {
+ return getWrapped().getCharacterEncoding();
+ }
+
+ public String getContentType() {
+ return getWrapped().getContentType();
+ }
+
+ public void startDocument() throws IOException {
+ getWrapped().startDocument();
+ }
+
+ public void writeAttribute(String name, Object value, String property) throws IOException {
+ getWrapped().writeAttribute(name, value, property);
+ }
+
+ /**
+ * @since 1.2
+ */
+ public void writeText(Object object, UIComponent component, String string) throws IOException
+ {
+ getWrapped().writeText(object, component, string);
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/context/ResponseWriterWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/convert/EnumConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/convert/EnumConverter.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/convert/EnumConverter.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/convert/EnumConverter.java Fri Mar 16 06:24:10 2007
@@ -1,114 +1,114 @@
-/*
- * Copyright 2006 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 javax.faces.convert;
-
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
- *
- * @author Stan Silvert
- */
-public class EnumConverter implements Converter, StateHolder {
-
- public static final String CONVERTER_ID = "javax.faces.Enum";
- public static final String ENUM_ID = "javax.faces.converter.EnumConverter.ENUM";
- public static final String ENUM_NO_CLASS_ID = "javax.faces.converter.EnumConverter.ENUM_NO_CLASS";
-
- private Class targetClass;
-
- private boolean isTransient = false;
-
- /** Creates a new instance of EnumConverter */
- public EnumConverter() {
- }
-
- public EnumConverter(Class targetClass) {
- if (!targetClass.isEnum()) throw new IllegalArgumentException("targetClass for EnumConverter must be an Enum");
- this.targetClass = targetClass;
- }
-
- public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value) throws ConverterException {
- if (facesContext == null) throw new NullPointerException("facesContext can not be null");
- if (uiComponent == null) throw new NullPointerException("uiComponent can not be null");
- if (value == null) return "";
-
-
- for (Object enumConstant : targetClass.getEnumConstants()) {
- if (enumConstant == value) return enumConstant.toString();
- }
-
- return value.toString();
- }
-
- public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value) throws ConverterException {
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
- if (value == null) return null;
- if (targetClass == null) {
- Object[] params = new Object[]{value, _MessageUtils.getLabel(facesContext, uiComponent)};
- throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
- ENUM_NO_CLASS_ID,
- params));
- }
-
- value = value.trim();
- if (value.length() == 0) return null;
-
- // we know targetClass and value can't be null, so we can use Enum.valueOf
- // instead of the hokey looping called for in the javadoc
- try {
- return Enum.valueOf(targetClass, value);
- } catch (IllegalArgumentException e) {
- Object[] params = new Object[]{value,
- firstConstantOfEnum(),
- _MessageUtils.getLabel(facesContext, uiComponent)};
-
- throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
- ENUM_ID,
- params));
- }
- }
-
- // find the first constant value of the targetClass and return as a String
- private String firstConstantOfEnum() {
- Object[] enumConstants= targetClass.getEnumConstants();
-
- if (enumConstants.length != 0 ) return enumConstants[0].toString();
-
- return ""; // if empty Enum
- }
-
- public void restoreState(FacesContext context, Object state) {
- targetClass = (Class)state;
- }
-
- public Object saveState(FacesContext context) {
- return targetClass;
- }
-
- public void setTransient(boolean newTransientValue) {
- isTransient = newTransientValue;
- }
-
- public boolean isTransient() {
- return isTransient;
- }
-
-}
+/*
+ * Copyright 2006 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 javax.faces.convert;
+
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ *
+ * @author Stan Silvert
+ */
+public class EnumConverter implements Converter, StateHolder {
+
+ public static final String CONVERTER_ID = "javax.faces.Enum";
+ public static final String ENUM_ID = "javax.faces.converter.EnumConverter.ENUM";
+ public static final String ENUM_NO_CLASS_ID = "javax.faces.converter.EnumConverter.ENUM_NO_CLASS";
+
+ private Class targetClass;
+
+ private boolean isTransient = false;
+
+ /** Creates a new instance of EnumConverter */
+ public EnumConverter() {
+ }
+
+ public EnumConverter(Class targetClass) {
+ if (!targetClass.isEnum()) throw new IllegalArgumentException("targetClass for EnumConverter must be an Enum");
+ this.targetClass = targetClass;
+ }
+
+ public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value) throws ConverterException {
+ if (facesContext == null) throw new NullPointerException("facesContext can not be null");
+ if (uiComponent == null) throw new NullPointerException("uiComponent can not be null");
+ if (value == null) return "";
+
+
+ for (Object enumConstant : targetClass.getEnumConstants()) {
+ if (enumConstant == value) return enumConstant.toString();
+ }
+
+ return value.toString();
+ }
+
+ public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value) throws ConverterException {
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+ if (value == null) return null;
+ if (targetClass == null) {
+ Object[] params = new Object[]{value, _MessageUtils.getLabel(facesContext, uiComponent)};
+ throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+ ENUM_NO_CLASS_ID,
+ params));
+ }
+
+ value = value.trim();
+ if (value.length() == 0) return null;
+
+ // we know targetClass and value can't be null, so we can use Enum.valueOf
+ // instead of the hokey looping called for in the javadoc
+ try {
+ return Enum.valueOf(targetClass, value);
+ } catch (IllegalArgumentException e) {
+ Object[] params = new Object[]{value,
+ firstConstantOfEnum(),
+ _MessageUtils.getLabel(facesContext, uiComponent)};
+
+ throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+ ENUM_ID,
+ params));
+ }
+ }
+
+ // find the first constant value of the targetClass and return as a String
+ private String firstConstantOfEnum() {
+ Object[] enumConstants= targetClass.getEnumConstants();
+
+ if (enumConstants.length != 0 ) return enumConstants[0].toString();
+
+ return ""; // if empty Enum
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ targetClass = (Class)state;
+ }
+
+ public Object saveState(FacesContext context) {
+ return targetClass;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ isTransient = newTransientValue;
+ }
+
+ public boolean isTransient() {
+ return isTransient;
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/convert/EnumConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/event/MethodExpressionActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/main/java/javax/faces/event/MethodExpressionActionListener.java?view=diff&rev=518967&r1=518966&r2=518967
==============================================================================
--- myfaces/core/branches/jsf12/api/src/main/java/javax/faces/event/MethodExpressionActionListener.java (original)
+++ myfaces/core/branches/jsf12/api/src/main/java/javax/faces/event/MethodExpressionActionListener.java Fri Mar 16 06:24:10 2007
@@ -1,72 +1,72 @@
-/*
- * Copyright 2006 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 javax.faces.event;
-
-import javax.el.ELContext;
-import javax.el.MethodExpression;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-
-/**
- * See Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
- *
- * @author Stan Silvert
- */
-public class MethodExpressionActionListener implements ActionListener, StateHolder {
-
- private MethodExpression methodExpression;
-
- private boolean isTransient = false;
-
- /** Creates a new instance of MethodExpressionActionListener */
- public MethodExpressionActionListener() {
- }
-
- public MethodExpressionActionListener(MethodExpression methodExpression) {
- this.methodExpression = methodExpression;
- }
-
- public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
- try {
- Object[] params = new Object[]{actionEvent};
- methodExpression.invoke(elContext(), params);
- } catch (Exception e) {
- throw new AbortProcessingException(e);
- }
- }
-
- private ELContext elContext() {
- return FacesContext.getCurrentInstance().getELContext();
- }
-
- public void restoreState(FacesContext context, Object state) {
- methodExpression = (MethodExpression)state;
- }
-
- public Object saveState(FacesContext context) {
- return methodExpression;
- }
-
- public void setTransient(boolean newTransientValue) {
- isTransient = newTransientValue;
- }
-
- public boolean isTransient() {
- return isTransient;
- }
-
-}
+/*
+ * Copyright 2006 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 javax.faces.event;
+
+import javax.el.ELContext;
+import javax.el.MethodExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+
+/**
+ * See Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ *
+ * @author Stan Silvert
+ */
+public class MethodExpressionActionListener implements ActionListener, StateHolder {
+
+ private MethodExpression methodExpression;
+
+ private boolean isTransient = false;
+
+ /** Creates a new instance of MethodExpressionActionListener */
+ public MethodExpressionActionListener() {
+ }
+
+ public MethodExpressionActionListener(MethodExpression methodExpression) {
+ this.methodExpression = methodExpression;
+ }
+
+ public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
+ try {
+ Object[] params = new Object[]{actionEvent};
+ methodExpression.invoke(elContext(), params);
+ } catch (Exception e) {
+ throw new AbortProcessingException(e);
+ }
+ }
+
+ private ELContext elContext() {
+ return FacesContext.getCurrentInstance().getELContext();
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ methodExpression = (MethodExpression)state;
+ }
+
+ public Object saveState(FacesContext context) {
+ return methodExpression;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ isTransient = newTransientValue;
+ }
+
+ public boolean isTransient() {
+ return isTransient;
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/api/src/main/java/javax/faces/event/MethodExpressionActionListener.java
------------------------------------------------------------------------------
svn:eol-style = native