You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Lutz Müller <lu...@combase.de> on 2008/09/05 18:29:53 UTC
AjaxFormComponentUpdatingBehavior("onchange") does not work when added to a FormComponentPanel
Hello all,
I created a Component called TimePanel which is a FormComponentPanel
containing two DropDownChoices. As you may have guessed from the components
name, its used to input time. It is intended to be used with Jodas LocaTime as
a ModelObject. One DDC is for hours, the other one for minutes. It is very
similar to the Time part of the DateTime Input example from WIA.
Now what i want to achieve, is that this Panel can be used with
AjaxFormComponentUpdatingBehavior("onchange") like any non-composite form
component:
timePanel.add(new AjaxFormComponentUpdatingBehavior("onchange")
{
@Override
protected void onUpdate(AjaxRequestTarget target)
{
target.addComponent(getForm());
}
});
I expected problems, mostly because the enclosing div (the panels container)
gets the onchange listener added. but to my surprise, an js event was
generated when i changed the selected value in one of the select elements, and
ultimately my TimePanel's convertInput() Method was called. My convertInput()
looks like this:
@Override
protected void convertInput()
{
Integer hour=m_hourDropDownChoice.getConvertedInput();
Integer minute=m_minuteDropDownChoice.getConvertedInput();
setConvertedInput(new LocalTime(hour,minute));
}
but both DDCs give me nulls as their convertedInput. They dont have any raw
input either. Digging a little further i discovered why: ofcourse the
timePanels, and not the DDCs, inputChanged() and getInputAsArray() methods are
called when the event is triggered. they try to get a value from the request
via the panels id, which of course results in null.
Now my question is: Is there a best practice for what i try to achieve? Or is
there already an AjaxBehaviour which does what i want?
thank you for reading,
lutz
Re: AjaxFormComponentUpdatingBehavior("onchange") does not work when added to a FormComponentPanel
Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Fri, 05 Sep 2008, Lutz Müller wrote:
> I expected problems, mostly because the enclosing div (the panels container)
> gets the onchange listener added. but to my surprise, an js event was
> generated when i changed the selected value in one of the select elements, and
People who know more about DOM and Javascript have told me
that with some luck, some events get propagated up and/or
down the DOM tree on some browsers, so maybe it was that.
> but both DDCs give me nulls as their convertedInput. They dont have any raw
> input either. Digging a little further i discovered why: ofcourse the
> timePanels, and not the DDCs, inputChanged() and getInputAsArray() methods are
> called when the event is triggered. they try to get a value from the request
> via the panels id, which of course results in null.
> Now my question is: Is there a best practice for what i try to achieve? Or is
I think that you need a behavior that submits all the
components of the form, such as AjaxFormSubmittingBehavior
or AjaxFormValidatingBehavior. You can at least look at them
for inspiration and implementation ideas.
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org