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

Reply via email to