2 Replies Latest reply on Aug 10, 2007 4:25 AM by Kgnytia

    How can I propagate an exception from Spring to Flex (Cairngorm)?

    Kgnytia
      Hello:

      I would like to throw an exception (Spring) and propagate it to the fault function at the Command class (Cairngorm).

      Here is the code. The exception in thrown but the code in the fault function is never executed.

      public class BankServiceImpl extends HibernateDaoSupport implements IBankService {

      ...

      public void deleteBank(Bank bank){
      IBankService bankService = new BankServiceImpl(this.getHibernateTemplate(), this.getSessionFactory());
      Collection<Bank> list = bankService.getBanks();
      if(lista.isEmpty()){
      throw new Exception("MyMessage");
      ...
      }
      }

      The code in the command is:

      public class DeleteBankCommand implements ICommand, IResponder
      {
      ...
      public function fault( ev : Object ) : void
      {
      var faultEvent : FaultEvent = FaultEvent( ev );
      Alert.show( faultEvent.message.toString() );
      }//fin funcion fault
      }

      Thank you all
        • 1. Re: How can I propagate an exception from Spring to Flex(Cairngorm)?
          Level 7
          Can you check that the faultEvent.fault.rootCause is not null and may contain
          your exception object?



          Hello Kgnytia,

          > Hello:
          >
          > I would like to throw an exception (Spring) and propagate it to the
          > fault function at the Command class (Cairngorm).
          >
          > Here is the code. The exception in thrown but the code in the fault
          > function is never executed.
          >
          > public class BankServiceImpl extends HibernateDaoSupport implements
          > IBankService {
          >
          > ...
          >
          > public void deleteBank(Bank bank){
          > IBankService bankService = new
          > BankServiceImpl(this.getHibernateTemplate(),
          > this.getSessionFactory());
          > Collection<Bank> list = bankService.getBanks();
          > if(lista.isEmpty()){
          > throw new Exception("MyMessage");
          > ...
          > }
          > }
          > The code in the command is:
          >
          > public class DeleteBankCommand implements ICommand, IResponder
          > {
          > ...
          > public function fault( ev : Object ) : void
          > {
          > var faultEvent : FaultEvent = FaultEvent( ev );
          > Alert.show( faultEvent.message.toString() );
          > }//fin funcion fault
          > }
          > Thank you all
          >


          • 2. Re: How can I propagate an exception from Spring to Flex(Cairngorm)?
            Kgnytia Level 1
            Thank you for your reply.

            Actually, the problem is that when the exception is thrown, the fault function at the Command class doesnt notice. It never enters into the fault function.