lundi 22 août 2016

Modal problems with get the attribute from the servlet

I have a problem with my code. I just to make a edit field modal and i cant take the attribute from the Servlet. My modal will not connect to a href, he just appear when i press a button and i want to set inputs with my object attribute.

        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String sId = req.getParameter("id");
        log.info("sID din servlet", sId);
        Integer idCompany = null;
        try {
            ClientsDAO dao = new JdbcClientsDao();
            Client a = dao.getClient(Integer.parseInt(sId));
            req.setAttribute("currentClient", a);
             idCompany = a.getIdCompany();

        } catch (Exception e) {
            log.error("error editting Client", e);
        }
        req.getRequestDispatcher("/jsp/list-clients.jsp?idCompanyBase=" + idCompany).forward(req, resp);
    }
   the servlet Method;

    <div class="modal fade " id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Edit Client</h4>
      </div>

      <div class ="modal-body">


        <form name="EditForm" id="EditForm" class = "form-horizontal" action="${pageContext.request.contextPath}/edit-client-servlet" method="post">

    <div class="form-group form-group-sm">

        <label for="companyname" class="col-sm-2 control-label ">Client <span style="color:red;">*</span> Company name </label>
        <div class="col-sm-10">
         <input class="form-control" id="editcompanyname" type="text" " name="editcompanyname"  aria-describedby="helpBlock2"/> 
            </div>
            </div>
            <div class="form-group form-group-sm">
            <label for="taxid" class="col-sm-2 control-label" >Tax ID <span style="color:red">*</span></label>
            <div class="col-sm-10">
                <input class="form-control" type="text" value="" name="edittaxid" id="edittaxid" /> 
            </div>
            </div>`
</form>




    Client myClient= (Client)request.getAttribute("currentClient");

Aucun commentaire:

Enregistrer un commentaire