Bug #31667
AJAX widgets broken when called inside a loop
| Status: | Resolved | Start date: | 2011-11-08 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Sebastian Kurfuerst | % Done: | 100% |
|
| Category: | Widgets | |||
| Target version: | TYPO3 Flow Base Distribution - 1.0.1 | |||
| Has patch: | No | FLOW3 version affected: | FLOW3 1.0.0 | |
| Votes: | 0 |
Description
As ViewHelpers are supposed to be stateless they were create once per
RenderingContext and reused whenever the RenderingContext fits.
Some ViewHelpers are not stateless, e.g. AJAX widgets.
AJAX widgets push their WidgetContext into an AjaxWidgetContextHolder
before they get rendered.
As soon as AJAX-WidgetViewHelpers were used multiple times within the
same RenderingContext (widgets in ForViewHelpers for example) differet
widgets share the same ViewHelper containing the same WidgetContext.
Because the WidgetContext contains all statefull information about a
widget, only the last rendered widget gets stored in the ContextHolder.
That makes equal AJAX widgets within a for-loop impossible because
each GUI representation interacts with only the last rendered PHP object.
Associated revisions
[FEATURE] Widgets: Reset WidgetViewHelpers when being reused from ViewHelperNode
- Introduce an AbstractViewHelper::resetState method to handle any kind
of statefull interaction, empty by default. - Make ViewHelperNode call resetState when reusing a ViewHelper, and also
call it when reusing it in a compiled template. - AbstractWidgetViewHelper implements resetState for creating a new
WidgetContext object.
As ViewHelpers are supposed to be stateless they were create once per
RenderingContext and reused whenever the RenderingContext fits.
Some ViewHelpers are not stateless, e.g. AJAX widgets.
AJAX widgets push their WidgetContext into an AjaxWidgetContextHolder
before they get rendered.
As soon as AJAX-WidgetViewHelpers were used multiple times within the
same RenderingContext (widgets in ForViewHelpers for example) differet
widgets share the same ViewHelper containing the same WidgetContext.
Because the WidgetContext contains all statefull information about a
widget, only the last rendered widget gets stored in the ContextHolder.
That makes equal AJAX widgets within a for-loop impossible because
each GUI representation interacts with only the last rendered PHP object.
A test case has been committed to Viewhelpertest with http://review.typo3.org/6594
Resolves: #31667
Release: 1.0, 1.1
Change-Id: I543fd9771b3c5f9d7b9693980f3b1c17dff28996
[BUGFIX] Reset WidgetViewHelpers when being reused from ViewHelperNode
- Introduce an AbstractViewHelper::resetState method to handle any kind
of stateful interaction, empty by default. - Make ViewHelperNode call resetState when reusing a ViewHelper, and also
call it when reusing it in a compiled template. - AbstractWidgetViewHelper implements resetState for creating a new
WidgetContext object.
As ViewHelpers are supposed to be stateless they were create once per
RenderingContext and reused whenever the RenderingContext fits.
Some ViewHelpers are not stateless, e.g. AJAX widgets.
AJAX widgets push their WidgetContext into an AjaxWidgetContextHolder
before they get rendered.
As soon as AJAX-WidgetViewHelpers were used multiple times within the
same RenderingContext (widgets in ForViewHelpers for example) different
widgets share the same ViewHelper containing the same WidgetContext.
Because the WidgetContext contains all stateful information about a
widget, only the last rendered widget gets stored in the ContextHolder.
That makes equal AJAX widgets within a for-loop impossible because
each GUI representation interacts with only the last rendered PHP object.
A test case has been committed to Viewhelpertest with http://review.typo3.org/6594
Change-Id: I7b0b1779079d4e48399d8db4981f2e6a24ebe536
Fixes: #31667
Release: 1.0, 1.1
History
Updated by Sebastian Kurfuerst over 1 year ago
- Status changed from New to Under Review
Updated by Mr. Hudson over 1 year ago
Patch set 3 of change I543fd9771b3c5f9d7b9693980f3b1c17dff28996 has been pushed to the review server.
It is available at http://review.typo3.org/2602
Updated by Sebastian Kurfuerst over 1 year ago
Please use http://review.typo3.org/6594 for testing
Updated by Mr. Hudson over 1 year ago
Patch set 4 of change I543fd9771b3c5f9d7b9693980f3b1c17dff28996 has been pushed to the review server.
It is available at http://review.typo3.org/2602
Updated by Mr. Hudson over 1 year ago
Patch set 5 of change I543fd9771b3c5f9d7b9693980f3b1c17dff28996 has been pushed to the review server.
It is available at http://review.typo3.org/2602
Updated by Stephan Schuler over 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset e45079412d945aab812a48933ea5c3ff362e0b08.
Updated by Karsten Dambekalns over 1 year ago
- Category set to Widgets
- Assignee set to Sebastian Kurfuerst
- Target version set to 1.0.1