FileDocCategorySizeDatePackage
EmployeeAction.javaAPI DocApache Struts 2.0.9 Apps3983Mon Jul 23 13:43:26 BST 2007org.apache.struts2.showcase.action

EmployeeAction

public class EmployeeAction extends AbstractCRUDAction implements com.opensymphony.xwork2.Preparable
JsfEmployeeAction.

Fields Summary
private static final long
serialVersionUID
private static final Logger
log
private Long
empId
protected org.apache.struts2.showcase.dao.EmployeeDao
employeeDao
private org.apache.struts2.showcase.model.Employee
currentEmployee
private List
selectedSkills
Constructors Summary
Methods Summary
public java.lang.Stringexecute()

        if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) {
            setSelectedSkills(new ArrayList());
            Iterator it = getCurrentEmployee().getOtherSkills().iterator();
            while (it.hasNext()) {
                getSelectedSkills().add(((Skill) it.next()).getName());
            }
        }
        return super.execute();
    
public java.util.ListgetAvailableLevels()

        return Arrays.asList(TestDataProvider.LEVELS);
    
public java.lang.String[]getAvailablePositions()

        return TestDataProvider.POSITIONS;
    
public org.apache.struts2.showcase.model.EmployeegetCurrentEmployee()

        return currentEmployee;
    
protected org.apache.struts2.showcase.dao.DaogetDao()

        return employeeDao;
    
public java.lang.LonggetEmpId()


       
        return empId;
    
public java.util.ListgetSelectedSkills()

        return selectedSkills;
    
public voidprepare()
This method is called to allow the action to prepare itself.

throws
Exception thrown if a system level exception occurs.

        Employee preFetched = (Employee) fetch(getEmpId(), getCurrentEmployee());
        if (preFetched != null) {
            setCurrentEmployee(preFetched);
        }
    
public java.lang.Stringsave()

        if (getCurrentEmployee() != null) {
            setEmpId((Long) employeeDao.merge(getCurrentEmployee()));
            employeeDao.setSkills(getEmpId(), getSelectedSkills());
        }
        return SUCCESS;
    
public voidsetCurrentEmployee(org.apache.struts2.showcase.model.Employee currentEmployee)

        this.currentEmployee = currentEmployee;
    
public voidsetEmpId(java.lang.Long empId)

        this.empId = empId;
    
public voidsetEmployeeDao(org.apache.struts2.showcase.dao.EmployeeDao employeeDao)

        if (log.isDebugEnabled()) {
            log.debug("JsfEmployeeAction - [setEmployeeDao]: employeeDao injected.");
        }
        this.employeeDao = employeeDao;
    
public voidsetSelectedSkills(java.util.List selectedSkills)

        this.selectedSkills = selectedSkills;