You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alexander Elsholz <al...@widas.de> on 2010/01/14 00:35:04 UTC

Ajax and form handling and clearInput

Hi,

i use a drop-down to switch some data in view. replace data in my model-bean
class (pojo wraps different business objects) and repaints the form via ajax-on
change event. (data binded via propertymodel)

some fields are required.

1. all fields are valid, works fine
2. clear one field and try to submit - fails. Model is still valid. cool
3. switch the drop down list. model-object will replaced and the form added to
ajaxtarget. expect to see the model value of new model object
4. fails! the field still is empty. why?

public final String getValue()
{
	if (NO_RAW_INPUT.equals(rawInput))
	{
		return getModelValue();
	}
	else
	{
		if (getEscapeModelStrings() && rawInput != null)
		{
			return Strings.escapeMarkup(rawInput).toString();
		}
		return rawInput;
	}
}

input is empty (cleared field before last button submit) , so the geModelValue
isn't called.

Form#clearInput or FormComponent#clearInput helps, but i think i make a mistake.
i can't imagine that ajax-events on failed forms which switch the model and
repaint the form have to clear the form manually.

wicket 1.3.5

regards alex


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


Re: Ajax and form handling and clearInput

Posted by Alexander Elsholz <al...@widas.de>.
Igor Vaynberg <igor.vaynberg <at> gmail.com> writes:

> 
> this is by design. formcomponents buffer input that is in error so it
> can be redisplayed. you can use either form.clearinput() or for your
> usecase a bit more appropriate form.modelchanged() to notify the model
> that you have changed the backing model object and it should drop any
> buffered state

When I think about it now - you're right. i have to notify the form about
switching their underlying business object

thanks again alex


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


Re: Ajax and form handling and clearInput

Posted by Igor Vaynberg <ig...@gmail.com>.
this is by design. formcomponents buffer input that is in error so it
can be redisplayed. you can use either form.clearinput() or for your
usecase a bit more appropriate form.modelchanged() to notify the model
that you have changed the backing model object and it should drop any
buffered state

-igor

On Wed, Jan 13, 2010 at 3:35 PM, Alexander Elsholz
<al...@widas.de> wrote:
> Hi,
>
> i use a drop-down to switch some data in view. replace data in my model-bean
> class (pojo wraps different business objects) and repaints the form via ajax-on
> change event. (data binded via propertymodel)
>
> some fields are required.
>
> 1. all fields are valid, works fine
> 2. clear one field and try to submit - fails. Model is still valid. cool
> 3. switch the drop down list. model-object will replaced and the form added to
> ajaxtarget. expect to see the model value of new model object
> 4. fails! the field still is empty. why?
>
> public final String getValue()
> {
>        if (NO_RAW_INPUT.equals(rawInput))
>        {
>                return getModelValue();
>        }
>        else
>        {
>                if (getEscapeModelStrings() && rawInput != null)
>                {
>                        return Strings.escapeMarkup(rawInput).toString();
>                }
>                return rawInput;
>        }
> }
>
> input is empty (cleared field before last button submit) , so the geModelValue
> isn't called.
>
> Form#clearInput or FormComponent#clearInput helps, but i think i make a mistake.
> i can't imagine that ajax-events on failed forms which switch the model and
> repaint the form have to clear the form manually.
>
> wicket 1.3.5
>
> regards alex
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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