【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了BankAccountAction.java提供大家参考,希望对大家有所帮助!
package atbs.view;
import javax.naming.Context;
import javax.naming.NamingException;
import atbs.entity.*;
import atbs.session.*;
public class BankAccountAction {
private Context ctx;
private BankAccountSessionRemote bankAccountSession;
private Account bankAccount;
private String updateError;
private int addValue;
private String newPassword;
public BankAccountAction(){
try {
ctx = RemoteContext.getContextInstance();
} catch (NamingException ex) {
ex.printStackTrace();
}
try {
bankAccountSession = (BankAccountSessionRemote) ctx.lookup("atbs/BankAccountSession/remote");
} catch (NamingException ex1) {
ex1.printStackTrace();
}
SysUser user = (SysUser)ManageContext.getSessionScopeBean("user");
this.bankAccount = this.bankAccountSession.getAccount(user.getUserName());
if(bankAccount==null){
this.bankAccount = this.bankAccountSession.createAccount(user.getUserName());
}
}
public String updatePassword(){
System.out.println("Password:"+bankAccount.getPassword());
System.out.println("New Password:"+this.newPassword);
if(this.newPassword.equals(bankAccount.getPassword())){
this.bankAccountSession.updateAccount(bankAccount);
this.updateError = "Update Pass
word Success...";
}else{
this.updateError = "Two password are not same...";
}
return null;
}
public String chargeValue(){
if(this.addValue>0){
this.bankAccount.setValue(this.addValue+this.bankAccount.getValue());
this.bankAccountSession.updateAccount(bankAccount);
this.updateError = "You Account add value:"+this.addValue+" dollars";
}else{
this.updateError = "Add Value is not postive...";
}
return null;
}
public Account getBankAccount() {
return bankAccount;
}
public void setBankAccount(Account bankAccount) {
this.bankAccount = bankAccount;
}
public int getAddValue() {
return addValue;
}
public void setAddValue(int addValue) {
this.addValue = addValue;
}
public String getNewPassword() {
return newPassword;
}
public void setNewPassword(String newPassword) {
this.newPassword = newPassword;
}
public String getUpdateError() {
return updateError;
}
public void setUpdateError(String updateError) {
this.updateError = updateError;
}
}