Re: Ajax based filling of form

2009-08-13 Thread Linda van der Pal

Awesome! Thanks for the help.

Regards,
Linda

John Krasnay wrote:

The problem is the CompoundPropertyModel continues to point to the
original Book object. You would have to get rid of the
CompoundPropertyModel and give each FormComponent its own model that is
tolerant to changes to the book member. Something like this would work:

add(new TextField("title", new PropertyModel(this, "book.title")));

jk

On Thu, Aug 13, 2009 at 09:15:50AM +0200, Linda van der Pal wrote:
  

Well the model doesn't update. (Not that I'd expect it to.)

Here's some pieces of my code I deem relevant to the problem.


if (key == null || key.getIsbn() == null) {
   book = new Book();
} else {
   book = bookRetriever.getBook(key.getIsbn(), key.getCollectionId());
}   


setDefaultModel(new CompoundPropertyModel(book));

// ...

isbnField.add(new AjaxFormComponentUpdatingBehavior("onchange") {
   private static final long serialVersionUID = 1L;

   @Override
   protected void onUpdate(final AjaxRequestTarget target) {
   try {
   book = bookRetriever.getBook(isbnField.getInput());
   modelChanged();
  
   target.addComponent(titleField);

   //...
   target.addComponent(genrefield);
   } catch (SQLException e) {
   //...
   }
   }
});

John Krasnay wrote:


Sounds like you're on the right track. What's the problem?

jk

On Wed, Aug 12, 2009 at 04:27:41PM +0200, Linda van der Pal wrote:
 
  
I have a panel with a form. This form has several fields, one of which 
is the ISBN of a book. The fields are filled by a CompoundPropertyModel 
if the user is editing his previous entry, and they are empty if the 
user is adding a new book. Simply entering data or updating it and then 
submitting already works. But now I want to fetch the data for the other 
fields if the ISBN is already in the database. It is a multi-user 
system, so it is in fact possible that the ISBN is already in there.


I was thinking of achieving this with AJAX, but I'm not really sure how 
to do it. I was thinking of adding an AjaxFormComponentUpdatingBeavior, 
where all the related fields are added to the target. But as the ISBN is 
part of the model, I don't really now how to get this working. Any hints 
on what direction I should be searching in?


Regards,
Linda

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

   


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




No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.392 / Virus Database: 270.13.53/2299 - Release Date: 08/12/09 
18:12:00


 
  

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




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




No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.392 / Virus Database: 270.13.54/2300 - Release Date: 08/13/09 06:11:00


  



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



RE: Ajax based filling of form

2009-08-13 Thread Russell Simpkins

I believe this is a variable reference issue.
// instead of this
isbnField.add(new AjaxFormComponentUpdatingBehavior("onchange") {...@override
protected void onUpdate(final AjaxRequestTarget target) {try {book = 
bookRetriever.getBook(isbnField.getInput());
// try this@overrideprotected void onUpdate(final AjaxRequestTarget target) 
{try {book = bookRetriever.getBook(isbnField.getInput());setDefaultModel(new 
CompoundPropertyModel(book));modelChanged();
When you passed in book to the constructor, it now has a reference to your book 
object, when you execute this line:
book = bookRetriever.getBook(isbnField.getInput());

you are only changing the value of the variable book, but not the reference 
stored in new CompoundPropertyModel(book). You should be able pull that 
off in C++ by changing the value of the pointer, but you can't do that in java.
It is similar to this short code
String y = "example";java.util.HashMap h = new 
java.util.HashMap();h.put("y",y);// changing the value of y y="not you";// see 
that the value of y is not the same as the reference we stored in the 
hashmapSystem.out.println(h.get("y"));System.out.println(y);
I hope that helps.

Russ
> Date: Thu, 13 Aug 2009 09:15:50 +0200
> From: lvd...@heritageagenturen.nl
> To: users@wicket.apache.org
> Subject: Re: Ajax based filling of form
> 
> Well the model doesn't update. (Not that I'd expect it to.)
> 
> Here's some pieces of my code I deem relevant to the problem.
> 
> 
> if (key == null || key.getIsbn() == null) {
> book = new Book();
> } else {
> book = bookRetriever.getBook(key.getIsbn(), key.getCollectionId());
> }   
> 
> setDefaultModel(new CompoundPropertyModel(book));
> 
> // ...
> 
> isbnField.add(new AjaxFormComponentUpdatingBehavior("onchange") {
> private static final long serialVersionUID = 1L;
> 
> @Override
> protected void onUpdate(final AjaxRequestTarget target) {
> try {
> book = bookRetriever.getBook(isbnField.getInput());
> modelChanged();
>
> target.addComponent(titleField);
> //...
> target.addComponent(genrefield);
> } catch (SQLException e) {
> //...
> }
> }
> });
> 
> John Krasnay wrote:
> > Sounds like you're on the right track. What's the problem?
> >
> > jk
> >
> > On Wed, Aug 12, 2009 at 04:27:41PM +0200, Linda van der Pal wrote:
> >   
> >> I have a panel with a form. This form has several fields, one of which 
> >> is the ISBN of a book. The fields are filled by a CompoundPropertyModel 
> >> if the user is editing his previous entry, and they are empty if the 
> >> user is adding a new book. Simply entering data or updating it and then 
> >> submitting already works. But now I want to fetch the data for the other 
> >> fields if the ISBN is already in the database. It is a multi-user 
> >> system, so it is in fact possible that the ISBN is already in there.
> >>
> >> I was thinking of achieving this with AJAX, but I'm not really sure how 
> >> to do it. I was thinking of adding an AjaxFormComponentUpdatingBeavior, 
> >> where all the related fields are added to the target. But as the ISBN is 
> >> part of the model, I don't really now how to get this working. Any hints 
> >> on what direction I should be searching in?
> >>
> >> Regards,
> >> Linda
> >>
> >> -
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >> 
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >   
> > 
> >
> >
> > No virus found in this incoming message.
> > Checked by AVG - www.avg.com 
> > Version: 8.5.392 / Virus Database: 270.13.53/2299 - Release Date: 08/12/09 
> > 18:12:00
> >
> >   
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 

_
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1

Re: Ajax based filling of form

2009-08-13 Thread John Krasnay
The problem is the CompoundPropertyModel continues to point to the
original Book object. You would have to get rid of the
CompoundPropertyModel and give each FormComponent its own model that is
tolerant to changes to the book member. Something like this would work:

add(new TextField("title", new PropertyModel(this, "book.title")));

jk

On Thu, Aug 13, 2009 at 09:15:50AM +0200, Linda van der Pal wrote:
> Well the model doesn't update. (Not that I'd expect it to.)
> 
> Here's some pieces of my code I deem relevant to the problem.
> 
> 
> if (key == null || key.getIsbn() == null) {
>book = new Book();
> } else {
>book = bookRetriever.getBook(key.getIsbn(), key.getCollectionId());
> }   
> 
> setDefaultModel(new CompoundPropertyModel(book));
> 
> // ...
> 
> isbnField.add(new AjaxFormComponentUpdatingBehavior("onchange") {
>private static final long serialVersionUID = 1L;
> 
>@Override
>protected void onUpdate(final AjaxRequestTarget target) {
>try {
>book = bookRetriever.getBook(isbnField.getInput());
>modelChanged();
>   
>target.addComponent(titleField);
>//...
>target.addComponent(genrefield);
>} catch (SQLException e) {
>//...
>}
>}
> });
> 
> John Krasnay wrote:
> >Sounds like you're on the right track. What's the problem?
> >
> >jk
> >
> >On Wed, Aug 12, 2009 at 04:27:41PM +0200, Linda van der Pal wrote:
> >  
> >>I have a panel with a form. This form has several fields, one of which 
> >>is the ISBN of a book. The fields are filled by a CompoundPropertyModel 
> >>if the user is editing his previous entry, and they are empty if the 
> >>user is adding a new book. Simply entering data or updating it and then 
> >>submitting already works. But now I want to fetch the data for the other 
> >>fields if the ISBN is already in the database. It is a multi-user 
> >>system, so it is in fact possible that the ISBN is already in there.
> >>
> >>I was thinking of achieving this with AJAX, but I'm not really sure how 
> >>to do it. I was thinking of adding an AjaxFormComponentUpdatingBeavior, 
> >>where all the related fields are added to the target. But as the ISBN is 
> >>part of the model, I don't really now how to get this working. Any hints 
> >>on what direction I should be searching in?
> >>
> >>Regards,
> >>Linda
> >>
> >>-
> >>To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >>
> >
> >-
> >To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >For additional commands, e-mail: users-h...@wicket.apache.org
> >  
> >
> >
> >
> >No virus found in this incoming message.
> >Checked by AVG - www.avg.com 
> >Version: 8.5.392 / Virus Database: 270.13.53/2299 - Release Date: 08/12/09 
> >18:12:00
> >
> >  
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 

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



Re: Ajax based filling of form

2009-08-13 Thread Linda van der Pal

Well the model doesn't update. (Not that I'd expect it to.)

Here's some pieces of my code I deem relevant to the problem.


if (key == null || key.getIsbn() == null) {
   book = new Book();
} else {
   book = bookRetriever.getBook(key.getIsbn(), key.getCollectionId());
}   


setDefaultModel(new CompoundPropertyModel(book));

// ...

isbnField.add(new AjaxFormComponentUpdatingBehavior("onchange") {
   private static final long serialVersionUID = 1L;

   @Override
   protected void onUpdate(final AjaxRequestTarget target) {
   try {
   book = bookRetriever.getBook(isbnField.getInput());
   modelChanged();
  
   target.addComponent(titleField);

   //...
   target.addComponent(genrefield);
   } catch (SQLException e) {
   //...
   }
   }
});

John Krasnay wrote:

Sounds like you're on the right track. What's the problem?

jk

On Wed, Aug 12, 2009 at 04:27:41PM +0200, Linda van der Pal wrote:
  
I have a panel with a form. This form has several fields, one of which 
is the ISBN of a book. The fields are filled by a CompoundPropertyModel 
if the user is editing his previous entry, and they are empty if the 
user is adding a new book. Simply entering data or updating it and then 
submitting already works. But now I want to fetch the data for the other 
fields if the ISBN is already in the database. It is a multi-user 
system, so it is in fact possible that the ISBN is already in there.


I was thinking of achieving this with AJAX, but I'm not really sure how 
to do it. I was thinking of adding an AjaxFormComponentUpdatingBeavior, 
where all the related fields are added to the target. But as the ISBN is 
part of the model, I don't really now how to get this working. Any hints 
on what direction I should be searching in?


Regards,
Linda

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




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




No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.392 / Virus Database: 270.13.53/2299 - Release Date: 08/12/09 18:12:00


  



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



RE: Ajax based filling of form

2009-08-12 Thread Russell Simpkins

All,
I'm still green with Wicket and even greener on Facebook, so I had a hard time 
adding Facebook connect to my wicket app. I think this is due in large part to 
Facebook changing so often. Any ways, I have written up a new page for anyone 
else trying to do Facebook connect with Wicket. If I get some more time I would 
like to come up with a quick start, for now the wiki entry is all I had time to 
squeeze in.
http://cwiki.apache.org/confluence/display/WICKET/Adding+Facebook+connect


Russ
_
Windows Liveā„¢: Keep your life in sync.
http://windowslive.com/explore?ocid=PID23384::T:WLMTAGL:ON:WL:en-US:NF_BR_sync:082009

Re: Ajax based filling of form

2009-08-12 Thread John Krasnay
Sounds like you're on the right track. What's the problem?

jk

On Wed, Aug 12, 2009 at 04:27:41PM +0200, Linda van der Pal wrote:
> I have a panel with a form. This form has several fields, one of which 
> is the ISBN of a book. The fields are filled by a CompoundPropertyModel 
> if the user is editing his previous entry, and they are empty if the 
> user is adding a new book. Simply entering data or updating it and then 
> submitting already works. But now I want to fetch the data for the other 
> fields if the ISBN is already in the database. It is a multi-user 
> system, so it is in fact possible that the ISBN is already in there.
> 
> I was thinking of achieving this with AJAX, but I'm not really sure how 
> to do it. I was thinking of adding an AjaxFormComponentUpdatingBeavior, 
> where all the related fields are added to the target. But as the ISBN is 
> part of the model, I don't really now how to get this working. Any hints 
> on what direction I should be searching in?
> 
> Regards,
> Linda
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 

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



Ajax based filling of form

2009-08-12 Thread Linda van der Pal
I have a panel with a form. This form has several fields, one of which 
is the ISBN of a book. The fields are filled by a CompoundPropertyModel 
if the user is editing his previous entry, and they are empty if the 
user is adding a new book. Simply entering data or updating it and then 
submitting already works. But now I want to fetch the data for the other 
fields if the ISBN is already in the database. It is a multi-user 
system, so it is in fact possible that the ISBN is already in there.


I was thinking of achieving this with AJAX, but I'm not really sure how 
to do it. I was thinking of adding an AjaxFormComponentUpdatingBeavior, 
where all the related fields are added to the target. But as the ISBN is 
part of the model, I don't really now how to get this working. Any hints 
on what direction I should be searching in?


Regards,
Linda

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