problem with s:link or h:commandLink
tienlantri Oct 19, 2010 11:49 AMIn my application, I need function delete. When we click on the icon delete, a modal popup will appear asking if we are willing to delete... If we click on Yes button, the selected item is deleted and the page is reloaded.
The problem is that when I click on the icon delete and let it be (without clicking Yes or No button). My page is reloading and after few seconds, my modal popup disappears.
I think that with s:link or h:commandLink, SEAM automatically call @Create function
Here is the code define icon and delete
<s:link id="linkSuppression"> <h:graphicImage value="/img/icones/supprimer.png" /> <s:conversationPropagation type="join"/> <a4j:support status="_none" event="onclick" reRender="tablePrestations" /> <rich:componentControl for="panelSuppression" attachTo="linkSuppression" operation="show" event="onclick" /> </s:link> <hardis:modal id="panelSuppression" width="380" height="70" title="#{messages['general.delete.question']}"> <table width="100%"> <tbody> <tr> <td width="50%"> <rich:spacer width="20" height="1" styleClass="right"/> <a4j:commandLink reRender="tablePrestations" eventsQueue="serviceQueue" action="#{gestionPrestation.deleteSelectedPrestation}"> <a4j:support status="_none" event="onclick" reRender="tablePrestations" ajaxSingle="true" /> <hardis:button id="tablePrestations:#{var}:panelSuppressionBtn1" class="right" title="#{messages['button.yes']}"/> <rich:componentControl for="panelSuppression" attachTo="tablePrestations:#{var}:panelSuppressionBtn1" operation="hide" event="onclick"/> </a4j:commandLink> </td> <td width="50%"> <rich:spacer width="20" height="1" styleClass="left"/> <hardis:button id="tablePrestations:#{var}:panelSuppressionBtn2" class="left" title="#{messages['button.no']}" /> <rich:componentControl for="panelSuppression" attachTo="tablePrestations:#{var}:panelSuppressionBtn2" operation="hide" event="onclick"/> </td> </tr> </tbody> </table> </hardis:modal>
My backing bean
@AutoCreate @Scope(ScopeType.CONVERSATION) @Name("gestionPrestation") public class GestionPrestationAction { @In private EntityManager entityManager; @Logger private Log logger; @In private PrestationService prestationService; @In @Out private Prestation prestationToAdd; @DataModel private List<Prestation> prestations; @DataModelSelection private Prestation selectedPrestation; @Create public void initComponent() { Conversation.instance().begin(); logger.info("createAction"); prestationToAdd = new Prestation(); allEftcos = eftcoService.getAllEftcos(); allActivites = activiteService.getAllActivites(); initDataModel(); } public void deleteSelectedPrestation() { logger.info("Suppress... " + selectedPrestation); prestations.remove(selectedPrestation); entityManager.remove(selectedPrestation); adjustNewNumeroGca(); logger.info(selectedPrestation + " is deleted"); } }
Please tell me how to fix it? I appreciate your time!
Thanks,
Tina