views:

534

answers:

1

I use displaytag on a list bean : utilisateurBean.I need to add a column on this tab to add a checkbox for selecting an element.

Pb : With the displaytag struts looks for the property choixUtilisateur in the bean and not in the formBean. Is there a way to talk struts/displaytag to map this property in the form? I don't understand the mix of prestenation layer/ business layer that this involves.

I understand that I iterate on the bean and that he looks for the property in. But I did not understand the mapping of the decorator property in the business layer.

My code :

<html:form action="/rechercheUtilisateur"
    name="formRechercheUtilisateur"
        decorator="org.displaytag.render.DecorateurCheckbox"
    type="lan.poujoulat.osac.forms.FormRechercheUtilisateur">
...

   <div align="center"><display:table style="width: 100%;"
    class="mars" sort="list"
    name="formRechercheUtilisateur.listeUtilisateurs"
    id="formRechercheUtilisateur.listeUtilisateurs"
        decorator="org.displaytag.render.DecorateurCheckbox"
    cellspacing="4" cellpadding="2" pagesize="10"
    requestURI="rechercheUtilisateur.do" export="true"  >
    <display:column title="id" property="id" sortable="true"
        style="color: black;" headerClass="sortable"></display:column>
    ...
    <display:column media="html" property="choixUtilisateur" title="&nbsp;"></display:column>
...
   </display:table></div>
</html:form>

The DecorateurCheckbox.java to add checkbox to my tab:

public class DecorateurCheckbox extends TableDecorator{
...
    public String getChoixUtilisateur()
    {
        String retour = "";
        UtilisateurBean user= (UtilisateurBean) getCurrentRowObject();
        int idUser ;

        idUser = user.getId();

       retour = "<input type='checkbox' name='formRechercheUtilisateur' property='choixUtilisateur' value='"+idUser+"' id='selectedArticle" + idUser + "' />";

        return  retour;
    }
...
}

Error : /Administration/acces.jsp. Exception : javax.servlet.ServletException: Error looking up property "choixUtilisateur" in object type "xxx.UtilisateurBean".

A: 
public class DecorateurCheckbox extends TableDecorator{
   public String getChoixUtilisateur()
   {
    String retour = "";
    UtilisateurBean user= (UtilisateurBean) getCurrentRowObject();
    int idUser ;

    idUser = user.getId();

   retour = "<input type='checkbox' name='utilisateurModif' property='choixUtilisateur'   value='"+idUser+"' id='" + idUser + "' />";

    return  retour;
   }
}

utilisateurModif is the form property and choixUtilisateur is the displaytag property with the decorator : jsp :

<display:column property="choixUtilisateur" title="modif"></display:column>
jayjaypg22