Actually one must hack even further to reject the "submitButton=1"
value being added at form submit javascript:
/**
* wicket-ajax:
*
* if (submitButton != null) {
* s += Wicket.Form.encode(submitButton) + "=1";
* }
*
* @see org.apache.wicket.markup.html.form.FormComponent#getInputAsArray()
*/
@Override
public String[] getInputAsArray() {
List<String> strings = Arrays.asList(super.getInputAsArray());
strings.remove("1");
return strings.toArray(new String[strings.size()]);
}
/**
* @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;
}
Is there a feature request that would allow a normal component to
implement IFormSubmittingComponent without adding the =1 code?
wicket-ajax:
// Submits a form using ajax.
// This method serializes a form and sends it as POST body.
submitForm: function(form, submitButton) {
var body = function() {
var s = Wicket.Form.serialize(form);
if (submitButton != null) {
s += Wicket.Form.encode(submitButton) + "=1";
}
return s;
}
return this.request.post(body);
},
**
Martin
2009/4/28 Martin Makundi <[email protected]>:
> Ahh, now I know. I just need to make FormSubmittingCheckBox implements
> IFormSubmittingComponent and then checkBox.add(new
> AjaxFormSubmitBehavior("onchange")).
>
> Yippee!
>
> **
> Martin
>
> 2009/2/13 Timo Rantalaiho <[email protected]>:
>> On Fri, 13 Feb 2009, Martin Makundi wrote:
>>> Yes, this is what I am trying to do, but disabling and enabling a
>>> textfield ends up clearing its value too if I use
>>> AjaxFormSumitBehavior. Don't know why.
>>
>> Maybe a conversion error that prohibits updating the model?
>> Though in the case of validation or conversion errors the
>> erroneous input could be preserved... but maybe the Ajax
>> update gets it from the model anyway?
>>
>> 0) raw input
>> 1) convert -> if succeeds, convertedInput
>> 2) validate -> if succeeds, model
>>
>> Do you have a feedback panel on the page?
>>
>> By debugging Form.process() you can probably see easily
>> what's going on.
>>
>>> I feel it is more consistent to use just plain Wicket.
>>
>> In a way, yes, but sometimes purely client-side stuff can be
>> easier purely on the client-side.
>>
>> Best wishes,
>> Timo
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]