I though more something like this:
AjaxLink link = new AjaxLink("copyAddress"){
@Override
public void onClick(AjaxRequestTarget target) {
this.address2 = this.address1;
target.addComponent(myAddress2);
}
};//end of Link
wouldn't that work?
Eyal Golan
[email protected]
Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74
P Save a tree. Please don't print this e-mail unless it's really necessary
On Mon, Jun 1, 2009 at 5:31 PM, hill180 <[email protected]> wrote:
> AjaxLink link = new AjaxLink("copyAddress"){
>
>
> @Override
> public void onClick(AjaxRequestTarget target) {
> myAddress2.setModelObject(myAddress1.getValue());
> target.addComponent(myAddress2);
> }
> };//end of Link
>
>
> This kinda works. It does update the MyAddress2 Field, but if I change
> myAddress1 and click on the click, it will get the original value of
> myAddress1, not the value inside of the forms textfield.
>
>
> -jose
>
>
> On Jun 1, 2009, at 1:48 AM, Eyal Golan wrote:
>
> I'm not sure, but give it a try:
>> In the onClick, set the property address2 to be the same as property
>> address1.
>> Add myAddress2 to the target.
>>
>> If you use compoundpropertymodel, it should work.
>>
>> Eyal Golan
>> [email protected]
>>
>> Visit: http://jvdrums.sourceforge.net/
>> LinkedIn: http://www.linkedin.com/in/egolan74
>>
>> P Save a tree. Please don't print this e-mail unless it's really
>> necessary
>>
>>
>> On Mon, Jun 1, 2009 at 12:55 AM, hill180 <[email protected]> wrote:
>>
>> I have looked through the archives and there were a couple references to
>>> this question but no examples and I was hoping for some help.
>>>
>>> I have a form with Address One and Address Two,
>>>
>>> I have a link that I just want to copy the data over. I am thinking it
>>> should use Javascript, but I am new to wicket and not sure how to
>>> implement.
>>>
>>> The textfields are a compound property model which is hitting a hibernate
>>> POJO.
>>>
>>>
>>> private static class AddressPanel extends Panel
>>> {
>>>
>>> public AddressPanel(String id, Form f,final AssociateDB a)
>>> {
>>> super(id);
>>> final TextField myAddress1 = new TextField("Address1"); //
>>> First Address
>>> add(myAddress1);
>>> final TextField myAddress2 = new TextField("Address2"); //
>>> First Address
>>> myAddress2.setOutputMarkupId(true);
>>> add(myAddress2);
>>>
>>>
>>> Link link = new Link("copyAddress"){
>>> @Override
>>> //TODO ADD JAVASCRIPT COPY, FAILS TO SAVE BEFORE COPY OF DATA
>>> public void onClick() {
>>>
>>> }
>>>
>>> };
>>>
>>>
>>>
>>> add(link);
>>> }
>>>
>>> };
>>>
>>> ---------------------------------------------------------------------
>>> 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]
>
>