javawicketwicket-7

Wicket : Add a list to a datatable


I have a list of object to display in a table with wicket. Those object are composed of a String and an Array of String.

My problem is that i don't know how to add this array into my table. And second, i have some css that I need to apply to each of my String of the array, so each of them have to be on a different div/span/li.

Can it be a good idea to concatenate all those elements and add the "div" manually ?

Thank you for your help :)


Solution

  • I have been to obssesed with using a datatable. By using a list in a list it work just fine !

    JAVA :

    ListView<Profil> listProfil = new ListView<Profil>("listProfils", profils) {
        protected void populateItem(ListItem<Profil> item) {
            Profil tmpProfil = item.getModelObject();
            item.add(new Label("libelle", tmpProfil.getLibelle()));
            item.add( new ListView("listChamps", tmpProfil.getChamps()) {
                protected void populateItem(ListItem item) {
                    item.add(new Label("libelleChamps", item.getModel()));
                }
            });
        }
    });
    

    And the associate HTML template :

    <tr wicket:id="listProfils">
        <div class="row">
            <td class="col-xs-4 col-md-3 col-lg-3 text">
                <span wicket:id="libelle"></span>
            </td>
            <td class="col-xs-7 col-md-8 col-lg-8 text" colspan="3">
                <span wicket:id="listChamps">
                    <span wicket:id="libelleChamps" 
                    class="label label-default badge badge-tag" >Champs</span>
                </span>
            </td>
        </div>
    </tr >