Anna,
Try this:

==============
f.add(new Label("label1", new PopertyModel(data, "label1")));
f.add(new Label("label2", new PopertyModel(data, "label2")));
==============

That way when the model is queried for the value, the propertymodel
will dynamically query "data"'s appropriate property name (in this
case label1 and label2) for the values.

-R

On Mon, Mar 1, 2010 at 1:06 PM, Anna Simbirtsev <asimbirt...@gmail.com> wrote:
>
> But how can I use a label with a real model?
>
> On Mon, Mar 1, 2010 at 2:59 PM, James Carman
> <jcar...@carmanconsulting.com>wrote:
>
> > You're not using a real model.  You're constructing the labels with an
> > empty string (the data.getLabel1() is evaluated when you construct the
> > Label object).
> >
> > On Mon, Mar 1, 2010 at 2:57 PM, Anna Simbirtsev <asimbirt...@gmail.com>
> > wrote:
> > > Hi,
> > >
> > > I have labels defined in the following way:
> > >
> > > MarkupContainer f = new WebMarkupContainer("viewPanel");
> > >
> > > f.setOutputMarkupPlaceholderTag(true);
> > > form.add(f);
> > > f.setVisible(false);
> > >
> > > f.add(new Label("label1", data.getLabel1()));
> > > f.add(new Label("label2", data.getLabel2()));
> > >
> > > AjaxSubmitLink submitbutton = new AjaxSubmitLink("submit") {
> > >
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            protected void onSubmit(AjaxRequestTarget target, Form<?>
> > form)
> > > {
> > >
> > >                data = Manager.getData(data);
> > >
> > >                f.setVisible(true);
> > >                target.addComponent(f);
> > >            }
> > >  };
> > >
> > > <div wicket:id="viewPanel">
> > >    <div wicket:id="label1"></div>
> > >    <div wicket:id="label2"></div>
> > > </div>
> > >
> > > Originally data.getLabel1() return empty string. Manager.getData(data)
> > sets
> > > the values for the labels to some values.
> > > But when the panel becomes visible, the values are still empty. Why are
> > > models not updated to display new values?
> > >
> > > Thanks,
> > > Anna
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
>
> --
> Anna Simbirtsev
> (416) 729-7331

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

Reply via email to