2017-11-27 6 views
0

자바 서블릿을 객체로 사용하여 오라클로부터 데이터를 가져 와서 동적으로 테이블을 생성하고 있습니다. 내 목표는 다른 java 서블릿에 행 num의 값을 전송하여 행을 편집하는 것입니다. 아래 예에서 경고의 값을 인쇄하려고 시도하는 동안 행의 마지막 값만 되돌립니다. 당신의 도움을 주셔서 감사합니다!자바 객체에서 자바 객체의 값을 얻으려고합니다.

코드 스 니펫 & javascript. 목표는 crObject.getRefNum()의 값을 java 서블릿으로 보내는 것입니다. 이것은 JSP에서 수행되고

<div class="container"> 
    <table class="table"> 
    <th>Ref #</th> 
    <th>CR #</th> 
    <th>Imapcted Application</th> 
    <th>Deployment Starts</th> 
    <th>Deployment Ends</th> 
    <th>Issue Description</th> 
    <th>Approval Status</th> 
    <th>Edit</th> 


    <% 
CRDetails crObject; 
for (int i = 0; i < listLength; i++) 
{ 
    crObject = (CRDetails) Alldata.get(i); 
    out.println("<tr><td>" + crObject.getRefNum() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getCrNum() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getAppName() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getDeployStartTime() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getDeployEndTime() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getIssueDesc() + "</td>" + "\n"); 
    out.println("<td>" + crObject.getStatus() + "</td>" + "\n"); 
    pageContext.setAttribute("refNum",crObject.getRefNum()); 
// pageContext.setAttribute("refNum",11); 

%> 
     <td><a editid="<%=crObject.getRefNum()%>" href="javascript:editRow()" target="_blank">Edit</a>${crObject.getRefNum()}</td> 

     <!--<c:out value = '${refNum}' />--> 
     <%  
} 


    %> 
테이블의

비주얼보기 :로 동적으로 편집 HREF를 변경 enter image description here

답변

0

:

자바 스크립트는 다음과 같이 약간 변형 된
<td><a name = "listLength1" id = "listLength1" value ="<%=crObject.getRefNum()%>" type = int href="javascript:editRow('<%=crObject.getRefNum()%>')" target="_blank">Edit</a></td> 

:

<script>function editRow(listLength1) {alert(listLength1);