src/java/br/org/catolicasc/fcgf/projprog4/web/cmds/UserCRUDCmd.java
//Para criar e voltar a view de List

Para criar e voltar a view de List
Para criar e voltar a view de List
public String makeAndList(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        setCmdName(request);
        EntityManagerFactory factory = EntityManagerFactoryManager.getEntityManagerFactory();
        RuleDAO ruleDao = new RuleDAO(factory);
        UserDAO userDao = new UserDAO(factory);
        String name = request.getParameter(NOME);
        String email = request.getParameter(EMAIL);
        String password = request.getParameter(PASSWORD);
        String ruleId = request.getParameter(RULE);
        Rule rule = ruleDao.findRule(Long.parseLong(ruleId));
        User user = new User(name, email, password, rule);
        userDao.create(user);
        request.setAttribute(MESSAGE, "User created successfully.");
        return list(request, response);
    }
public String makeAndList ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { setCmdName ( request ) ; EntityManagerFactory factory = EntityManagerFactoryManager . getEntityManagerFactory ( ) ; RuleDAO ruleDao = new RuleDAO ( factory ) ; UserDAO userDao = new UserDAO ( factory ) ; String name = request . getParameter ( NOME ) ; String email = request . getParameter ( EMAIL ) ; String password = request . getParameter ( PASSWORD ) ; String ruleId = request . getParameter ( RULE ) ; Rule rule = ruleDao . findRule ( Long . parseLong ( ruleId ) ) ; User user = new User ( name , email , password , rule ) ; userDao . create ( user ) ; request . setAttribute ( MESSAGE , "User created successfully." ) ; return list ( request , response ) ; }
Para criar e voltar a view de List
Para criar e voltar a view de List