package demo18.client;
import org.openswing.swing.client.*;
import java.util.*;
import org.openswing.swing.util.client.ClientSettings;
import org.openswing.swing.internationalization.java.EnglishOnlyResourceFactory;
import org.openswing.swing.form.model.client.VOModel;
import org.openswing.swing.form.client.Form;
import org.openswing.swing.form.client.FormController;
import org.openswing.swing.util.java.Consts;
import org.openswing.swing.message.receive.java.*;
import org.openswing.swing.lookup.client.LookupController;
import org.openswing.swing.lookup.client.LookupDataLocator;
import org.openswing.swing.internationalization.java.Resources;
import org.openswing.swing.mdi.client.MDIFrame;
import org.openswing.swing.util.client.ClientUtils;
/**
* <p>Title: OpenSwing Framework</p>
* <p>Description: Detail frame controller for the employee</p>
* <p>Copyright: Copyright (C) 2006 Mauro Carniel</p>
* <p> </p>
* @author Mauro Carniel
* @version 1.0
*/
public class EmpDetailFrameController extends FormController {
private EmpDetailFrame frame = null;
private String pk = null;
private EmpGridFrame gridFrame = null;
public EmpDetailFrameController(EmpGridFrame gridFrame,String pk) {
this.gridFrame = gridFrame;
this.pk = pk;
frame = new EmpDetailFrame(this);
MDIFrame.add(frame);
if (pk!=null) {
frame.getMainPanel().setMode(Consts.READONLY);
frame.getMainPanel().reload();
}
else {
frame.getMainPanel().setMode(Consts.INSERT);
}
}
/**
* This method must be overridden by the subclass to retrieve data and return the valorized value object.
* @param valueObjectClass value object class
* @return a VOResponse object if data loading is successfully completed, or an ErrorResponse object if an error occours
*/
public Response loadData(Class valueObjectClass) {
return ClientUtils.getData("loadEmp",pk);
}
/**
* Callback method called when the data loading is completed.
* @param error <code>true</code> if an error occours during data loading, <code>false</code> if data loading is successfully completed
*/
public void loadDataCompleted(boolean error) {
frame.getControlCurrency().setCurrencySymbol("$");
frame.getControlCurrency().setDecimals(2);
frame.getControlCurrency().setDecimalSymbol('.');
frame.getControlCurrency().setGroupingSymbol(',');
}
/**
* Method called by the Form panel to insert new data.
* @param newValueObject value object to save
* @return an ErrorResponse value object in case of errors, VOResponse if the operation is successfully completed
*/
public Response insertRecord(ValueObject newPersistentObject) throws Exception {
return ClientUtils.getData("insertEmp",newPersistentObject);
}
/**
* Method called by the Form panel to update existing data.
* @param oldPersistentObject original value object, previous to the changes
* @param persistentObject value object to save
* @return an ErrorResponse value object in case of errors, VOResponse if the operation is successfully completed
*/
public Response updateRecord(ValueObject oldPersistentObject,ValueObject persistentObject) throws Exception {
return ClientUtils.getData("updateEmp",new ValueObject[]{oldPersistentObject,persistentObject});
}
/**
* Method called by the Form panel to delete existing data.
* @param persistentObject value object to delete
* @return an ErrorResponse value object in case of errors, VOResponse if the operation is successfully completed
*/
public Response deleteRecord(ValueObject persistentObject) throws Exception {
ArrayList list = new ArrayList();
list.add(persistentObject);
return ClientUtils.getData("deleteEmps",list);
}
}