displaytag,如何集成复选框? [英] displaytag, how to integrate checkboxes?
问题描述
我在列表bean上使用displaytag: utilisateurBean
。我需要在此标签上添加一个列,以添加用于选择元素的复选框。
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:使用 displaytag
struts在bean中查找属性 choixUtilisateur
,而不是在 formBean
中查找。有没有一种方式来谈论struts / displaytag在窗体中映射这个属性?我不明白这涉及到的Prestenation层/业务层的组合。
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.
我理解我在bean上进行迭代,并寻找属性。我不明白商家层中装饰器属性的映射。
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.
我的代码:
<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=" "></display:column>
...
</display:table></div>
</html:form>
DecorateurCheckbox.java
我的标签:
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;
}
...
}
p>
Error:
/Administration/acces.jsp。异常:javax.servlet.ServletException:
在对象类型
xxx.UtilisateurBean中查找属性choixUtilisateur时出错。
/Administration/acces.jsp. Exception : javax.servlet.ServletException: Error looking up property "choixUtilisateur" in object type "xxx.UtilisateurBean".
推荐答案
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是form属性,choixUtilisateur是displaytag属性与装饰器:
jsp:
utilisateurModif is the form property and choixUtilisateur is the displaytag property with the decorator : jsp :
<display:column property="choixUtilisateur" title="modif"></display:column>
这篇关于displaytag,如何集成复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!