1 10 package net.sourceforge.ejosa.piggybank.presentation.enhydra; 11 12 import com.lutris.appserver.server.httpPresentation.*; 13 14 16 import java.io.*; 17 18 import java.text.*; 19 20 import java.util.*; 21 22 import net.sourceforge.ejosa.piggybank.spec.*; 23 import net.sourceforge.ejosa.piggybank.spec.business.*; 24 import net.sourceforge.ejosa.piggybank.spec.system.*; 25 26 import org.openuss.presentation.enhydra.framework.*; 27 28 import org.openuss.utility.*; 29 30 import org.w3c.dom.*; 31 import org.w3c.dom.html.*; 32 33 34 40 public class SavePage extends FoundationPO { 41 protected String amount = null; 43 44 private SaveHTML mPage; 46 47 50 public String handleDefault() throws HttpPresentationException { 51 mPage = (SaveHTML) this.getComms().xmlcFactory.create(SaveHTML.class); 53 54 String errorMsg = this.getSessionData().getAndClearUserMessage(); 56 57 if (errorMsg == null) { 58 mPage.getElementTStatusbar().getParentNode() 60 .removeChild(mPage.getElementTStatusbar()); 61 } else { 62 mPage.setTextTStatusbar(errorMsg); 64 } 65 66 return showLayout(mPage); 68 } 69 70 73 public boolean loggedInUserRequired() { 74 return false; 76 } 77 78 81 public String showLayout(Object page) throws BasePOException { 82 super.showLayout(mPage); 84 85 86 showSave(); 88 89 return mPage.toDocument(); 91 } 92 93 96 private void showSave() throws FoundationPOException { 97 try { 100 amount = "0"; 101 102 if (this.getComms().request.getParameter("amount") != null) { 103 try { 104 int temp = Integer.parseInt( 105 this.getComms().request.getParameter( 106 "amount")); 107 amount = "" + temp; 108 } catch (NumberFormatException nfe) { 109 } 111 } 112 } catch (Exception ex) { 113 System.out.println("Form Reader Error: " + ex); 114 } 115 116 try { 119 CoinManager coinManager = CoinManagerFactory.createCoinManager( 121 "net.sourceforge.ejosa.piggybank.business.session.CoinManagerImpl"); 122 123 Coin coin = CoinFactory.createCoin( 126 "net.sourceforge.ejosa.piggybank.business.entity.CoinImpl"); 127 128 String now = DateFormat.getDateInstance(DateFormat.SHORT, 129 Locale.ENGLISH) 130 .format(new Date()); 131 132 coin.setDate(now); 133 coin.setAmount(amount); 134 coin.setCurrency("Dollar"); 135 136 coinManager.createCoin(coin); 137 138 } catch (Exception ex) { 140 System.out.println("EJB Error: " + ex); 141 ex.printStackTrace(); 142 } 143 144 145 mPage.setTextVAmount(amount); 147 } 148 } | Popular Tags |