Plusieurs commandButton - Submit ne marche pas
Bonjour,
Je rencontre un problème avec JSF pour construire une page avec plusieurs bouton ou liens pour soumettre le formulaire. J'ai une partie de la page qui sert à faire une recherche. Deux critères de recherche sont proposés. Un bouton "Search" permet de soumettre ces deux champs de texte. Ensuite la page est rafraîchie avec une dataTable comportant tous les enregistrements correspondant aux critères de recherche. Dans cette dataTable, je souhaite ajouter 2 commandLink par ligne : un pour renvoyer vers une page de mise à jour de l'enregistrmeent (Update) et un autre pour supprimer l'enregistrement (Delete). Le problème : Quand je clique sur ces liens de la dataTable, la page se rafraîchit mais la méthode du managed bean JSF n'est pas appelée.
Mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
<h:form id="form">
<table width="100%">
<tr>
<td>
<fieldset>
<legend>Search criteria : </legend>
<table>
<tr>
<td align="right"> <h:outputLabel id="traitCodeLabel" value="Trait code : " for="traitCode" /> </td>
<td align="left"> <h:inputText id="traitCode" value="" /> </td>
<td> <rich:spacer width="30" /> </td>
<td align="right"> <h:outputLabel id="traitDescriptionLabel" value="Trait definition : " for="traitDescription" /> </td>
<td align="left"> <h:inputText id="traitDescription" value="" /> </td>
<td> <rich:spacer width="30" /> </td>
<td> <h:commandButton action="#{traitBean.searchTraits}" value="Search" /> </td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td>
<rich:dataTable id="table" onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
cellpadding="0" cellspacing="0" width="100%" border="0" var="trait" value="#{traitBean.traits}" rendered="#{traitBean.traits != null}">
<f:facet name="header">
<rich:columnGroup>
<rich:column>
<h:outputText value="Code" />
</rich:column>
<rich:column>
<h:outputText value="Definition" />
</rich:column>
<rich:column>
<h:outputText value="Update" />
</rich:column>
<rich:column>
<h:outputText value="Delete" />
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:column>
<h:outputText value="#{trait.code}" />
</rich:column>
<rich:column>
<h:outputText value="#{trait.definition}" />
</rich:column>
<rich:column style="text-align: center">
<h:commandLink action="#{traitBean.updateTrait}">
<h:outputText value="Update" />
<f:setPropertyActionListener value="#{trait}" target="#{traitBean.selectedTrait}" />
</h:commandLink>
</rich:column>
<rich:column style="text-align: center">
<h:commandLink action="#{traitBean.deleteTrait}">
<h:graphicImage url="/images/croix_supprimer.png" style="border: 0" />
<f:setPropertyActionListener value="#{trait}" target="#{traitBean.selectedTrait}" />
</h:commandLink>
</rich:column>
</rich:dataTable>
</td>
</tr>
</table>
</h:form> |
Si je supprime le premier commandButton "Search" et que j'affiche d'entrée tous mes enregistrements dans la dataTable, alors ces boutons marchent et les méthodes du managed bean sont bien appelées.
Le problème pourrait-il donc venir du fait qu'il y a deux plusieurs façon de "submiter" le formulaire ?
Merci d'avance pour votre aide