Thanks, that seems pretty straightforward. However, it makes me wonder, what is the advantage of using a model instead of just using the Task as a class variable? The model adds an extra layer of complexity, and I don't see the benefit.
-----Original Message----- From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] Sent: Friday, April 24, 2009 10:12 AM To: users@wicket.apache.org Subject: Re: Adding a model to a custom panel public TaskPanel(String id, IModel<Task> task) { super(id, task); add(new Label("name",new propertymodel(task, "name")); protected void onComponentTag(ComponentTag tag) { if (getModel().getObject().isSelected()) { // Do something } } -igor On Fri, Apr 24, 2009 at 7:57 AM, Dane Laverty <danelave...@gmail.com> wrote: > I’m building a Panel called TaskPanel that will display the contents of my > Task class. This simple Panel has a single constructor and a method, that > looks like this: > > public class TaskPanel extends Panel { > > Task task; > > public TaskPanel(String id, final Task task) { > super(id); > add(new Label("name", task.getName())); > add(new Label("description", task.getDescription())); > add(new Label("assignedTo", task.getAssignedTo())); > > this.task = task; > } > > �...@override > protected void onComponentTag(ComponentTag tag) { > if (task.isSelected()) { > // Do something > } > } > } > > > It seems like I should make Task the model for the Panel, but I'm having > trouble finding information on how to connect them. I imagine it should look > something like this: > > public class TaskPanel extends Panel { > > public TaskPanel(String id, IModel task) { > super(id, task); > add(new Label("name", ???)); > add(new Label("description", ???)); > add(new Label("assignedTo", ???)); > } > > �...@override > protected void onComponentTag(ComponentTag tag) { > if (getModel().???.isSelected()) { > // Do something > } > } > } > > Am I even heading in the right direction? Is this the right place to be > using a Model, or should I just stick with keeping the Task as an instance > variable in the class? --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org