Clay,

I am not able to use ajax in this particular case because I have file inputs
on the page, otherwise you are right the solution would be much easier if I
were able to use ajax.

javascript: form.submit() would be what I am looking for except I would like
the wicket side to understand the form was submitted via javascript and
execute an onSubmit that is specific to this type of submission (similar to
how a button has its own onSubmit that is executed with that specific button
is used to submit the form).

It sounds like for now I will have to use a hidden link and trigger its
onClick event.

Ryan

On Dec 11, 2007 5:01 PM, Clay Lehman <[EMAIL PROTECTED]> wrote:

> Are you trying to submit the form from within an ajax event?
> If so you can simply do:
> target.appendJavascript(getForm().getMarkupId()+".submit()");//get the
> markupId for the form and append javascript to submit it
>
> In any case, it seems like form.submit() might do what you are looking
> for?
>
> -Clay
>
> -----Original Message-----
> From: Ryan [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 11, 2007 1:56 PM
> To: users@wicket.apache.org
> Subject: Creating a form submit listener using IBehavior
>
> All,
>
> I have a use case where I would like to submit a form via javascript and
> have wicket map this submission back to a java onSubmit method (using
> wicket
> 1.3-rc1). On the surface this is very similar to adding a SubmitLink,
> hiding
> the submit link markup elements, then using a javascript function to
> trigger
> the onclick handler for that SubmitLink. This approach works however I
> would
> like to find a more elegant solution.. Something that can be added to
> any
> form and not require changes to that form or its markup. Adding a hidden
> link seems hackish.
>
> This lead me to my first attempt which was to create a behavior that is
> added to the form that emulate's SubmitLink.getTriggerJavascript and
> render
> that javascript into a function. This doesn't look like it will work out
> because getTriggerJavascript uses a package private method
> Form.getHiddenFieldId() and also relies on the fact that the SubmitLink
> itself is a component within the Form (I am trying to create a
> behavior). My
> second attempt was to make use of
> Form.getJsForInterfaceUrl(interfaceUrl)
> passing in a url generated using form.urlFor(behavior,
> IBehaviorListener.INTERFACE). I could then use my behavior to add a
> javascript function that executes the javascript from
> Form.getJsForInterfaceUrl(interfaceUrl). This is not working for two
> reasons:
>
> 1) Form.getTriggerJavascript (line 1045 in wicket 1.3-rc1) requires the
> request target to be an instance of ListenerInterfaceRequestTarget (
> IBehaviorListener.INSTANCE is creating a BehaviorRequestTarget).
> 2) requestTarget.getTarget() is returning the form instead of my
> behavior,
> so even if Form.getTriggerJavascript accepted BehaviorRequestTarget it
> would
> not execute my behavior.
>
> Clearly I am missing something about hooking into the submit process for
> a
> form. Could someone that has a better understanding of this area of
> wicket
> point me in the right direction?
>
> Ryan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to