Hi everybody,
I need really your help.
In a form, from the bdd, I create checkgroups with checkgroupselectors.
This checkgroup works fine with the Check.
But a want to add a Checkbox with thanks to AjaxBehavior can select or
unselect all the checkgroup. But I don't succed.
This is the part of my code :
CheckBox group_all = new CheckBox("select_all", new Model());
group_all.add(new Label("select_all", "Selectionner tous les
projets"));
group_all.add(new AjaxFormComponentUpdatingBehavior("onchange") {
private static final long serialVersionUID = 1L;
protected void onUpdate(AjaxRequestTarget target) {
for (int i = 0 ; i < list_checkgroup.size() ; i++){
CheckGroup check =
(CheckGroup)list_checkgroup.get(i);
log.info("Test1 :
"+check.getModelObjectAsString()); -> print []
log.info("Test2 :
"+check.getModel().getObject()); --> print []
check.getModel().setObject(true); --> no working
target.addComponent(check);
}
}
});
// parametrage de la listview desfile
this.listview_domaine = new ListView("listview_domaine",
list_domaine) {
private static final long serialVersionUID = 1L;
protected void populateItem(ListItem listItem)
{
final TDomaine domaine =
(TDomaine)listItem.getModelObject();
listItem.add(new Label("nom_domaine",
domaine.getNom()));
list_sousdomaine =
CDataFromBDD.getListSousDomaine(domaine.getNom());
listview_sousdomaine = new
ListView("listview_sousdomaine", list_sousdomaine) {
private static final long serialVersionUID = 1L;
protected void populateItem(ListItem listItem)
{
final TSousDomaine sousdomaine =
(TSousDomaine)listItem.getModelObject();
group_sousdomaine = new
CheckGroup("group_sousdomaine",new ArrayList()); -> create the
checkgroup
group_sousdomaine.setOutputMarkupId(true);
group_sousdomaine.setRenderBodyOnly(false);
CheckGroupSelector checkgroup_sousdomaine = new
CheckGroupSelector("groupselector_sousdomaine");
checkgroup_sousdomaine.add(new
Label("nom_sousdomaine", sousdomaine.getNom()));
group_sousdomaine.add(checkgroup_sousdomaine);
-> add the CheckGroupSelector
list_projet =
CDataFromBDD.getListProjet(sousdomaine.getNom());
listview_projet = new
ListView("listview_projet", list_projet) {
private static final long serialVersionUID
= 1L;
protected void populateItem(ListItem
listItem)
{
final TProjet projet =
(TProjet)listItem.getModelObject();
TInformationsGenerales info_gen =
CDataFromBDD.getInfoGen(projet.getIdProjet());
TVersion version =
CDataFromBDD.getVersion(info_gen.getIdInformationGen());
listItem.add(new Check("checkbox_projet",
new Model()));
listItem.add(new Label("name_projet",
info_gen.getNom()));
listItem.add(new Label("version_projet",
version.getNumVersion()));
}
};
group_sousdomaine.add(listview_projet);
list_checkgroup.add(group_sousdomaine); -> save
the CheckGroup objet in a ArrayList
listItem.add(group_sousdomaine);
}
};
listItem.add(listview_sousdomaine);
}
};
The first problem is that I can't get back the value of checgroups : for
every one, is there selected or unselected ? The second problem
Is how can I set the checkgroup to selected or unselected ?
Thank you very much for your help :-)