You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by drf <da...@gmail.com> on 2011/03/02 11:59:16 UTC

Getting an AjaxRequestTarget from within a Form.onSubmit

Wicket extensions contains a ModalWindow object. In order to open it, you
call the show(AjaxRequestTarget) method.

We want to call this from within Form.onSubmit(), the problem is, how do we
get hold of a AjaxRequestTarget object? What can we add to the form that
will give us this capability?

Here is the use case: Wicket adds javascript to the page which calls a
function which calls an activeX object and places the return value from the
activeX call in a field. The function then does a form submit. From the
onSumit we can pick up the value in the field, therefore we know what the
actveX returned. Great. But under some circumstances we then want to open
the dialog. For that we need a AjaxRequestTarget.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Getting-an-AjaxRequestTarget-from-within-a-Form-onSubmit-tp3331336p3331336.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Getting an AjaxRequestTarget from within a Form.onSubmit

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
See

1-http://apache-wicket.1842946.n4.nabble.com/opening-ModalWindow-on-page-load-tt3055618.html#a3056717

Maybe you can override

public void renderHead(IHeaderResponse response)
        {
                response.renderOnDomReadyJavascript(getWindowOpenJavascript());
        }

and only do  response.renderOnDomReadyJavascript(getWindowOpenJavascript());
 under certain conditions...

Ernesto


On Wed, Mar 2, 2011 at 12:22 PM, Ernesto Reinaldo Barreiro
<re...@gmail.com> wrote:
> AFAIK then you can't use AjaxRequestTarget  to make modal window
> visible (as there is no AJAX request). Some time ago I have posted a
> message showing how to create a version of modal window that is open
> on page onload. Make you can come up with a variation of it that can
> be valid for your use-case.
>
> Ernesto
>
> On Wed, Mar 2, 2011 at 12:12 PM, drf <da...@gmail.com> wrote:
>> The form is being submitted by including this line in the javascript
>> function:
>>
>> document.forms[0].submit()
>>
>>
>> --
>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Getting-an-AjaxRequestTarget-from-within-a-Form-onSubmit-tp3331336p3331346.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

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


Re: Getting an AjaxRequestTarget from within a Form.onSubmit

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
AFAIK then you can't use AjaxRequestTarget  to make modal window
visible (as there is no AJAX request). Some time ago I have posted a
message showing how to create a version of modal window that is open
on page onload. Make you can come up with a variation of it that can
be valid for your use-case.

Ernesto

On Wed, Mar 2, 2011 at 12:12 PM, drf <da...@gmail.com> wrote:
> The form is being submitted by including this line in the javascript
> function:
>
> document.forms[0].submit()
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Getting-an-AjaxRequestTarget-from-within-a-Form-onSubmit-tp3331336p3331346.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Getting an AjaxRequestTarget from within a Form.onSubmit

Posted by drf <da...@gmail.com>.
The form is being submitted by including this line in the javascript
function:

document.forms[0].submit()


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Getting-an-AjaxRequestTarget-from-within-a-Form-onSubmit-tp3331336p3331346.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Getting an AjaxRequestTarget from within a Form.onSubmit

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
If form was submitted via AJAX you can always access AjaxRequestTarget
via AjaxRequestTarget.get();

Ernesto

On Wed, Mar 2, 2011 at 11:59 AM, drf <da...@gmail.com> wrote:
> Wicket extensions contains a ModalWindow object. In order to open it, you
> call the show(AjaxRequestTarget) method.
>
> We want to call this from within Form.onSubmit(), the problem is, how do we
> get hold of a AjaxRequestTarget object? What can we add to the form that
> will give us this capability?
>
> Here is the use case: Wicket adds javascript to the page which calls a
> function which calls an activeX object and places the return value from the
> activeX call in a field. The function then does a form submit. From the
> onSumit we can pick up the value in the field, therefore we know what the
> actveX returned. Great. But under some circumstances we then want to open
> the dialog. For that we need a AjaxRequestTarget.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Getting-an-AjaxRequestTarget-from-within-a-Form-onSubmit-tp3331336p3331336.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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