Re: AjaxCallListener precondition with user input

2012-11-26 Thread Thomas Heigl
Hey Sekib,

Thanks a lot for your input!

In case anybody has a similar problem, I ended up solving it through an
AjaxCallListener with a little workaround. If the user confirms the alert,
I re-trigger a click on the link with additional data and check for that in
my precondition. This can be used to perform arbitrary async actions in a
listener precondition.

@Override
> public CharSequence getPrecondition(final Component component) {
>
return "if (attrs.event.extraData != 'OK')  { jConfirm(function(r)
> { if (r) { $('#" + component.getMarkupId() + "').trigger('click', 'OK'); }
> }); return false;";

}


Cheers,

Thomas

On Mon, Nov 5, 2012 at 2:35 PM, Sekib_Omazic  wrote:

> If this is an option for you, you could use modal dialog from twitter
> bootstrap (short example can be fond here:
> https://github.com/sekib/twittermodal). I don't use public CharSequence
> getPrecondition(final Component component) at all. Modal dialog is shown
> after clicking the link (no ajax call). Only a click on "Of course" button
> triggers an ajax call.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AjaxCallListener-precondition-with-user-input-tp4653566p4653622.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: AjaxCallListener precondition with user input

2012-11-05 Thread Sekib_Omazic
If this is an option for you, you could use modal dialog from twitter
bootstrap (short example can be fond here:
https://github.com/sekib/twittermodal). I don't use public CharSequence
getPrecondition(final Component component) at all. Modal dialog is shown
after clicking the link (no ajax call). Only a click on "Of course" button
triggers an ajax call.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AjaxCallListener-precondition-with-user-input-tp4653566p4653622.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AjaxCallListener precondition with user input

2012-11-03 Thread Martin Grigorov
Hi,

Please create a quickstart and attach it to Jira.

On Fri, Nov 2, 2012 at 2:26 PM, Thomas Heigl  wrote:
> Hey all,
>
> I'm currently in the progress of migrating a largish Wicket 1.5 app to
> Wicket 6.2. The only major problem I could not resolve so far are
> precondition scripts with user input.
>
> My old code looked like this:
>
>@Override
>> public CharSequence postDecorateScript(Component component, CharSequence
>> script) {
>> return "jConfirm(function(r) { if (r) {" + script + "}});";
>> }
>
>
> The whole script was decorated and the callback only executed if the user
> pressed OK in a custom confirmation dialog.
>
> In Wicket 6, there are no more script decorators, just listeners that
> provide hooks into the ajax lifecycle, so I changed my code to this:
>
>
>  @Override
>> public CharSequence getPrecondition(final Component component) {
>> return "jConfirm(function(r) { if (r) { return true; } }); return false;";
>> }
>
>
> The problem is, that the callback function I'm passing to jConfirm is
> evaluated only when the user makes a selection, but the precondition has to
> return an output immediately. It would work if we used browser-level
> confirmation dialogs, but we use a custom jquery dialog for better user
> experience.
>
> Is there any way to emulate the pre-Wicket 6 behavior using listeners?
>
> Kind regards,
>
> Thomas



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



AjaxCallListener precondition with user input

2012-11-02 Thread Thomas Heigl
Hey all,

I'm currently in the progress of migrating a largish Wicket 1.5 app to
Wicket 6.2. The only major problem I could not resolve so far are
precondition scripts with user input.

My old code looked like this:

   @Override
> public CharSequence postDecorateScript(Component component, CharSequence
> script) {
> return "jConfirm(function(r) { if (r) {" + script + "}});";
> }


The whole script was decorated and the callback only executed if the user
pressed OK in a custom confirmation dialog.

In Wicket 6, there are no more script decorators, just listeners that
provide hooks into the ajax lifecycle, so I changed my code to this:


 @Override
> public CharSequence getPrecondition(final Component component) {
> return "jConfirm(function(r) { if (r) { return true; } }); return false;";
> }


The problem is, that the callback function I'm passing to jConfirm is
evaluated only when the user makes a selection, but the precondition has to
return an output immediately. It would work if we used browser-level
confirmation dialogs, but we use a custom jquery dialog for better user
experience.

Is there any way to emulate the pre-Wicket 6 behavior using listeners?

Kind regards,

Thomas