Boolean viewPhoto = getCheckBoxValue((String) findPersonForm.get("viewPhoto"));
} else if (findPersonForm.get("viewPhoto") != null) { viewPhoto = getCheckBoxValue((String) findPersonForm.get("viewPhoto")); } findPersonForm.set("viewPhoto", viewPhoto.toString());
    public ActionForward findPerson(ActionMapping mapping, ActionForm actionForm,            HttpServletRequest request, HttpServletResponse response) throws Exception {        ActionErrors errors = new ActionErrors();        IUserView userView = SessionUtils.getUserView(request);        DynaActionForm findPersonForm = (DynaActionForm) actionForm;        String name = null;        if (request.getParameter("name") != null && request.getParameter("name").length() > 0) {            name = request.getParameter("name");        } else if (findPersonForm.get("name") != null) {            name = (String) findPersonForm.get("name");        }        Integer startIndex = null;        if (request.getParameter("startIndex") != null                && request.getParameter("startIndex").length() > 0) {            startIndex = Integer.valueOf(request.getParameter("startIndex"));        } else if (findPersonForm.get("startIndex") != null) {            startIndex = Integer.valueOf((String) findPersonForm.get("startIndex"));        }        String roleType = null;        Integer departmentId = null;        Integer degreeId = null;        String degreeType = null;        Integer indexPage = null;        if (request.getParameter("roleType") != null && request.getParameter("roleType").length() > 0) {            roleType = (String) request.getParameter("roleType");        } else if (findPersonForm.get("roleType") != null) {            roleType = (String) findPersonForm.get("roleType");        }        if (request.getParameter("degreeType") != null                && request.getParameter("degreeType").length() > 0) {            degreeType = (String) request.getParameter("degreeType");        } else if (findPersonForm.get("degreeType") != null) {            degreeType = (String) findPersonForm.get("degreeType");        }        if (degreeType.length() == 0 && roleType.length() == 0) {            degreeType = null;        } else if (roleType.equals(RoleType.STUDENT.getName())) {            if (degreeType.length() != 0) {                Object[] args1 = { degreeType };                List nonMasterDegree = (List) ServiceUtils.executeService(null, "ReadAllDegreesByType",                        args1);                request.setAttribute("nonMasterDegree", nonMasterDegree);                request.setAttribute("degreeType", degreeType);            } else {                request.setAttribute("degreeType", true);            }        }        if (request.getParameter("departmentId") != null                && request.getParameter("departmentId").length() > 0) {            departmentId = Integer.valueOf(request.getParameter("departmentId"));        } else if (findPersonForm.get("departmentId") != null) {            departmentId = (Integer) findPersonForm.get("departmentId");        }        if (roleType.equals(RoleType.TEACHER.getName())) {            List departments = (List) ServiceUtils.executeService(null, "ReadAllDepartments", null);            request.setAttribute("departments", departments);        }        if (request.getParameter("degreeId") != null && request.getParameter("degreeId").length() > 0) {            degreeId = Integer.valueOf(request.getParameter("degreeId"));        } else if (findPersonForm.get("degreeId") != null) {            degreeId = (Integer) findPersonForm.get("degreeId");        }        SearchParameters searchParameters = new SearchPerson.SearchParameters(name, null, null, null,                roleType, degreeType, degreeId, departmentId);        SearchPersonPredicate predicate = new SearchPerson.SearchPersonPredicate(searchParameters);        Object[] args = { searchParameters, predicate };              SearchPerson.SearchPersonResults result = null;        List<InfoPerson> searchPersons = null;        try {            result = (SearchPersonResults) ServiceManagerServiceFactory.executeService(userView,                    "SearchPerson", args);            Integer start = (startIndex - 1) * SessionConstants.LIMIT_FINDED_PERSONS;            Integer end = start + SessionConstants.LIMIT_FINDED_PERSONS;            searchPersons = searchParameters.getIntervalPersons(start, end, result.getValidPersons());        } catch (FenixServiceException e) {            errors.add("impossibleFindPerson", new ActionError(e.getMessage()));            saveErrors(request, errors);            return preparePerson(mapping, actionForm, request, response);        }        if (result == null || result.getValidPersons() == null) {            errors.add("impossibleFindPerson", new ActionError("error.manager.implossible.findPerson"));        }        if (searchPersons.isEmpty()) {            errors.add("impossibleFindPerson", new ActionError("error.manager.implossible.findPerson"));            saveErrors(request, errors);        }        if (!errors.isEmpty()) {            saveErrors(request, errors);            return preparePerson(mapping, actionForm, request, response);        }        int totalPersons = result.getTotalPersons();        List pagesList = getPageList(totalPersons);        request.setAttribute("totalFindedPersons", totalPersons);        request.setAttribute("personListFinded", searchPersons);        request.setAttribute("name", name);        request.setAttribute("roleType", roleType);        request.setAttribute("degreeId", degreeId);        request.setAttribute("departmentId", departmentId);        request.setAttribute("pages", pagesList);        request.setAttribute("startIndex", startIndex);        findPersonForm.set("name", name);        if (isEmployeeOrTeacher(userView)) {            request.setAttribute("show", Boolean.TRUE);        } else {            request.setAttribute("show", Boolean.FALSE);        }        Boolean viewPhoto = getCheckBoxValue((String) findPersonForm.get("viewPhoto"));        request.setAttribute("viewPhoto", viewPhoto);        return mapping.findForward("findPerson");    }