2016-04-29 10 views
0
<c:forEach var="i" begin="0" end="3" step="1"> 
<div class="col-md-3" style="margin-right: 0% !important"> 
    <a href="#" class="thumbnail book"> 
     <%            
     String TCurlI = "Def"; 
     String idImgIII = "null"; 
     pageContext.setAttribute("TCurlI", new String(TCurlI)); 
     pageContext.setAttribute("idImgIII", new String(idImgIII)); 
     %> 
     <c:if test="${not empty sessionScope.livresTC[i].titre }"> 
      <c:set var="TCurlI" value="${sessionScope.livresTC[i].titre }"></c:set> 
      <c:set var="idImgIII" value="${sessionScope.livresTC[i].numInventaire }"></c:set> 
     </c:if> 

     <img id="${idImgIII }" src="../media/Pics/<c:out value="${TCurlI }"></c:out>.jpg" alt="image" > 

    </a> 
</div> 

は、idが私すでにこれは私がIMG のid ND URLを取得する方法であると私はIMGをクリックすると、JSTL

によって生成されたクリック)(

$('.book, .book *').click(function(event){//}); 

はNDセッションが方法 `のArrayListのlivresの=のdb.getAllLivresが充填されているパネルを示しJSコードを持っています。

public ArrayList<Livre> getAllLivres() throws Exception { 
    ArrayList<Livre> listeLivres = new ArrayList<Livre>(); 
    Livre livre; 
    rs = stmt.executeQuery("select * from Livre"); 
    while(rs.next()){ 
     /*(int numInventaire 1, 
     * String cote 2, 
     * String titre 3, 
     * int idAuteur 5, 
     * int idEdition 6, 
     * boolean disponible 4, 
     * String intituleNiveau 7, 
     * int idGenre 8), 
     * Date dateAjout 9*/ 
     livre = new Livre(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getInt(5), rs.getInt(6), rs.getBoolean(4), rs.getString(7), rs.getInt(8), rs.getDate(9)); 
     listeLivres.add(livre); 
    } 
    return listeLivres; 
} 

今私は情報の残りの部分(コート、力価、...)と同じJSPページ内のフォームを記入する必要がありますが、numInventaireは、IMGはあなたが別のJSPを作成することができ、ID

答えて

0

をクリック等しいです'ID'のようないくつかの要求パラメータに基づいてフォームをレンダリングします。

String id = request.getParameter("id"); 
//retrieve 'livre' instance with the given ID 

そして、あなたのjavascriptのクリックのリスナーに、あなたは、AJAXを使用しているJSPファイルを要求することができますし、あなたのポップアップinnerHTMLプロパティに結果を追加します。

$('.book, .book *').click(function(event){ 
    //Get id from clicked item 
    var id = $(this).attr('id'); 

    //request the form jsp by id of livre 
    $.ajax('formJspFile.jsp?id=' + id , { 
     success:function(data){ 
      //add the form jsp content to the popup div. 
      $('#popupDiv').html(data); 
     } 
    }); 
}); 
関連する問題