Re: Problem with IFormsubmitting

2009-11-04 Thread Martin Makundi
Hi!

The proposed solution does not work with Modal Windows!!
* http://osdir.com/ml/users-wicket.apache.org/2009-11/msg00076.html

Modal windws have a fake parent form:



.. and ofcourse it does not have a hidden input field...

.. so the solution gets a bit nastier...

.. we must fake the hidden field value into the request ... ?

Is there another less pervasive way to do this? Maybe alter wicket a bit ;) ?

The solution here is implementation specific and probably works with jetty only:


public abstract class
AjaxFormSubmittingChangeListenerDropDownChoice extends
DropDownChoice {
  private final static Method hiddenFieldGetter;
  static {
try {
  hiddenFieldGetter = Form.class.getDeclaredMethod("getHiddenFieldId");
  hiddenFieldGetter.setAccessible(true);
} catch (Exception e) {
  throw new RuntimeException(e);
}
  }

  /** Initialize */ {
add(new AjaxFormSubmitBehavior(JavaScriptConstants.ONCHANGE) {

  @Override
  protected void onError(AjaxRequestTarget target) {
AjaxFormSubmittingChangeListenerDropDownChoice.this.onError(target);
  }

  @Override
  protected void onSubmit(AjaxRequestTarget target) {
AjaxFormSubmittingChangeListenerDropDownChoice.this.onSubmit(target);
  }

  /**
   * @see 
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior#onEvent(org.apache.wicket.ajax.AjaxRequestTarget)
   */
  @Override
  protected void onEvent(AjaxRequestTarget target) {
org.mortbay.util.MultiMap parameters =
((org.mortbay.jetty.Request) ((WebRequest)
getRequest()).getHttpServletRequest()).getParameters();

parameters.put(getHiddenFieldId(AjaxFormSubmittingChangeListenerDropDownChoice.this.getForm()),

AjaxFormSubmittingChangeListenerDropDownChoice.this.urlFor(IOnChangeListener.INTERFACE));
super.onEvent(target);
  }

  /**
   * @param form
   * @return String
   */
  private String getHiddenFieldId(Form form) {
try {
  Form root = form.getRootForm();
  return (String) hiddenFieldGetter.invoke(root);
} catch (Exception e) {
  throw new RuntimeException(e);
}
  }

});
  }
}


**
Martin

> 2009/11/4 Jeremy Thomerson :
>> The power of this list is amazing - it seems you just had an entire thread
>> with yourself and answered your own question.  SYNERGY!  :)
>>
>> But seriously, did you have any remaining questions on this that we could
>> assist with?
>>
>>
>> --
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>

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



Re: Problem with IFormsubmitting

2009-11-03 Thread Martin Makundi
Tnx. I would like to ask (myself?) whether it could be formulated
simply into a behavior that can be attached into any formcomponent.
Probably. I will work on this next.

Ofcourse if more people try the code in their applications we will
soon learn if it breaks something.

**
Martin

2009/11/4 Jeremy Thomerson :
> The power of this list is amazing - it seems you just had an entire thread
> with yourself and answered your own question.  SYNERGY!  :)
>
> But seriously, did you have any remaining questions on this that we could
> assist with?
>
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Tue, Nov 3, 2009 at 12:22 PM, Martin Makundi <
> martin.maku...@koodaripalvelut.com> wrote:
>
>> Hi!
>>
>> One finishing touch is needed. The hidden field should be cleared
>> after ajax submit. It seems to work now.. feel free to critisize.
>>
>> public abstract class FormSubmitAjaxChangeListenerCallDecorator
>> implements IAjaxCallDecorator {
>>  private final static Method hiddenFieldGetter;
>>
>>  static {
>>    try {
>>      hiddenFieldGetter = Form.class.getDeclaredMethod("getHiddenFieldId");
>>      hiddenFieldGetter.setAccessible(true);
>>    } catch (Exception e) {
>>      throw new RuntimeException(e);
>>    }
>>  }
>>  /**
>>   * @see
>> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnFailureScript(java.lang.CharSequence)
>>   */
>>  public CharSequence decorateOnFailureScript(
>>      CharSequence arg0) {
>>     return getSetHiddenFieldValue("").append(arg0);
>>   }
>>
>>  /**
>>   * @see
>> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnSuccessScript(java.lang.CharSequence)
>>   */
>>  public CharSequence decorateOnSuccessScript(
>>      CharSequence arg0) {
>>     return getSetHiddenFieldValue("").append(arg0);
>>   }
>>
>>  /**
>>   * @see
>> org.apache.wicket.ajax.IAjaxCallDecorator#decorateScript(java.lang.CharSequence)
>>   */
>>  public CharSequence decorateScript(CharSequence arg0) {
>>     return getSetHiddenFieldValue(getChangeListenerUrl()).append(arg0);
>>  }
>>
>>  /**
>>   * @param hiddenFieldId
>>   * @param value
>>   * @return
>>   */
>>  private AppendingStringBuffer getSetHiddenFieldValue(CharSequence value) {
>>    try {
>>       Form root = getForm().getRootForm();
>>      String hiddenFieldId;
>>       hiddenFieldId = (String) hiddenFieldGetter.invoke(root);
>>      return new AppendingStringBuffer("document.getElementById('").append(
>>           hiddenFieldId).append("').value='").append(value).append(
>>          "';");
>>     } catch (Exception e) {
>>      throw new RuntimeException(e);
>>    }
>>  }
>>
>>  /**
>>   * @return Form
>>   */
>>  public abstract Form getForm();
>>
>>  /**
>>   * @return CharSequence
>>   */
>>  public abstract CharSequence getChangeListenerUrl();
>> }
>>
>> **
>> Martin
>>
>> 2009/11/3 Martin Makundi :
>> > Hi!
>> >
>> > I hope I found a solution usin IOnChangeListener.
>> >
>> > Please try this out and let me know if it works for you. Maybe it
>> > should be incorporated into Wicket?
>> >
>> > public abstract class FormSubmitAjaxChangeListenerCallDecorator
>> > implements IAjaxCallDecorator {
>> >  private final static Method hiddenFieldGetter;
>> >
>> >  static {
>> >    try {
>> >      hiddenFieldGetter =
>> Form.class.getDeclaredMethod("getHiddenFieldId");
>> >      hiddenFieldGetter.setAccessible(true);
>> >    } catch (Exception e) {
>> >      throw new RuntimeException(e);
>> >    }
>> >  }
>> >  /**
>> >   * @see
>> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnFailureScript(java.lang.CharSequence)
>> >   */
>> >  public CharSequence decorateOnFailureScript(
>> >      CharSequence arg0) {
>> >    return arg0;
>> >  }
>> >
>> >  /**
>> >   * @see
>> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnSuccessScript(java.lang.CharSequence)
>> >   */
>> >  public CharSequence decorateOnSuccessScript(
>> >      CharSequence arg0) {
>> >    return arg0;
>> >  }
>> >
>> >  /**
>> >   * @see
>> org.apache.wicket.ajax.IAjaxCallDecorator#decorateScript(java.lang.CharSequence)
>> >   */
>> >  public CharSequence decorateScript(CharSequence arg0) {
>> >    Form root = getForm().getRootForm();
>> >    String hiddenFieldId;
>> >    try {
>> >      hiddenFieldId = (String) hiddenFieldGetter.invoke(root);
>> >      return new
>> AppendingStringBuffer("document.getElementById('").append(
>> >
>>  hiddenFieldId).append("').value='").append(getChangeListenerUrl()).append(
>> >          "';").append(arg0);
>> >    } catch (Exception e) {
>> >      throw new RuntimeException(e);
>> >    }
>> >  }
>> >
>> >  /**
>> >   * @return Form
>> >   */
>> >  public abstract Form getForm();
>> >
>> >  /**
>> >   * @return CharSequence
>> >   */
>> >  public abstract CharSequence getChangeListenerUrl();
>> > }
>> >
>> >
>> > public abstract class AjaxFormSubmittingChangeListenerCheckBox extends
>> > CheckBox {
>> >  /**
>> >   * @param id
>> >   * @param model
>> >   */
>> >  public AjaxFormSubmittingChangeListenerCheckBox(String id,
>> > IMod

Re: Problem with IFormsubmitting

2009-11-03 Thread Jeremy Thomerson
The power of this list is amazing - it seems you just had an entire thread
with yourself and answered your own question.  SYNERGY!  :)

But seriously, did you have any remaining questions on this that we could
assist with?


--
Jeremy Thomerson
http://www.wickettraining.com



On Tue, Nov 3, 2009 at 12:22 PM, Martin Makundi <
martin.maku...@koodaripalvelut.com> wrote:

> Hi!
>
> One finishing touch is needed. The hidden field should be cleared
> after ajax submit. It seems to work now.. feel free to critisize.
>
> public abstract class FormSubmitAjaxChangeListenerCallDecorator
> implements IAjaxCallDecorator {
>  private final static Method hiddenFieldGetter;
>
>  static {
>try {
>  hiddenFieldGetter = Form.class.getDeclaredMethod("getHiddenFieldId");
>  hiddenFieldGetter.setAccessible(true);
>} catch (Exception e) {
>  throw new RuntimeException(e);
>}
>  }
>  /**
>   * @see
> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnFailureScript(java.lang.CharSequence)
>   */
>  public CharSequence decorateOnFailureScript(
>  CharSequence arg0) {
> return getSetHiddenFieldValue("").append(arg0);
>   }
>
>  /**
>   * @see
> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnSuccessScript(java.lang.CharSequence)
>   */
>  public CharSequence decorateOnSuccessScript(
>  CharSequence arg0) {
> return getSetHiddenFieldValue("").append(arg0);
>   }
>
>  /**
>   * @see
> org.apache.wicket.ajax.IAjaxCallDecorator#decorateScript(java.lang.CharSequence)
>   */
>  public CharSequence decorateScript(CharSequence arg0) {
> return getSetHiddenFieldValue(getChangeListenerUrl()).append(arg0);
>  }
>
>  /**
>   * @param hiddenFieldId
>   * @param value
>   * @return
>   */
>  private AppendingStringBuffer getSetHiddenFieldValue(CharSequence value) {
>try {
>   Form root = getForm().getRootForm();
>  String hiddenFieldId;
>   hiddenFieldId = (String) hiddenFieldGetter.invoke(root);
>  return new AppendingStringBuffer("document.getElementById('").append(
>   hiddenFieldId).append("').value='").append(value).append(
>  "';");
> } catch (Exception e) {
>  throw new RuntimeException(e);
>}
>  }
>
>  /**
>   * @return Form
>   */
>  public abstract Form getForm();
>
>  /**
>   * @return CharSequence
>   */
>  public abstract CharSequence getChangeListenerUrl();
> }
>
> **
> Martin
>
> 2009/11/3 Martin Makundi :
> > Hi!
> >
> > I hope I found a solution usin IOnChangeListener.
> >
> > Please try this out and let me know if it works for you. Maybe it
> > should be incorporated into Wicket?
> >
> > public abstract class FormSubmitAjaxChangeListenerCallDecorator
> > implements IAjaxCallDecorator {
> >  private final static Method hiddenFieldGetter;
> >
> >  static {
> >try {
> >  hiddenFieldGetter =
> Form.class.getDeclaredMethod("getHiddenFieldId");
> >  hiddenFieldGetter.setAccessible(true);
> >} catch (Exception e) {
> >  throw new RuntimeException(e);
> >}
> >  }
> >  /**
> >   * @see
> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnFailureScript(java.lang.CharSequence)
> >   */
> >  public CharSequence decorateOnFailureScript(
> >  CharSequence arg0) {
> >return arg0;
> >  }
> >
> >  /**
> >   * @see
> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnSuccessScript(java.lang.CharSequence)
> >   */
> >  public CharSequence decorateOnSuccessScript(
> >  CharSequence arg0) {
> >return arg0;
> >  }
> >
> >  /**
> >   * @see
> org.apache.wicket.ajax.IAjaxCallDecorator#decorateScript(java.lang.CharSequence)
> >   */
> >  public CharSequence decorateScript(CharSequence arg0) {
> >Form root = getForm().getRootForm();
> >String hiddenFieldId;
> >try {
> >  hiddenFieldId = (String) hiddenFieldGetter.invoke(root);
> >  return new
> AppendingStringBuffer("document.getElementById('").append(
> >
>  hiddenFieldId).append("').value='").append(getChangeListenerUrl()).append(
> >  "';").append(arg0);
> >} catch (Exception e) {
> >  throw new RuntimeException(e);
> >}
> >  }
> >
> >  /**
> >   * @return Form
> >   */
> >  public abstract Form getForm();
> >
> >  /**
> >   * @return CharSequence
> >   */
> >  public abstract CharSequence getChangeListenerUrl();
> > }
> >
> >
> > public abstract class AjaxFormSubmittingChangeListenerCheckBox extends
> > CheckBox {
> >  /**
> >   * @param id
> >   * @param model
> >   */
> >  public AjaxFormSubmittingChangeListenerCheckBox(String id,
> > IModel model) {
> >super(id, model);
> >add(new AjaxFormSubmitBehavior(JavaScriptConstants.ONCHANGE) {
> >  @Override
> >  protected void onError(AjaxRequestTarget target) {
> >AjaxFormSubmittingChangeListenerCheckBox.this.onError(target);
> >  }
> >
> >  @Override
> >  protected void onSubmit(AjaxRequestTarget target) {
> >AjaxFormSubmittingChangeListenerCheckBox.this.onSubmit(target);
> >  }
> >
> >  /**
> >   * @see
> org.apache.wick

Re: Problem with IFormsubmitting

2009-11-03 Thread Martin Makundi
Hi!

One finishing touch is needed. The hidden field should be cleared
after ajax submit. It seems to work now.. feel free to critisize.

public abstract class FormSubmitAjaxChangeListenerCallDecorator
implements IAjaxCallDecorator {
  private final static Method hiddenFieldGetter;

  static {
try {
  hiddenFieldGetter = Form.class.getDeclaredMethod("getHiddenFieldId");
  hiddenFieldGetter.setAccessible(true);
} catch (Exception e) {
  throw new RuntimeException(e);
}
  }
  /**
   * @see 
org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnFailureScript(java.lang.CharSequence)
   */
  public CharSequence decorateOnFailureScript(
  CharSequence arg0) {
return getSetHiddenFieldValue("").append(arg0);
  }

  /**
   * @see 
org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnSuccessScript(java.lang.CharSequence)
   */
  public CharSequence decorateOnSuccessScript(
  CharSequence arg0) {
return getSetHiddenFieldValue("").append(arg0);
  }

  /**
   * @see 
org.apache.wicket.ajax.IAjaxCallDecorator#decorateScript(java.lang.CharSequence)
   */
  public CharSequence decorateScript(CharSequence arg0) {
return getSetHiddenFieldValue(getChangeListenerUrl()).append(arg0);
  }

  /**
   * @param hiddenFieldId
   * @param value
   * @return
   */
  private AppendingStringBuffer getSetHiddenFieldValue(CharSequence value) {
try {
  Form root = getForm().getRootForm();
  String hiddenFieldId;
  hiddenFieldId = (String) hiddenFieldGetter.invoke(root);
  return new AppendingStringBuffer("document.getElementById('").append(
  hiddenFieldId).append("').value='").append(value).append(
  "';");
} catch (Exception e) {
  throw new RuntimeException(e);
}
  }

  /**
   * @return Form
   */
  public abstract Form getForm();

  /**
   * @return CharSequence
   */
  public abstract CharSequence getChangeListenerUrl();
}

**
Martin

2009/11/3 Martin Makundi :
> Hi!
>
> I hope I found a solution usin IOnChangeListener.
>
> Please try this out and let me know if it works for you. Maybe it
> should be incorporated into Wicket?
>
> public abstract class FormSubmitAjaxChangeListenerCallDecorator
> implements IAjaxCallDecorator {
>  private final static Method hiddenFieldGetter;
>
>  static {
>    try {
>      hiddenFieldGetter = Form.class.getDeclaredMethod("getHiddenFieldId");
>      hiddenFieldGetter.setAccessible(true);
>    } catch (Exception e) {
>      throw new RuntimeException(e);
>    }
>  }
>  /**
>   * @see 
> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnFailureScript(java.lang.CharSequence)
>   */
>  public CharSequence decorateOnFailureScript(
>      CharSequence arg0) {
>    return arg0;
>  }
>
>  /**
>   * @see 
> org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnSuccessScript(java.lang.CharSequence)
>   */
>  public CharSequence decorateOnSuccessScript(
>      CharSequence arg0) {
>    return arg0;
>  }
>
>  /**
>   * @see 
> org.apache.wicket.ajax.IAjaxCallDecorator#decorateScript(java.lang.CharSequence)
>   */
>  public CharSequence decorateScript(CharSequence arg0) {
>    Form root = getForm().getRootForm();
>    String hiddenFieldId;
>    try {
>      hiddenFieldId = (String) hiddenFieldGetter.invoke(root);
>      return new AppendingStringBuffer("document.getElementById('").append(
>          
> hiddenFieldId).append("').value='").append(getChangeListenerUrl()).append(
>          "';").append(arg0);
>    } catch (Exception e) {
>      throw new RuntimeException(e);
>    }
>  }
>
>  /**
>   * @return Form
>   */
>  public abstract Form getForm();
>
>  /**
>   * @return CharSequence
>   */
>  public abstract CharSequence getChangeListenerUrl();
> }
>
>
> public abstract class AjaxFormSubmittingChangeListenerCheckBox extends
> CheckBox {
>  /**
>   * @param id
>   * @param model
>   */
>  public AjaxFormSubmittingChangeListenerCheckBox(String id,
> IModel model) {
>    super(id, model);
>    add(new AjaxFormSubmitBehavior(JavaScriptConstants.ONCHANGE) {
>     �...@override
>      protected void onError(AjaxRequestTarget target) {
>        AjaxFormSubmittingChangeListenerCheckBox.this.onError(target);
>      }
>
>     �...@override
>      protected void onSubmit(AjaxRequestTarget target) {
>        AjaxFormSubmittingChangeListenerCheckBox.this.onSubmit(target);
>      }
>
>      /**
>       * @see 
> org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getAjaxCallDecorator()
>       */
>     �...@override
>      protected IAjaxCallDecorator getAjaxCallDecorator() {
>        return new FormSubmitAjaxChangeListenerCallDecorator() {
>         �...@override
>          public CharSequence getChangeListenerUrl() {
>            return urlFor(IOnChangeListener.INTERFACE);
>          }
>
>         �...@override
>          public Form getForm() {
>            return AjaxFormSubmittingChangeListenerCheckBox.this.getForm();
>          }
>
>        };
>      }
>    });
>  }
>
>  /**
>   * @param target
>   */
>  protected abstract void onS

Re: Problem with IFormsubmitting

2009-11-03 Thread Martin Makundi
Hi!

I hope I found a solution usin IOnChangeListener.

Please try this out and let me know if it works for you. Maybe it
should be incorporated into Wicket?

public abstract class FormSubmitAjaxChangeListenerCallDecorator
implements IAjaxCallDecorator {
  private final static Method hiddenFieldGetter;

  static {
try {
  hiddenFieldGetter = Form.class.getDeclaredMethod("getHiddenFieldId");
  hiddenFieldGetter.setAccessible(true);
} catch (Exception e) {
  throw new RuntimeException(e);
}
  }
  /**
   * @see 
org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnFailureScript(java.lang.CharSequence)
   */
  public CharSequence decorateOnFailureScript(
  CharSequence arg0) {
return arg0;
  }

  /**
   * @see 
org.apache.wicket.ajax.IAjaxCallDecorator#decorateOnSuccessScript(java.lang.CharSequence)
   */
  public CharSequence decorateOnSuccessScript(
  CharSequence arg0) {
return arg0;
  }

  /**
   * @see 
org.apache.wicket.ajax.IAjaxCallDecorator#decorateScript(java.lang.CharSequence)
   */
  public CharSequence decorateScript(CharSequence arg0) {
Form root = getForm().getRootForm();
String hiddenFieldId;
try {
  hiddenFieldId = (String) hiddenFieldGetter.invoke(root);
  return new AppendingStringBuffer("document.getElementById('").append(
  
hiddenFieldId).append("').value='").append(getChangeListenerUrl()).append(
  "';").append(arg0);
} catch (Exception e) {
  throw new RuntimeException(e);
}
  }

  /**
   * @return Form
   */
  public abstract Form getForm();

  /**
   * @return CharSequence
   */
  public abstract CharSequence getChangeListenerUrl();
}


public abstract class AjaxFormSubmittingChangeListenerCheckBox extends
CheckBox {
  /**
   * @param id
   * @param model
   */
  public AjaxFormSubmittingChangeListenerCheckBox(String id,
IModel model) {
super(id, model);
add(new AjaxFormSubmitBehavior(JavaScriptConstants.ONCHANGE) {
  @Override
  protected void onError(AjaxRequestTarget target) {
AjaxFormSubmittingChangeListenerCheckBox.this.onError(target);
  }

  @Override
  protected void onSubmit(AjaxRequestTarget target) {
AjaxFormSubmittingChangeListenerCheckBox.this.onSubmit(target);
  }

  /**
   * @see 
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getAjaxCallDecorator()
   */
  @Override
  protected IAjaxCallDecorator getAjaxCallDecorator() {
return new FormSubmitAjaxChangeListenerCallDecorator() {
  @Override
  public CharSequence getChangeListenerUrl() {
return urlFor(IOnChangeListener.INTERFACE);
  }

  @Override
  public Form getForm() {
return AjaxFormSubmittingChangeListenerCheckBox.this.getForm();
  }

};
  }
});
  }

  /**
   * @param target
   */
  protected abstract void onSubmit(AjaxRequestTarget target);

  /**
   * @param target
   */
  protected void onError(AjaxRequestTarget target) {
onSubmit(target);
  }

  /**
   * @param id
   */
  public AjaxFormSubmittingChangeListenerCheckBox(String id) {
this(id, null);
  }
}


2009/11/3 Martin Makundi :
> Hi!
>
> Maybe this is the solution:
>
>                        String url = 
> getRequest().getParameter(getHiddenFieldId());
>                        if (!Strings.isEmpty(url))
>                        {
>                                dispatchEvent(getPage(), url);
>                        }
>
>
> ??
>
> Attach a change listener with ajax form submit?
>
> **
> Martin
>
> 2009/11/3 Martin Makundi :
>> Hi!
>>
>> I need to accomplish the following:
>> 1. receive ajax onchange event from a formcomponent
>> 2. receive "defaultformprocesing=false" style submit
>> 3. repaint an area; I this is why I need the form to be really
>> submitted (=rawinput but not validated).
>>
>> I have built a custom component FormSubmittingDropDownChoice.
>>
>> The problem is that even if I press another submit component (button,
>> for example), the form allways assumes the formSubmitting component to
>> be FormSubmittingDropDownChoice. Why? Because the findSubmittingButton
>> is so simple that if FormSubmittingDropDownChoice has a value, it is
>> the submitting component.
>>
>> Is there a workaround or fix? How could I achieve similar
>> functionality in a working manner? This works well if I click the
>> FormSubmittingDropDownChoice, otherwise it does not :(
>>
>> package com.tustor.wicket.common.reusables.formcomponents;
>>
>> public class FormSubmittingDropDownChoice extends DropDownChoice
>> implements IFormSubmittingComponent {
>>
>>  public FormSubmittingDropDownChoice(String id, various constructor options) 
>> {
>>    super(id, choices, renderer);
>>  }
>>  /**
>>   * @see 
>> org.apache.wicket.markup.html.form.IFormSubmittingComponent#getDefaultFormProcessing()
>>   */
>>  public boolean getDefaultFormProcessing() {
>>    return false;
>>  }
>>
>>  /**
>>   * @see 
>> org.apache.wicket.m

Re: Problem with IFormsubmitting

2009-11-03 Thread Martin Makundi
Hi!

Maybe this is the solution:

String url = 
getRequest().getParameter(getHiddenFieldId());
if (!Strings.isEmpty(url))
{
dispatchEvent(getPage(), url);
}


??

Attach a change listener with ajax form submit?

**
Martin

2009/11/3 Martin Makundi :
> Hi!
>
> I need to accomplish the following:
> 1. receive ajax onchange event from a formcomponent
> 2. receive "defaultformprocesing=false" style submit
> 3. repaint an area; I this is why I need the form to be really
> submitted (=rawinput but not validated).
>
> I have built a custom component FormSubmittingDropDownChoice.
>
> The problem is that even if I press another submit component (button,
> for example), the form allways assumes the formSubmitting component to
> be FormSubmittingDropDownChoice. Why? Because the findSubmittingButton
> is so simple that if FormSubmittingDropDownChoice has a value, it is
> the submitting component.
>
> Is there a workaround or fix? How could I achieve similar
> functionality in a working manner? This works well if I click the
> FormSubmittingDropDownChoice, otherwise it does not :(
>
> package com.tustor.wicket.common.reusables.formcomponents;
>
> public class FormSubmittingDropDownChoice extends DropDownChoice
> implements IFormSubmittingComponent {
>
>  public FormSubmittingDropDownChoice(String id, various constructor options) {
>    super(id, choices, renderer);
>  }
>  /**
>   * @see 
> org.apache.wicket.markup.html.form.IFormSubmittingComponent#getDefaultFormProcessing()
>   */
>  public boolean getDefaultFormProcessing() {
>    return false;
>  }
>
>  /**
>   * @see 
> org.apache.wicket.markup.html.form.IFormSubmittingComponent#onSubmit()
>   */
>  public void onSubmit() {
>    // override
>  }
>
>  /**
>   * wicket-ajax:
>   *
>   * if (submitButton != null) {
>   *   s += Wicket.Form.encode(submitButton) + "=1";
>   * }
>   *
>   * @see org.apache.wicket.markup.html.form.FormComponent#getInputAsArray()
>   */
> �...@override
>  public String[] getInputAsArray() {
>    return MarkupUtils.filterSubmitIndicator(super.getInputAsArray());
>  }
>
>  /**
>   * @see 
> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice#getModelValue()
>   */
> �...@override
>  public String getModelValue() {
>    String value = super.getModelValue();
>    if ("1".equals(value)) {
>      throw new IllegalStateException("1 not supported because of
> javaScript wicket-ajax:submitForm: function(form, submitButton)");
>    }
>    return value;
>  }
> }
>

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



Problem with IFormsubmitting

2009-11-03 Thread Martin Makundi
Hi!

I need to accomplish the following:
1. receive ajax onchange event from a formcomponent
2. receive "defaultformprocesing=false" style submit
3. repaint an area; I this is why I need the form to be really
submitted (=rawinput but not validated).

I have built a custom component FormSubmittingDropDownChoice.

The problem is that even if I press another submit component (button,
for example), the form allways assumes the formSubmitting component to
be FormSubmittingDropDownChoice. Why? Because the findSubmittingButton
is so simple that if FormSubmittingDropDownChoice has a value, it is
the submitting component.

Is there a workaround or fix? How could I achieve similar
functionality in a working manner? This works well if I click the
FormSubmittingDropDownChoice, otherwise it does not :(

package com.tustor.wicket.common.reusables.formcomponents;

public class FormSubmittingDropDownChoice extends DropDownChoice
implements IFormSubmittingComponent {

  public FormSubmittingDropDownChoice(String id, various constructor options) {
super(id, choices, renderer);
  }
  /**
   * @see 
org.apache.wicket.markup.html.form.IFormSubmittingComponent#getDefaultFormProcessing()
   */
  public boolean getDefaultFormProcessing() {
return false;
  }

  /**
   * @see org.apache.wicket.markup.html.form.IFormSubmittingComponent#onSubmit()
   */
  public void onSubmit() {
// override
  }

  /**
   * wicket-ajax:
   *
   * if (submitButton != null) {
   *   s += Wicket.Form.encode(submitButton) + "=1";
   * }
   *
   * @see org.apache.wicket.markup.html.form.FormComponent#getInputAsArray()
   */
  @Override
  public String[] getInputAsArray() {
return MarkupUtils.filterSubmitIndicator(super.getInputAsArray());
  }

  /**
   * @see 
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice#getModelValue()
   */
  @Override
  public String getModelValue() {
String value = super.getModelValue();
if ("1".equals(value)) {
  throw new IllegalStateException("1 not supported because of
javaScript wicket-ajax:submitForm: function(form, submitButton)");
}
return value;
  }
}

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