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:38:36 UTC
svn commit: r949325 - in
/myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component:
UIData.java UIForm.java UIInput.java
Author: lu4242
Date: Sat May 29 00:38:36 2010
New Revision: 949325
URL: http://svn.apache.org/viewvc?rev=949325&view=rev
Log:
MYFACES-2737 Cache FacesContext on UIComponentBase instances
Modified:
myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIData.java
myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIForm.java
myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIInput.java
Modified: myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIData.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIData.java?rev=949325&r1=949324&r2=949325&view=diff
==============================================================================
--- myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIData.java (original)
+++ myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIData.java Sat May 29 00:38:36 2010
@@ -597,7 +597,15 @@ public class UIData extends UIComponentB
*/
public void encodeEnd(FacesContext context) throws IOException
{
- setRowIndex(-1);
+ try
+ {
+ setCachedFacesContext(context);
+ setRowIndex(-1);
+ }
+ finally
+ {
+ setCachedFacesContext(null);
+ }
super.encodeEnd(context);
}
Modified: myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIForm.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIForm.java?rev=949325&r1=949324&r2=949325&view=diff
==============================================================================
--- myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIForm.java (original)
+++ myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIForm.java Sat May 29 00:38:36 2010
@@ -52,47 +52,80 @@ public class UIForm
public void processDecodes(javax.faces.context.FacesContext context)
{
- if (context == null) throw new NullPointerException("context");
- decode(context);
- if (!isSubmitted()) return;
- for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
+ if (context == null)
{
- UIComponent childOrFacet = (UIComponent)it.next();
- childOrFacet.processDecodes(context);
+ throw new NullPointerException("context");
+ }
+ try
+ {
+ setCachedFacesContext(context);
+ decode(context);
+ if (!isSubmitted()) return;
+ for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
+ {
+ UIComponent childOrFacet = (UIComponent)it.next();
+ childOrFacet.processDecodes(context);
+ }
+ }
+ finally
+ {
+ setCachedFacesContext(null);
}
}
public void processValidators(javax.faces.context.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 (context == null)
+ {
+ throw new NullPointerException("context");
}
- if (!isSubmitted()) return;
- for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
+ try
{
- UIComponent childOrFacet = (UIComponent)it.next();
- childOrFacet.processValidators(context);
+ setCachedFacesContext(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 it = getFacetsAndChildren(); it.hasNext(); )
+ {
+ UIComponent childOrFacet = (UIComponent)it.next();
+ childOrFacet.processValidators(context);
+ }
+ }
+ finally
+ {
+ setCachedFacesContext(null);
}
}
public void processUpdates(javax.faces.context.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 (context == null)
+ {
+ throw new NullPointerException("context");
+ }
+ try
+ {
+ setCachedFacesContext(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 it = getFacetsAndChildren(); it.hasNext(); )
+ {
+ UIComponent childOrFacet = (UIComponent)it.next();
+ childOrFacet.processUpdates(context);
+ }
}
- if (!isSubmitted()) return;
- for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
+ finally
{
- UIComponent childOrFacet = (UIComponent)it.next();
- childOrFacet.processUpdates(context);
+ setCachedFacesContext(null);
}
}
Modified: myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIInput.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIInput.java?rev=949325&r1=949324&r2=949325&view=diff
==============================================================================
--- myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIInput.java (original)
+++ myfaces/core/branches/1.1.x/api/src/main/java/javax/faces/component/UIInput.java Sat May 29 00:38:36 2010
@@ -210,39 +210,122 @@ public class UIInput extends UIOutput im
*/
public void processDecodes(FacesContext context)
{
- if (context == null) throw new NullPointerException("context");
- if (!isRendered()) return;
+ if (context == null)
+ {
+ throw new NullPointerException("context");
+ }
+ try
+ {
+ setCachedFacesContext(context);
+ if (!isRendered())
+ {
+ return;
+ }
+ }
+ finally
+ {
+ setCachedFacesContext(null);
+ }
super.processDecodes(context);
- if (isImmediate())
+ try
{
- try
+ setCachedFacesContext(context);
+ if (isImmediate())
{
- validate(context);
+ try
+ {
+ validate(context);
+ }
+ catch (RuntimeException e)
+ {
+ context.renderResponse();
+ throw e;
+ }
+ if (!isValid())
+ {
+ context.renderResponse();
+ }
}
- catch (RuntimeException e)
+ }
+ finally
+ {
+ setCachedFacesContext(null);
+ }
+ }
+
+ public void processValidators(FacesContext context)
+ {
+ if (context == null)
+ {
+ throw new NullPointerException("context");
+ }
+ try
+ {
+ setCachedFacesContext(context);
+ if (!isRendered())
{
- context.renderResponse();
- throw e;
+ return;
}
- if (!isValid())
+ }
+ finally
+ {
+ setCachedFacesContext(null);
+ }
+
+ super.processValidators(context);
+
+ try
+ {
+ setCachedFacesContext(context);
+ if (!isImmediate())
{
- context.renderResponse();
+ try
+ {
+ validate(context);
+ }
+ catch (RuntimeException e)
+ {
+ context.renderResponse();
+ throw e;
+ }
+ if (!isValid())
+ {
+ context.renderResponse();
+ }
}
}
+ finally
+ {
+ setCachedFacesContext(null);
+ }
}
- public void processValidators(FacesContext context)
+ public void processUpdates(FacesContext context)
{
- if (context == null) throw new NullPointerException("context");
- if (!isRendered()) return;
-
- super.processValidators(context);
+ if (context == null)
+ {
+ throw new NullPointerException("context");
+ }
+ try
+ {
+ setCachedFacesContext(context);
+ if (!isRendered())
+ {
+ return;
+ }
+ }
+ finally
+ {
+ setCachedFacesContext(null);
+ }
+ super.processUpdates(context);
- if (!isImmediate())
+ try
{
+ setCachedFacesContext(context);
try
{
- validate(context);
+ updateModel(context);
}
catch (RuntimeException e)
{
@@ -254,27 +337,9 @@ public class UIInput extends UIOutput im
context.renderResponse();
}
}
- }
-
- public void processUpdates(FacesContext context)
- {
- if (context == null) throw new NullPointerException("context");
- if (!isRendered()) return;
-
- super.processUpdates(context);
-
- try
- {
- updateModel(context);
- }
- catch (RuntimeException e)
- {
- context.renderResponse();
- throw e;
- }
- if (!isValid())
+ finally
{
- context.renderResponse();
+ setCachedFacesContext(null);
}
}