Linda,
Without looking at your question very long I noticed that you supply your
component with a static List<Author>.
This means that this list is only retrieved once (at initialization). It
sounds like you want it to be refreshed when other components change their
input. This would mean you need to supply a Model which returns a
List<Author>; That way when you re-render the component through AJAX, it
reloads the list of authors.
Regards,
Bas
----- Original Message -----
From: "Linda van der Pal" <[email protected]>
To: <[email protected]>
Sent: Wednesday, August 19, 2009 4:54 PM
Subject: How do I get my DropDownChoice to refresh the list of choices with
Ajax?
I have a page with a dropdown list on it with authors. If I enter a new
book I want my fields to be filled based on the ISBN. This works just fine.
But now I want those fields to be filled with data I collect from the
internet, meaning that it isn't always already in my database, and therefor
the author might not yet be in the list. I have already decided to save the
new author so I can select it in the list, but the list isn't updated, and
I can't figure out how to get it to update.
Here are some pieces of code I think are relevant:
This is how I create the authorfield:
authorField = new MultiSelectFieldSwitchPanel("authors",
dataRetriever.fetchAuthors(), new PropertyModel(this, "book.authors"));
dataRetriever.fetchAuthors return a List<Author>
Here's the constructor of MultiSelectFieldSwitchPanel which extends
FormComponentPanel:
public MultiSelectFieldSwitchPanel(final String id, final List<? extends
DomainObject> authors, final IModel<List<Author>> model) {
super(id, model);
lmc = new ListMultipleChoice("selectField", new
PropertyModel<List<Author>>(this, "selectedObjects"), authors, new
ChoiceRenderer<DomainObject>("name", "id"));
init(lmc);
}
The init method adds a link to swap the lmc for a textfield where new
authors can be entered, which is not really relevant in this case.
I have of course already added authorField to the AjaxRequestTarget in the
behavior that is triggered by updating the ISBN.
Regards,
Linda
---------------------------------------------------------------------
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]