public Aluno pegaAlunoDoFormulario() {

    aluno.setNome(nome.getEditableText().toString());
    aluno.setEndereco(endereco.getEditableText().toString());
    aluno.setTelefone(telefone.getEditableText().toString());
    aluno.setSite(site.getEditableText().toString());
    aluno.setNota(Double.valueOf(nota.getProgress()));

    return aluno;
  }
  public static void main(String[] args) {
    Aluno a1 = new Aluno();
    Aluno a2 = new Aluno();
    Aluno a3 = new Aluno();
    Aluno a4 = new Aluno();

    a1.setNome("João");
    a2.setNome("José");
    a3.setNome("Pedro");
    a4.setNome("Maria");

    Vetor lista = new Vetor();

    lista.adiciona(a1);
    lista.adiciona(a2);
    lista.adiciona(a3);
    lista.adiciona(a4);

    System.out.println(lista);
  }
Beispiel #3
0
  /** @param args the command line arguments */
  public static void main(String[] args) {
    // TODO code application logic here

    Aluno a1 = new Aluno();
    a1.setNome("Matheus");
    a1.setIdade(21);

    AlunoJpaController a1Jpa = new AlunoJpaController();

    a1Jpa.create(a1);
  }
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    System.out.println(getClass() + "Inicio........");
    Aluno aluno = new Aluno();
    aluno.setMatricula(2221L);
    aluno.setNome("Maria da Silva");
    enviarObjetoForma2(aluno);
    System.out.println(getClass() + "Fim........");

    PrintWriter out = response.getWriter();
    out.print("<H1>Objeto enviado com sucesso! JMS 2.0</H1>");
  }
  protected void service(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    String paramMatricula = req.getParameter("matricula");
    String matricula = paramMatricula == null ? "" : paramMatricula;

    String paramNome = req.getParameter("nome");
    String nome = paramNome == null ? "" : paramNome;

    String paramFone = req.getParameter("fone");
    String fone = paramFone == null ? "" : paramFone;

    String paramCpf = req.getParameter("cpf");
    String cpf = paramCpf == null ? "" : paramCpf;

    String paramEvento = req.getParameter("evento");
    String evento = paramEvento == null ? "" : paramEvento;

    Aluno aluno = new Aluno();
    aluno.setMatricula(matricula);
    aluno.setNome(nome);
    aluno.setFone(fone);
    aluno.setCpf(cpf);

    if (evento.equals("Incluir")) {
      if (!matricula.equals("")) {
        aluno.incluir();
      }
    } else if (evento.equals("Alterar")) {
      if (!matricula.equals("")) {
        aluno.alterar(matricula, nome, fone, cpf);
      }
    } else if (evento.equals("Excluir")) {
      if (!matricula.equals("")) {
        aluno.excluir(matricula);
      }
    }

    req.setAttribute("aluno", aluno); // Passando um objeto para o JSP.

    List<Aluno> alunos = Aluno.listar();
    req.setAttribute("alunos", alunos); // Passando uma coleção para o
    // JSP.

    // Chamar o JSP apenas para mostrar o resultado.
    req.getRequestDispatcher("CadastroAlunoView.jsp").forward(req, resp);
  }