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: [email protected]
For additional commands, e-mail: [email protected]
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.278 / Virus Database: 270.11.8/1986 - Release Date: 03/05/09 19:32:00