1 Reply Latest reply on Feb 14, 2011 7:32 AM by Ilya Sorokoumov

    Show error msg using javascript alert

    Zaheer Ahmed Novice

      Hi All

       

      I'm using following code to generate the Alert()  this code works to an extend.

       

      <a4j:commandButton id="gI" value="Generate Invoice" action="#{categoryProduct.generateInvoice}"

                               oncomplete="if (#{categoryProduct.errorMsg != ''}) {

                               alert('#{categoryProduct.errorMsg}')

                                    }else{

                                     location.href='poss_main_screen.jsp';

                                    } ">

        </a4j:commandButton>

       

      The probem is,  this part of the code will not work why???     

       

      }else{ location.href='poss_main_screen.jsp';  } ">

       

      No matter what the status of 'errorMsg' is it still shows the alert.

       

      Code in Bean file;

       

                errorMsg = "Your basket is empty"; else{

      }

       

       

      //code

       

       

      if  (basketList.isEmpty()) {

       

       

      }