You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/05/29 02:41:13 UTC
svn commit: r949328 - in
/myfaces/core/trunk/api/src/main/java/javax/faces/component: UIData.java
UIForm.java UIInput.java
Author: lu4242
Date: Sat May 29 00:41:12 2010
New Revision: 949328
URL: http://svn.apache.org/viewvc?rev=949328&view=rev
Log:
MYFACES-2737 Cache FacesContext on UIComponentBase instances
Modified:
myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java
myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java
myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java
Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java?rev=949328&r1=949327&r2=949328&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java Sat May 29 00:41:12 2010
@@ -817,7 +817,15 @@ public class UIData extends UIComponentB
@Override
public void encodeEnd(FacesContext context) throws IOException
{
- setRowIndex(-1);
+ try
+ {
+ setCachedFacesContext(context);
+ setRowIndex(-1);
+ }
+ finally
+ {
+ setCachedFacesContext(null);
+ }
super.encodeEnd(context);
}
Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java?rev=949328&r1=949327&r2=949328&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java Sat May 29 00:41:12 2010
@@ -79,13 +79,33 @@ public class UIForm extends UIComponentB
public void processDecodes(FacesContext context)
{
if (context == null)
+ {
throw new NullPointerException("context");
- decode(context);
- if (!isSubmitted())
- return;
- for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+ }
+ try
+ {
+ setCachedFacesContext(context);
+ try
+ {
+ pushComponentToEL(context, this);
+
+ decode(context);
+
+ if (!isSubmitted())
+ return;
+ for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+ {
+ it.next().processDecodes(context);
+ }
+ }
+ finally
+ {
+ popComponentFromEL(context);
+ }
+ }
+ finally
{
- it.next().processDecodes(context);
+ setCachedFacesContext(null);
}
}
@@ -93,19 +113,38 @@ public class UIForm extends UIComponentB
public void processValidators(FacesContext context)
{
if (context == null)
+ {
throw new NullPointerException("context");
- // SF issue #1050022: a form used within a datatable will loose it's submitted state
- // as UIForm is no EditableValueHolder and therefore it's state is not saved/restored by UIData
- // to restore the submitted state we call decode here again
- if (!isSubmitted())
- {
- decode(context);
- }
- if (!isSubmitted())
- return;
- for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+ }
+
+ try
{
- it.next().processValidators(context);
+ setCachedFacesContext(context);
+ try
+ {
+ pushComponentToEL(context, this);
+ // SF issue #1050022: a form used within a datatable will loose it's submitted state
+ // as UIForm is no EditableValueHolder and therefore it's state is not saved/restored by UIData
+ // to restore the submitted state we call decode here again
+ if (!isSubmitted())
+ {
+ decode(context);
+ }
+ if (!isSubmitted())
+ return;
+ for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+ {
+ it.next().processValidators(context);
+ }
+ }
+ finally
+ {
+ popComponentFromEL(context);
+ }
+ }
+ finally
+ {
+ setCachedFacesContext(null);
}
}
@@ -113,19 +152,38 @@ public class UIForm extends UIComponentB
public void processUpdates(FacesContext context)
{
if (context == null)
+ {
throw new NullPointerException("context");
- // SF issue #1050022: a form used within a datatable will loose it's submitted state
- // as UIForm is no EditableValueHolder and therefore it's state is not saved/restored by UIData
- // to restore the submitted state we call decode here again
- if (!isSubmitted())
- {
- decode(context);
- }
- if (!isSubmitted())
- return;
- for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+ }
+
+ try
+ {
+ setCachedFacesContext(context);
+ try
+ {
+ pushComponentToEL(context, this);
+ // SF issue #1050022: a form used within a datatable will loose it's submitted state
+ // as UIForm is no EditableValueHolder and therefore it's state is not saved/restored by UIData
+ // to restore the submitted state we call decode here again
+ if (!isSubmitted())
+ {
+ decode(context);
+ }
+ if (!isSubmitted())
+ return;
+ for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+ {
+ it.next().processUpdates(context);
+ }
+ }
+ finally
+ {
+ popComponentFromEL(context);
+ }
+ }
+ finally
{
- it.next().processUpdates(context);
+ setCachedFacesContext(null);
}
}
Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java?rev=949328&r1=949327&r2=949328&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java Sat May 29 00:41:12 2010
@@ -159,34 +159,50 @@ public class UIInput extends UIOutput im
{
throw new NullPointerException("context");
}
- if (!isRendered())
+ try
{
- return;
+ setCachedFacesContext(context);
+ if (!isRendered())
+ {
+ return;
+ }
+ }
+ finally
+ {
+ setCachedFacesContext(null);
}
super.processDecodes(context);
- if (isImmediate())
+ try
{
- try
+ setCachedFacesContext(context);
+ if (isImmediate())
{
- //Pre validation event dispatch for component
- context.getApplication().publishEvent(context, PreValidateEvent.class, UIComponent.class, this);
-
- validate(context);
- }
- catch (RuntimeException e)
- {
- context.renderResponse();
- throw e;
- }
- finally
- {
- context.getApplication().publishEvent(context, PostValidateEvent.class, UIComponent.class, this);
- }
- if (!isValid())
- {
- context.renderResponse();
+ try
+ {
+ //Pre validation event dispatch for component
+ context.getApplication().publishEvent(context, PreValidateEvent.class, UIComponent.class, this);
+
+ validate(context);
+ }
+ catch (RuntimeException e)
+ {
+ context.renderResponse();
+ throw e;
+ }
+ finally
+ {
+ context.getApplication().publishEvent(context, PostValidateEvent.class, UIComponent.class, this);
+ }
+ if (!isValid())
+ {
+ context.renderResponse();
+ }
}
}
+ finally
+ {
+ setCachedFacesContext(null);
+ }
}
@Override
@@ -196,37 +212,53 @@ public class UIInput extends UIOutput im
{
throw new NullPointerException("context");
}
- if (!isRendered())
+ try
+ {
+ setCachedFacesContext(context);
+ if (!isRendered())
+ {
+ return;
+ }
+ }
+ finally
{
- return;
+ setCachedFacesContext(null);
}
super.processValidators(context);
- if (!isImmediate())
+ try
{
- try
+ setCachedFacesContext(context);
+ if (!isImmediate())
{
- //Pre validation event dispatch for component
- context.getApplication().publishEvent(context, PreValidateEvent.class, UIComponent.class, this);
-
- validate(context);
- }
- catch (RuntimeException e)
- {
- context.renderResponse();
- throw e;
- }
- finally
- {
- context.getApplication().publishEvent(context, PostValidateEvent.class, UIComponent.class, this);
- }
- if (!isValid())
- {
- context.validationFailed();
- context.renderResponse();
+ try
+ {
+ //Pre validation event dispatch for component
+ context.getApplication().publishEvent(context, PreValidateEvent.class, UIComponent.class, this);
+
+ validate(context);
+ }
+ catch (RuntimeException e)
+ {
+ context.renderResponse();
+ throw e;
+ }
+ finally
+ {
+ context.getApplication().publishEvent(context, PostValidateEvent.class, UIComponent.class, this);
+ }
+ if (!isValid())
+ {
+ context.validationFailed();
+ context.renderResponse();
+ }
}
}
+ finally
+ {
+ setCachedFacesContext(null);
+ }
}
@Override
@@ -236,25 +268,40 @@ public class UIInput extends UIOutput im
{
throw new NullPointerException("context");
}
- if (!isRendered())
+ try
+ {
+ setCachedFacesContext(context);
+ if (!isRendered())
+ {
+ return;
+ }
+ }
+ finally
{
- return;
+ setCachedFacesContext(null);
}
-
super.processUpdates(context);
try
{
- updateModel(context);
- }
- catch (RuntimeException e)
- {
- context.renderResponse();
- throw e;
+ setCachedFacesContext(context);
+ try
+ {
+ updateModel(context);
+ }
+ catch (RuntimeException e)
+ {
+ context.renderResponse();
+ throw e;
+ }
+ if (!isValid())
+ {
+ context.renderResponse();
+ }
}
- if (!isValid())
+ finally
{
- context.renderResponse();
+ setCachedFacesContext(null);
}
}