[
https://issues.apache.org/jira/browse/WICKET-234?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
vincent Demay reopened WICKET-234:
----------------------------------
Thanks to apply the patch quickly
Actually I also need the onAfterRespond() - beacause I had some datas to the
listener during component response.
Sorry to forgot to say it to you yestrerday :(.
So I made an other patch (with an other way to reduce target scope to
appendJavascript only - with exceptions):
What do you think about that?
Index: .
===================================================================
--- . (revision 499700)
+++ . (working copy)
@@ -95,6 +95,17 @@
*
*/
public void onBeforeRespond(Map map, AjaxRequestTarget target);
+
+
+ /**
+ * Triggered after ajax request has added component to the
response
+ * @param map
+ * read-only map:markupId->component of
components already
+ * added to the target
+ * @param target
+ * the target itself. Could be used <b>only to
append javascript</b>
+ */
+ public void onAfterRespond(Map map, AjaxRequestTarget target);
}
/**
@@ -209,6 +220,9 @@
/** a list of listeners */
private List listeners = null;
+
+ /** Used to know if component has already been responded */
+ private boolean respondComponentDone = false;
/**
* Constructor
@@ -275,6 +289,10 @@
*/
public final void addComponent(Component component, String markupId)
{
+ if (respondComponentDone){
+ //component has already been responded
+ throw new IllegalStateException("component can not be
added to the target on onAfterRespond. Only appendJavascript can be used");
+ }
if (Strings.isEmpty(markupId))
{
throw new IllegalArgumentException("markupId cannot be
empty");
@@ -372,6 +390,10 @@
*/
public final void prependJavascript(String javascript)
{
+ if (respondComponentDone){
+ //component has already been responded
+ throw new IllegalStateException("prependJavascript can
not be called on onAfterRespond. Only appendJavascript can be used");
+ }
if (javascript == null)
{
throw new IllegalArgumentException("javascript cannot
be null");
@@ -429,6 +451,22 @@
// process added components
respondComponents(response);
+
+ // flag respond component as done
+ respondComponentDone = true;
+
+ // invoke onbeforerespond event on listeners
+ if (listeners != null)
+ {
+ final Map components =
Collections.unmodifiableMap(markupIdToComponent);
+
+ it = listeners.iterator();
+ while (it.hasNext())
+ {
+
((Listener)it.next()).onAfterRespond(components, this);
+ }
+ }
+
it = appendJavascripts.iterator();
while (it.hasNext())
> [Patch] Adding Listener to AjaxRequestTarget
> --------------------------------------------
>
> Key: WICKET-234
> URL: https://issues.apache.org/jira/browse/WICKET-234
> Project: Wicket
> Issue Type: New Feature
> Affects Versions: 1.3, 2.0
> Reporter: vincent Demay
> Assigned To: Igor Vaynberg
> Fix For: 1.3, 2.0
>
> Attachments: AjaxRequestTargetListener.patch
>
>
> Add Listener to hook some step in AjaxRequestTarget response
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.