mercredi 6 mai 2015

Here is my DAO:

public ReportType getByName(String type) {
    EntityManager em = emf.createEntityManager();
    try {
        ReportType rptype2 = em.find(ReportType.class, type);

        return rptype2;
    } catch (Exception e) {
        e.printStackTrace();
        em.close();
    }
    return null;
}

Here is my Action:

ReportDAO dao = new ReportDAO();
    List<ReportType> reportType = dao.show();
    list = new ArrayList<>();
    for (ReportType reportType1 : reportType) {
        list.add(reportType1.getName());
    }
    ReportTypeDAO rpDAO = new ReportTypeDAO();
    reporttype = rpDAO.getByName(type);

Here is my jsp:

 <h3>Type: <s:select list="list" name="type"></s:select>

Here is my table:

CREATE TABLE [dbo].[Report_Type](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](100) NULL,

When i submit, i receive a record in String format (Name), but i want to get this record ID. Is there any solution?

Thank you.

Aucun commentaire:

Enregistrer un commentaire