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 <[email protected]> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to