Hi Josh, u are right, you code looks good also, can you provide an
quickstart?

On Wed, Jan 5, 2011 at 8:32 AM, Josh Kamau <joshnet2...@gmail.com> wrote:

> Pedros
>
> The CheckGroup component is part of a form that users
> CompoundPropertyModel.
> I thought i dont have to pass any thing to the constractor other than the
> id.
>
> i have however changed the constructor of CheckGroup to new
> CheckGroup("users", project.getUsers()); and it still hasnt worked. I have
> also ensured that all my models override the Equals and HashCode methods.
>
> Josh.
>
>
>
> On Wed, Jan 5, 2011 at 1:15 PM, Pedro Santos <pedros...@gmail.com> wrote:
>
> > On Wed, Jan 5, 2011 at 7:21 AM, Josh Kamau <joshnet2...@gmail.com>
> wrote:
> >
> > > Hi guys;
> > >
> > > I am trying to use a CheckGroup component in a form with a ListView to
> > > generate a list of checks. Now, everytime i reload the page, it shows
> all
> > > the checkboxes checked instead of cheking only those that exist in the
> > > model. Where am i going wrong?
> > >
> > > I have a Project entity that has many User entities. The form in
> question
> > > is
> > > for editing project, adding and removing users. I would like to load
> the
> > > page with all the Users but only the ones that exist in the project are
> > > check.. I however always shows all checkboxes as checked. I have
> checked
> > > the
> > > database and the information there is correct. Where could i be going
> > > wrong?
> > >
> > > Here is the Java Code:
> > >
> > > private Form<Project> frmProject;
> > >    private ListView<User> lstUsers;
> > >    private CheckGroup chbUsers ;
> > >
> > >    @Inject
> > >    private ProjectDao projectDao ;
> > >
> > >    @Inject
> > >    private UserDao userDao;
> > >
> > >    public ModifyUsersPanel(String id, final Project project) {
> > >        super(id);
> > >
> > >        System.out.println("Project has initial "
> > > +project.getUsers().size()+ " users" );
> > >
> > >        frmProject = new Form<Project>("frmProject", new
> > > CompoundPropertyModel<Project>(project));
> > >        frmProject.setOutputMarkupId(true);
> > >
> > >        chbUsers = new CheckGroup("users");
> > >
> >
> > --> as the Check is being created as: new Check("checkbox",
> > item.getModel())
> > you need to specify the selected users collection to CheckGroup, you can
> > pass it as parameter
> >
> >
> > >        chbUsers.add(new AjaxFormChoiceComponentUpdatingBehavior(){
> > >
> > >            @Override
> > >            protected void onUpdate(AjaxRequestTarget target) {
> > >                System.out.println("Project has "
> > > +project.getUsers().size()+ " users" );
> > >                projectDao.save(project);
> > >            }
> > >
> > >        });
> > >
> > >        lstUsers = new ListView<User>("checkList", new
> > > LoadableDetachableModel<List<User>>() {
> > >
> > >            @Override
> > >            protected List<User> load() {
> > >                return userDao.getAllUsers();
> > >            }
> > >        }){
> > >
> > >            /**
> > >             *
> > >             */
> > >            private static final long serialVersionUID = 1L;
> > >
> > >            @Override
> > >            protected void populateItem(ListItem<User> item) {
> > >                item.add(new Check("checkbox", item.getModel()));
> > >                item.add(new Label("lbFirstName",
> > > item.getModelObject().getFirstname()));
> > >                item.add(new Label("lbLastName",
> > > item.getModelObject().getLastname()));
> > >            }
> > >
> > >        };
> > >
> > >        chbUsers.add(lstUsers);
> > >        frmProject.add(chbUsers);
> > >
> > >        add(frmProject);
> > >    }
> > >
> > > Here is the HTML markup:
> > >
> > > <form wicket:id="frmProject">
> > > <div id="content">
> > > <table class="grid_list_table" wicket:id="users">
> > >    <thead>
> > >        <tr>
> > >            <th style="width: 10px;"><input type="checkbox"></th>
> > >            <th>First Name<img src="img/desc.png" class="sort"></th>
> > >            <th>Last Name</th>
> > >            <th style="width: 50%;"></th>
> > >        </tr>
> > >    </thead>
> > >    <tbody>
> > >        <tr class="odd" wicket:id="checkList">
> > >            <td><input type="checkbox" checked="checked"
> > > wicket:id="checkbox"></td>
> > >            <td wicket:id="lbFirstName">Bob</td>
> > >            <td wicket:id="lbLastName">Smith</td>
> > >            <td></td>
> > >        </tr>
> > >    </tbody>
> > > </table>
> > >
> > > </div>
> > > </form>
> > >
> > > Any help is appreciated.
> > >
> > > Kind regards.
> > > Josh.
> > >
> >
> >
> >
> > --
> > Pedro Henrique Oliveira dos Santos
> >
>



-- 
Pedro Henrique Oliveira dos Santos

Reply via email to