add(new ajaxsubmitlink("submit", form));
-igor
On Thu, Jan 27, 2011 at 7:46 PM, Brown, Berlin [GCG-PFS]
<[email protected]> wrote:
> So, I was able to submit a form WITHOUT ajax. Now, how can I submit a
> form with ajax but from a link not associated with that form. I tried
> the following. But, I couldn't get the proper URLs / Button? Are
> those needed for the wicketSubmFormById call?
>
> Also, do i have an issue using target.appendJavascript(...);
>
> ...
>
> If you look at the event handler method,
>
> public class MyPanel {
>
> public static final String
> JS_SUBMIT_THIS_WORKS_BUT_HOW_TO_SUBMIT_BY_AJAX = "try {
> document.forms['%s'].submit(); } catch(err) { alert('ERR:' + err); if
> (window.console != undefined) { console.log(err); } }";
>
> this.add(new AjaxLink<Object>("link") {
> @Override
> public void onClick(final AjaxRequestTarget target) {
>
> // Find the dynamic form on the page.
> final Object objAtStopTraversal =
> getParentContainer().visitChildren(new FindFormVisitor());
> if (objAtStopTraversal instanceof Form<?>) {
> // Form found, invoke javascript submit
> final Form<?> form = (Form<?>) objAtStopTraversal;
>
>
> target.appendJavascript(getEventHandler(form.getMarkupId(), ???, this));
> }
> }
> } );
>
> protected CharSequence getEventHandler(final String formMarkupId, final
> String inputName, final AbstractLink link) {
> final String formId = formMarkupId;
> final CharSequence url = ????????????????
> AppendingStringBuffer call = new AppendingStringBuffer("var
> wcall=wicketSubmitFormById('")
> .append(formId).append("', '").append(url).append("', ");
>
> call.append("'")
> .append(inputName)
> .append("' ");
> call.append(",function() { }.bind(this),function() {
> }.bind(this), function() { }.bind(this));;; return false;;");
> return call;
> }
>
> Berlin Brown
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]