I've put this method in my SectionPanel
@Override
public Component setModel(IModel arg0) {
SectionModel s = (SectionModel) arg0.getObject(this);
System.out.println(s.getResource().getText().get(language.toString
()).get(InstrumentContentType.PHRASE_TYPE));
Component test = super.setModel(arg0);
return test;
}
This prints indeed the a property of the new model in the shell. So the
model of the panel really is updated with the correct data. Moreover the
Panel is rendered again. But: it still shows the data of the old model. The
panel:
public class SectionPanel extends Panel {
private static final long serialVersionUID = 2876948753292218636L;
private final Locale language = this.getSession().getLocale();
private final Label title;
public SectionPanel(String id, IModel model) throws ApplicationException
{
super(id,model);
// title
this.title = new Label("title", new
PropertyModel(model.getObject(this),
"some.property"));
add(title);
//add(new Label("title", new
Model(((SectionModel)this.getModelObject()).getResource().getText().get(
language.toString()).get(InstrumentContentType.PHRASE_TYPE))));
// questionGroups
add(new QuestionGroupListView("questionGroups", ((SectionModel)
this.getModelObject()).getQuestionGroups()));
}
@Override
public Component setModel(IModel arg0) {
SectionModel s = (SectionModel) arg0.getObject(this);
System.out.println(s.getResource().getText().get(language.toString
()).get(InstrumentContentType.PHRASE_TYPE));
Component test = super.setModel(arg0);
return test;
}
class QuestionGroupListView extends ListView{
private static final long serialVersionUID = 6286550741243811340L;
private final Locale language = this.getSession().getLocale();
public QuestionGroupListView(String id, List list) {
super(id, list);
}
@Override
protected void populateItem(ListItem item) {
// questionGroupTitle
final String titleProperty = "resource.text[" +
this.language.toString() + "][" + InstrumentContentType.PHRASE_TYPE + "]";
item.add(new Label("title",new PropertyModel(item.getModelObject(),
titleProperty)));
}
}
}
2007/6/28, Pieter Cogghe <[EMAIL PROTECTED]>:
I' m trying to do something very simple. When I click a link, I change the
Model of a panel, but the Panel doesn't show the content of the new Model. I
tried to do this with a simple Label and that works. It has got to be
something very stupid, but I've been looking at it all morning and I just
don't get it. So I've got:
- Label
- Panel
- Link that changes both the model of Label and Panel
the Label shows the content of the new Model, the Panel shows the old
content... . Code of my index page:
public class Index extends BasePage {
private final SectionPanel sectionPanel; //section
private final ListView sectionMenu; // menu with the link
private final Label test; // test Label
public Index() throws ApplicationException{
super();
// components
// the panel that doesn't update when the model is changed
this.sectionPanel = new SectionPanel("section", new Model(
this.instrumentModel.getSectionModels().get(0)));
add(sectionPanel);
// test label
this.testje = new Label("testje", new Model("blah"));
add(testje);
// menu
this.sectionMenu = new ListView("sectionMenu",
this.instrumentModel.getSectionModels()){
@Override
protected void populateItem(final ListItem item) {
item.add(new Link("link"){
private static final long serialVersionUID =
374665526654182939L;
@Override
public void onClick() {
sectionPanel.setModel(item.getModel()); // this
doesn't work
sectionPanel.modelChanged();
testje.setModel(new PropertyModel (
item.getModelObject(),"some.property")); // this works
}
});
}
};
add(sectionMenu);
--
Pieter Cogghe
Ganzendries 186
9000 Gent
0487 10 14 21
--
Pieter Cogghe
Ganzendries 186
9000 Gent
0487 10 14 21
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user