You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2010/08/18 03:06:38 UTC
svn commit: r986543 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/corelib/components/
main/java/org/apache/tapestry5/internal/services/
main/java/org/apache/tapestry5/services/
test/java/org/apache/tapestry5/internal/...
Author: hlship
Date: Wed Aug 18 01:06:37 2010
New Revision: 986543
URL: http://svn.apache.org/viewvc?rev=986543&view=rev
Log:
TAP5-1235: The interaction between a Form component and the active page can be problematic when there is an error loading a page
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentSourceImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentSource.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentSourceImplTest.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java?rev=986543&r1=986542&r2=986543&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java Wed Aug 18 01:06:37 2010
@@ -378,8 +378,8 @@ public class Form implements ClientEleme
if (autofocus)
{
- ValidationDecorator autofocusDecorator = new AutofocusValidationDecorator(environment
- .peek(ValidationDecorator.class), activeTracker, renderSupport);
+ ValidationDecorator autofocusDecorator = new AutofocusValidationDecorator(
+ environment.peek(ValidationDecorator.class), activeTracker, renderSupport);
environment.push(ValidationDecorator.class, autofocusDecorator);
}
@@ -712,9 +712,27 @@ public class Form implements ClientEleme
idAllocator.allocateId(name);
}
- ComponentResources activePageResources = componentSource.getActivePage().getComponentResources();
+ Component activePage = componentSource.getActivePage();
- activePageResources.triggerEvent(EventConstants.PREALLOCATE_FORM_CONTROL_NAMES, new Object[]
- { idAllocator }, null);
+ // This is unlikely but may be possible if people override some of the standard
+ // exception reporting logic.
+
+ if (activePage == null)
+ return;
+
+ ComponentResources activePageResources = activePage.getComponentResources();
+
+ try
+ {
+
+ activePageResources.triggerEvent(EventConstants.PREALLOCATE_FORM_CONTROL_NAMES, new Object[]
+ { idAllocator }, null);
+ }
+ catch (RuntimeException ex)
+ {
+ logger.error(
+ String.format("Unable to obtrain form control names to preallocate: %s",
+ InternalUtils.toMessage(ex)), ex);
+ }
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentSourceImpl.java?rev=986543&r1=986542&r2=986543&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentSourceImpl.java Wed Aug 18 01:06:37 2010
@@ -98,10 +98,7 @@ public class ComponentSourceImpl impleme
{
String pageName = globals.getActivePageName();
- if (pageName == null)
- throw new RuntimeException("The identity of the active page for this request has not yet been established.");
-
- return getPage(pageName);
+ return pageName == null ? null : getPage(pageName);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentSource.java?rev=986543&r1=986542&r2=986543&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentSource.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentSource.java Wed Aug 18 01:06:37 2010
@@ -66,9 +66,7 @@ public interface ComponentSource
* the request.
* The identity of the active page is not known until the correct {@link Dispatcher} determines this.
*
- * @return the active page
- * @throws RuntimeException
- * if the active page is not yet known
+ * @return the active page, or null if no active page is yet identified
* @since 5.2.0
*/
Component getActivePage();
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentSourceImplTest.java?rev=986543&r1=986542&r2=986543&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentSourceImplTest.java Wed Aug 18 01:06:37 2010
@@ -151,15 +151,7 @@ public class ComponentSourceImplTest ext
ComponentSource source = new ComponentSourceImpl(null, null, globals);
- try
- {
- source.getActivePage();
- unreachable();
- }
- catch (RuntimeException ex)
- {
- assertMessageContains(ex, "active page", "not yet been established");
- }
+ assertNull(source.getActivePage());
verify();