When I debug the app, I can see that getObject() is being called for
subgenrefield, only selectedGenre == null. I also put a breakpoint in
convertInput() inside the GenreFieldSwithPanel, but it doesn't pass it.
Shouldn't it use that to determine what the new value of the model will be?
Linda
Linda van der Pal wrote:
That is in fact the type of behavior I am using. Here's a bit of the
code:
// The subgenre-field
IModel<List<Subgenre>> subgenreModel = new
AbstractReadOnlyModel<List<Subgenre>>() {
@Override
public List<Subgenre> getObject() {
List<Subgenre> subgenres = new ArrayList<Subgenre>();
if (selectedGenre != null){
// Fetch the subgenres based on selectedGenre
subgenres = ...
}
return subgenres;
}
};
final FieldSwitchPanel subgenrefield = new
SubgenreFieldSwitchPanel("subgenre", subgenreModel);
subgenrefield.setOutputMarkupId(true);
subgenrefield.setOutputMarkupPlaceholderTag(true);
form.add(subgenrefield);
// The genre-field
// fetch the genres
List<DomainObject> genres = ...
final FieldSwitchPanel genrefield = new
GenreFieldSwitchPanel("genre", genres, new
PropertyModel<DomainObject>(this, "selectedGenre"));
genrefield.add(new
AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.addComponent(subgenrefield);
}
});
genrefield.setOutputMarkupPlaceholderTag(true);
form.add(genrefield);
The problem is that selectedGenre stays null. So I'm looking for the
cause of that. My guess is that it is because the model isn't updated.
(I did implement convertInput() in GenreFieldSwitchPanel, which
extends FormComponentPanel.)
Linda
jWeekend wrote:
Linda,
Take a look at AjaxFormComponentUpdatingBehavior.
Regards - Cemal
http://jWeekend.com jWeekend
Linda van der Pal wrote:
I have a FormComponentPanel that contains a TextField and a
DropDownChoice. Of those two only one is visible at any moment. (The
TextField is there for when the DropDownChoice doesn't offer the
wanted result.) On the panel that contains the FormComponentPanel, I
want another element to respond to any change in the
FormComponentPanel (most importantly if the user selects something
from the DropDownChoice). I have added ajax behavior to the
component, but the model isn't updated, so when I debug the onChange
method of the behavior, I find that the object in the model is null.
How do I get it to update properly?
Regards,
Linda van der Pal
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org