[Debutant] besoin d'explication pour construire un ActionForm avec un lien href
Bonjour
Ma question est, je pense, assez bête, mais j'ai quelque problème avec un lien href qui doit renvoyer des propriété à mon ActionForm.
J'ai un boucle for qui m'affiche autant de lien que de Customer en affichant l'id, le name et le firstName du customer. Et selon le lien sur lequel je clique, je doit récuperer l'id.
Voici mon code JSP :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<% int taille = ControllerTableCustomer.createTableCustomer();
for (int i= 0 ; i < taille ; i++) {
request.setAttribute("customerBean",ControllerTableCustomer.createCustomerBean(i));%>
<tr><td>
<a href="selectPersonAction.do">
<bean:write scope="request" name="customerBean" property="id"/>
<bean:write scope="request" name="customerBean" property="name"/>
<bean:write scope="request" name="customerBean" property="firstName"/>
</a>
<html:link href="selectPersonAction.do" paramId="id" paramName="customerBean" />
</td></tr>
<%} %> |
Le SelectPersonForm est bien construit, mais le champ id n'est pas rempli.
Voici le SelectPersonForm :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public class SelectPersonForm extends ActionForm {
private static final long serialVersionUID = 1L;
private String id;
public final String getId() {
return id;
}
public final void setId(String newCustBean) {
id = newCustBean;
}
public final ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
return errors;
}
} |
mon SelectPersonAction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| public class SelectPersonAction extends Action {
/**
*
*/
public final ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
SelectPersonForm selectPersonForm = (SelectPersonForm) form;
System.out.println("SelectPersonAction, SelectPersonForm toString: " + selectPersonForm);
System.out.println("SelectPersonAction, CustomerBean string: " + selectPersonForm.getId());
return mapping.findForward("");
}
} |
et mon résultat de println :
Citation:
SelectPersonAction, SelectPersonForm toString: com.altis.welcome.controller.SelectPersonForm@1e91259
SelectPersonAction, CustomerBean string: null
Pour moi le probleme vient de la page JSP où je n'arrive pas à envoyer les information à mon ActionForm, mais j'arrive pas à savoir comment faire.
J'ai bien vue la faq, mais rien ne repond à ma question (ou j'ai rien capté...)
Merci de votre aide
Blaise