[
https://issues.apache.org/jira/browse/WICKET-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12550134
]
Peter Ertl commented on WICKET-1213:
------------------------------------
I would like to express my suggestion again in different words in the hope that
I could possibly convince you of the benefit.
Everything in this jira issue comes down to three lines:
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#onRequest()
public final void onRequest()
{
(1) AjaxRequestTarget target = new
AjaxRequestTarget(getComponent().getPage());
(2) RequestCycle.get().setRequestTarget(target);
(3) respond(target);
}
I want to provide a way to not only create AjaxRequestTarget but also
subclasses of it. This has to happen before (3) because implementors of
AbstractDefaultAjaxBehavior should be able to use that enhanced/enriched
subclasses of AjaxRequestTarget. These could contain for example additional
ajax effects. Also, it would be possible to call
AjaxRequestTarget#addListener() to decorate the ajax request with some base
functionality (like e.g. auto-focus on error fields or update some basic
components like feedback panels).
Possible approaches would *imho* be:
make (1) call some kind of callback / factory method to create a specific
instance of an ajax target which contains additional methods. Also, listeners
could be bound to the ajax requests in that moment.
make (2) RequestCycle#setRequestTarget() non-final.
> enable subclassing of AjaxRequestTarget
> ---------------------------------------
>
> Key: WICKET-1213
> URL: https://issues.apache.org/jira/browse/WICKET-1213
> Project: Wicket
> Issue Type: Wish
> Components: wicket
> Affects Versions: 1.3.0-rc1
> Reporter: Peter Ertl
> Assignee: Matej Knopp
> Fix For: 1.4.0-alpha
>
> Attachments: AjaxRequestTarget_using_callback_interface.patch,
> AjaxRequestTarget_with_subclassing.patch
>
>
> In my wicket programming experience so far I always didn't feel quite
> comfortable with the ajax part.
> I had some issues in particular with these as an example:
> - "Always include a common feedback panel from my template page"
> --> add 'target.addComponent(feedbackPanel)' just _everywhere_ (very
> cumbersome and not elegant at all)
> - add a listener using AjaxRequestTarget#addListener
> --> not possible without subclassing the request cycle (which is *yuk* if
> you ask me) to catch the short moment in between AjaxRequestTarget is
> instantiated and AjaxRequestTarget#onRespond() is called
> - automatically set focus on the first form component with errors
> --> add bulky code into all onSubmit() and onError() to check for errrors
> and call AjaxRequestTarget#setFocus
> - add some common function like AjaxRequestTarget#yellowFade(FormComponent)
> --> have some utility method and call it like this:
> AjaxUtil.yellowFade(target) -- not nice as functionality like this should
> really belong to the request target
> I found that all these issues can be solved very elegantly if you could just
> catch the moment where AjaxRequestTarget is instantiated.
> I attached a very little patch (!) which solves all that issues and makes
> ajax just a lot more powerful inside wicket *imho*
> also, it will not break current code but is just an enhancement you will not
> notice unless you need it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.