2 Replies Latest reply on Jan 15, 2010 11:28 AM by Caio Aoque

    How to check the return of a method of Java class?

    Caio Aoque Newbie

      Good morning,


      I'd like to do some unusual with richfaces and I don't know how. My problem is:


      There's an entity mapped on the database. It is listed on a page (showing all objects from the database on a datatable), where it is possible to remove each record displayed.


      The problem is that i want to display an error message in a modalpanel in case it's not possible to remove that object due a dependency from another entity. I have already work on it and I programmed to display correctly the message in modalpanel, but the modalpanel always is displayed, even when it is successful (and I don't want this), because I don't know how to check the method's return from the java to my page (in this case the remove method).


      I'd like to know if there is a way to check the return of the method on the action attribute of an ajax component to control if it will show or not the modalpanel.


      Below is the code as it's now.


      // The remove method on the Java class

      public void remove() {
      // ...
            "Error on remove !!!!!");


      // My xhtml page

      <!-- Button to remove and show the modalpanel -->
      <a:commandButton action="#{MyBean.remove()}"
          reRender="myModal" value="Confirmar" />
      <!-- ModalPanel -->
      <rich:modalPanel id="myModal">
           <f:facet name="header">
                <h:outputText value="Error on remove"/>
           <h:messages globalOnly="true" 
                styleClass="message" errorClass="errormsg"
                infoClass="infomsg" warnClass="warnmsg"
                rendered="#{showGlobalMessages != 'false'}"/>
           <div class="actionButtons" align="center">
                     <a:commandButton value="OK"


      I think that is possible to change the void to boolean of the remove method return and run the oncomplete event of the remove button in case it returned false, for example.