FileDocCategorySizeDatePackage
JsfEmployeeAction.javaAPI DocApache Struts 2.0.9 Apps3904Mon Jul 23 13:43:26 BST 2007org.apache.struts2.showcase.jsf

JsfEmployeeAction

public class JsfEmployeeAction extends org.apache.struts2.showcase.action.EmployeeAction
Overriding the EmployeeAction to main provide getters returning the data in the form required by the JSF components

Fields Summary
private static final long
serialVersionUID
private org.apache.struts2.showcase.dao.SkillDao
skillDao
Constructors Summary
public JsfEmployeeAction()
Creating a default employee and main skill, since the JSF EL can't handle creating new objects as necessary


                           
      
        Employee e = new Employee();
        e.setMainSkill(new Skill());
        setCurrentEmployee(e);
    
Methods Summary
public java.util.CollectiongetAvailableItems()
Returning a List because the JSF dataGrid can't handle a Set for some reason

        return new ArrayList(super.getAvailableItems());
    
public java.util.MapgetAvailableLevelsAsMap()
Converting the list into a map

        Map map = new LinkedHashMap();
        for (Object val : super.getAvailableLevels()) {
            map.put(val, val);
        }
        return map;
    
public java.util.MapgetAvailablePositionsAsMap()
Changing the String array into a Map

        Map<String, String> map = new LinkedHashMap<String, String>();
        for (String val : super.getAvailablePositions()) {
            map.put(val, val);
        }
        return map;
    
public java.util.MapgetAvailableSkills()
Converting the Skill object list into a map

        Map<String, String> map = new HashMap<String, String>();
        for (Object val : skillDao.findAll()) {
            Skill skill = (Skill) val;
            map.put(skill.getDescription(), skill.getName());
        }
        return map;
    
public java.util.ListgetSelectedSkillsAsList()
Gets the selected Skill objects as a list

        System.out.println("asked for skills");
        List<String> list = new ArrayList<String>();
        List skills = super.getSelectedSkills();
        if (skills != null) {
            for (Object val : skills) {
                if (val instanceof Skill) {
                    list.add(((Skill) val).getDescription());
                } else {
                    Skill skill = skillDao.getSkill((String) val);
                    list.add(skill.getDescription());
                }
            }
        }
        return list;
    
public voidsetSkillDao(org.apache.struts2.showcase.dao.SkillDao skillDao)

        this.skillDao = skillDao;