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:39:49 UTC
svn commit: r949326 - in
/myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component:
UIData.java UIForm.java UIInput.java
Author: lu4242
Date: Sat May 29 00:39:48 2010
New Revision: 949326
URL: http://svn.apache.org/viewvc?rev=949326&view=rev
Log:
MYFACES-2737 Cache FacesContext on UIComponentBase instances
Modified:
myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIData.java
myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIForm.java
myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIInput.java
Modified: myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIData.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIData.java?rev=949326&r1=949325&r2=949326&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIData.java (original)
+++ myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIData.java Sat May 29 00:39:48 2010
@@ -804,7 +804,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/branches/1.2.x/api/src/main/java/javax/faces/component/UIForm.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIForm.java?rev=949326&r1=949325&r2=949326&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIForm.java (original)
+++ myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIForm.java Sat May 29 00:39:48 2010
@@ -56,47 +56,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.2.x/api/src/main/java/javax/faces/component/UIInput.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIInput.java?rev=949326&r1=949325&r2=949326&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIInput.java (original)
+++ myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/component/UIInput.java Sat May 29 00:39:48 2010
@@ -143,27 +143,43 @@ 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())
{
- validate(context);
- }
- catch (RuntimeException e)
- {
- context.renderResponse();
- throw e;
- }
- if (!isValid())
- {
- context.renderResponse();
+ try
+ {
+ validate(context);
+ }
+ catch (RuntimeException e)
+ {
+ context.renderResponse();
+ throw e;
+ }
+ if (!isValid())
+ {
+ context.renderResponse();
+ }
}
}
+ finally
+ {
+ setCachedFacesContext(null);
+ }
}
public void processValidators(FacesContext context)
@@ -172,29 +188,45 @@ public class UIInput extends UIOutput im
{
throw new NullPointerException("context");
}
- if (!isRendered())
+ try
{
- return;
+ setCachedFacesContext(context);
+ if (!isRendered())
+ {
+ return;
+ }
+ }
+ finally
+ {
+ setCachedFacesContext(null);
}
super.processValidators(context);
- if (!isImmediate())
+ try
{
- try
- {
- validate(context);
- }
- catch (RuntimeException e)
- {
- context.renderResponse();
- throw e;
- }
- if (!isValid())
+ 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 processUpdates(FacesContext context)
@@ -203,25 +235,41 @@ public class UIInput extends UIOutput im
{
throw new NullPointerException("context");
}
- if (!isRendered())
+ try
{
- return;
+ setCachedFacesContext(context);
+ if (!isRendered())
+ {
+ return;
+ }
+ }
+ finally
+ {
+ 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);
}
}