Search code examples
jsfseam

Confirm and redirect to other view in JSF


Is it possible to add a confirmation box to the following component (Seam button ) ? I tried this ( see code below) : but when I click OK/Cancel nothing happens. When I remove the onclick everything works normally but without a confirm.

Code:

<s:button value="Delete this"
          id="updateTM"
          view="/secure/CustomerDelete.xhtml"
          onclick="if (! confirm('Really start deletion of  this customers ?') ) { return false;}; return true; "
          action="#{customerHome.initAsyncProcess}" />

Solution

  • Solved it with this (same layout as Seam butons) :

    <h:commandButton
        onclick="if (! confirm('Really want to do that?')) return false"
        value="Delete it"
        action="#{customerHome.startAsync}">
    </h:commandButton>
    

    Then in my bean I do the following :

    public String startAsync(){
            this.initAsyncProcess();
            return "/secure/CustomerDuplicateDelete.xhtml";
    }