You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by William Speirs <ws...@apache.org> on 2012/12/13 03:50:50 UTC

FormComponentPanel & onchange Events

I've created a FormComponentPanel with 2 text boxes: A & B. I've add this
new FormComponentPanel to my page twice: 1 & 2. What I'd like to have
happen is when I change the value of 1A I want that same value copied into
2A.

I call setOutputMarkupId to true on 1A, 1B, 2A, and 2B. I setup
an AjaxEventBehavior on panel 1 and it fires as expected. However, inside
of the onEvent method all of the model instances I try to obtain are always
null (therefore preventing me from setting 2A). I've tried getting the
form's model object, the model object for panel 1, and even the model
object for A1... everything is always null.

Is there some method of FormComponentPanel that I'm not overriding that I
need to be? Any thoughts on how to make this work?

Thanks...

Bill-

RE: FormComponentPanel & onchange Events

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
The model objects are only updated after form submission and submission
will only happen if successful validation has occurred.

If you are expecting to copy values from one field to another without
performing form submission then you can't extract the values from the
model objects.

I think what you might be looking for is the String getRawInput() method
on FormComponent which *I believe* returns the value that is currently
in the TextField.

>-----Original Message-----
>From: William Speirs [mailto:wspeirs@apache.org]
>Sent: Thursday, 13 December 2012 1:51 PM
>To: users
>Subject: FormComponentPanel & onchange Events
>
>I've created a FormComponentPanel with 2 text boxes: A & B. I've add
this
>new FormComponentPanel to my page twice: 1 & 2. What I'd like to have
>happen is when I change the value of 1A I want that same value copied
into
>2A.
>
>I call setOutputMarkupId to true on 1A, 1B, 2A, and 2B. I setup
>an AjaxEventBehavior on panel 1 and it fires as expected. However,
inside
>of the onEvent method all of the model instances I try to obtain are
always
>null (therefore preventing me from setting 2A). I've tried getting the
>form's model object, the model object for panel 1, and even the model
>object for A1... everything is always null.
>
>Is there some method of FormComponentPanel that I'm not overriding that
I
>need to be? Any thoughts on how to make this work?
>
>Thanks...
>
>Bill-

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


Re: FormComponentPanel & onchange Events

Posted by William Speirs <ws...@apache.org>.
I finally got some time to test a few combinations:

- onchange for panel, getRawInput() = null
- onblur for panel = event never fires

- onchange for field, getRawInput() = null
- onchange for field, getModelObject() = null

- same combinations as above but with AjaxFormComponentUpdatingBehavior;
always null

So just about all combinations still seem to only return null :-(

I put the code for my FormComponentPanel up on pastebin:
http://pastebin.com/AMvYbv2B

Any insight would be great.

Thanks...

Bill-


On Wed, Dec 12, 2012 at 10:57 PM, Colin Rogers <
Colin.Rogers@objectconsulting.com.au> wrote:

> William,
>
> Is the AjaxEventBehavior added to the panel or the component? What event
> is it fired on?
>
> I'd thought you'd need it to be added to the component (rather than panel)
> and say, triggered 'onblur'. And using a AjaxFormComponentUpdatingBehavior
> rather than AjaxEventBehavior?
>
> Can you post the non-working code up if those suggestions don't solve it?
> I'd be happy to have a look at it.
>
> Cheers,
> Col.
>
> -----Original Message-----
> From: William Speirs [mailto:wspeirs@apache.org]
> Sent: Thursday, 13 December 2012 1:51 PM
> To: users
> Subject: FormComponentPanel & onchange Events
>
> I've created a FormComponentPanel with 2 text boxes: A & B. I've add this
> new FormComponentPanel to my page twice: 1 & 2. What I'd like to have
> happen is when I change the value of 1A I want that same value copied into
> 2A.
>
> I call setOutputMarkupId to true on 1A, 1B, 2A, and 2B. I setup an
> AjaxEventBehavior on panel 1 and it fires as expected. However, inside of
> the onEvent method all of the model instances I try to obtain are always
> null (therefore preventing me from setting 2A). I've tried getting the
> form's model object, the model object for panel 1, and even the model
> object for A1... everything is always null.
>
> Is there some method of FormComponentPanel that I'm not overriding that I
> need to be? Any thoughts on how to make this work?
>
> Thanks...
>
> Bill-
> EMAIL DISCLAIMER This email message and its attachments are confidential
> and may also contain copyright or privileged material. If you are not the
> intended recipient, you may not forward the email or disclose or use the
> information contained in it. If you have received this email message in
> error, please advise the sender immediately by replying to this email and
> delete the message and any associated attachments. Any views, opinions,
> conclusions, advice or statements expressed in this email message are those
> of the individual sender and should not be relied upon as the considered
> view, opinion, conclusions, advice or statement of this company except
> where the sender expressly, and with authority, states them to be the
> considered view, opinion, conclusions, advice or statement of this company.
> Every care is taken but we recommend that you scan any attachments for
> viruses.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: FormComponentPanel & onchange Events

Posted by Colin Rogers <Co...@objectconsulting.com.au>.
William,

Is the AjaxEventBehavior added to the panel or the component? What event is it fired on?

I'd thought you'd need it to be added to the component (rather than panel) and say, triggered 'onblur'. And using a AjaxFormComponentUpdatingBehavior rather than AjaxEventBehavior?

Can you post the non-working code up if those suggestions don't solve it? I'd be happy to have a look at it.

Cheers,
Col.

-----Original Message-----
From: William Speirs [mailto:wspeirs@apache.org]
Sent: Thursday, 13 December 2012 1:51 PM
To: users
Subject: FormComponentPanel & onchange Events

I've created a FormComponentPanel with 2 text boxes: A & B. I've add this new FormComponentPanel to my page twice: 1 & 2. What I'd like to have happen is when I change the value of 1A I want that same value copied into 2A.

I call setOutputMarkupId to true on 1A, 1B, 2A, and 2B. I setup an AjaxEventBehavior on panel 1 and it fires as expected. However, inside of the onEvent method all of the model instances I try to obtain are always null (therefore preventing me from setting 2A). I've tried getting the form's model object, the model object for panel 1, and even the model object for A1... everything is always null.

Is there some method of FormComponentPanel that I'm not overriding that I need to be? Any thoughts on how to make this work?

Thanks...

Bill-
EMAIL DISCLAIMER This email message and its attachments are confidential and may also contain copyright or privileged material. If you are not the intended recipient, you may not forward the email or disclose or use the information contained in it. If you have received this email message in error, please advise the sender immediately by replying to this email and delete the message and any associated attachments. Any views, opinions, conclusions, advice or statements expressed in this email message are those of the individual sender and should not be relied upon as the considered view, opinion, conclusions, advice or statement of this company except where the sender expressly, and with authority, states them to be the considered view, opinion, conclusions, advice or statement of this company. Every care is taken but we recommend that you scan any attachments for viruses.

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