title: JSF: invoking a javascript after a successful creation
body: <p>my current code.</p>
  
  <pre><code>&lt;h:form&gt;
     &lt;h:panelGroup id="messagePanel" layout="block"&gt;
         &lt;h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/&gt;
     &lt;/h:panelGroup&gt;
      &lt;h:panelGrid columns="2"&gt;
  
          // some form input stuff here..
  
      &lt;/h:panelGrid&gt;         
  
     &lt;h:commandButton class="register-btn" action="#{accountController.create}" value="#{bundle.Register}"&gt;
          &lt;f:ajax event="action" execute="@form" render="messagePanel"/&gt;
     &lt;/h:commandButton&gt;                       
  &lt;/h:form&gt;
  </code></pre>
  
  <p>messagePanel is where the validation errors displays.</p>
  
  <p>create() method</p>
  
  <pre><code>public String create() {
          try {
  
              getFacadeUser().create(currentUser);
  
              FacesContext.getCurrentInstance().getExternalContext().redirect("/index.xhtml");
              return null;
          } catch (Exception e) {
              JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
              return null;
          }
      }
  </code></pre>
  
  <p>is it possible to invoke a javascript after a successful creation? currently my create form is a pop up modal, what i want is to just hide the modal after a successful creation rather than redirecting to a page.</p>
  
  <p>i'm using JSF 2.1</p>