1 27 28 29 package com.sun.ebank.web; 30 31 import com.sun.ebank.web.BeanManager; 32 import com.sun.ebank.util.*; 33 import com.sun.ebank.ejb.tx.TxController; 34 import com.sun.ebank.ejb.exception.*; 35 import java.util.*; 36 import java.rmi.RemoteException ; 37 import java.math.BigDecimal ; 38 39 40 public class TransferBean { 41 private BigDecimal transferAmount; 42 private String fromAccountId; 43 private String toAccountId; 44 private ResourceBundle messages; 45 private BeanManager beanManager; 46 47 public TransferBean() { 48 beanManager = null; 49 transferAmount = null; 50 fromAccountId = null; 51 toAccountId = null; 52 messages = null; 53 } 54 55 public String doTx() { 56 String message = null; 57 TxController txCtl = beanManager.getTxController(); 58 59 try { 60 txCtl.transferFunds(transferAmount, "Transfer", fromAccountId, 61 toAccountId); 62 } catch (RemoteException e) { 63 message = e.getMessage(); 64 Debug.print(message); 65 } catch (InvalidParameterException e) { 66 } catch (AccountNotFoundException e) { 68 } catch (InsufficientFundsException e) { 70 message = messages.getString("InsufficientFundsError"); 71 Debug.print(message); 72 } catch (InsufficientCreditException e) { 73 message = messages.getString("InsufficientCreditError"); 74 Debug.print(message); 75 } 76 77 return message; 78 } 79 80 public BigDecimal getTransferAmount() { 81 return transferAmount; 82 } 83 84 public String getFromAccountId() { 85 return fromAccountId; 86 } 87 88 public String getToAccountId() { 89 return toAccountId; 90 } 91 92 public void setBeanManager(BeanManager beanManager) { 93 this.beanManager = beanManager; 94 } 95 96 public void setTransferAmount(BigDecimal transferAmount) { 97 this.transferAmount = transferAmount; 98 Debug.print("Setting transfer amount to: " + transferAmount); 99 } 100 101 public void setFromAccountId(String fromAccountId) { 102 this.fromAccountId = fromAccountId; 103 Debug.print("Setting from account id to: " + fromAccountId); 104 } 105 106 public void setToAccountId(String toAccountId) { 107 this.toAccountId = toAccountId; 108 Debug.print("Setting to account id to: " + toAccountId); 109 } 110 111 public void setMessages(ResourceBundle messages) { 112 this.messages = messages; 113 } 114 } 115 | Popular Tags |