2014-06-19 2 views
0

나는 내 JSP에 다음 코드가팝업이

function doContractAction(actionUrl) { 

     var strActionUrl = actionUrl; 
     if(strActionUrl !=null) { 
      document.forms[0].action = actionUrl; 
      document.forms[0].submit(); 
      } 
     return false; 
    } 

<div id="content"> 
    <div id="report"> 
    <s:form name="openControl" id="myActionForm" theme="simple" action="ShowAlertReports" method="post"> 
     <div id="accordion"> 

      <s:iterator id="alertCat" value="alerts" status="status" > 

       <h2 style="font-size:1.1em; padding-top:0px;padding-left:1px;padding-bottom:-5px; font-weight:bold;"> 
       <p align="left"><s:property value="%{key}"/></p> 
       </h2> 
       <br> 
       <div> 

        <table id="${status.index}" class="grid one-em-below constant-left-width" cellspacing="0" d="ad-hoc-reports"> 
         <thead class="nosort"> 
          <tr> 
           <th scope="col" class="sortAsc" onclick="applySort(this);"><a style="cursor:pointer; color: #0066FF; font-weight:bold;">Alert Name </a></th> 
           <th scope="col" onclick="applySort(this);"><a style="cursor:pointer; color: #0066FF; font-weight:bold;">Customer Name</a></th> 
           <th scope="col" onclick="applySort(this);"><a style="cursor:pointer; color: #0066FF; font-weight:bold;">Date Opened</a></th> 
           <th scope="col">Action</th> 

          </tr> 
         </thead > 
         <tbody style="font-size:12px;"> 
          <s:iterator id="alertsubcat" value="%{value}"> 
           <tr> 
            <td> 
             <s:property value="name"/> 
            </td> 
            <td> 
             <s:property value="customerName"/> 
            </td> 
            <td style="font-size:11px;"> 
             <s:if test="%{display=='OK'}"> 
             <input type="button" value='<s:property value="%{display}" />' 
              onclick='return closeInfoAlert("<s:property value="%{alertsNotificationId}" />");' /> 
             </s:if> 

             <s:else> 
              <input type="button" value='<s:property value="%{display}" />' 
              onclick='return doContractAction("<s:property value="%{url}" />");' /> 
             </s:else> 
            </td> 

           </tr> 
          </s:iterator> 

         </tbody> 
        </table> 
        <br> 
       </div> 
      </s:iterator> 
     </div> 
    <s:hidden name="description" id="description" value=""/> 
    </s:form> 
<br> 
</div> 
</div> 

지금 <p align="left"><s:property value="%{key}"/></p>

  1. Alert1, Alert2 Alert3 등
을 가질 수있다

내 요구 사항은 코드에서입니다.

<s:else> 
    <input type="button" value='<s:property value="%{display}" />' 
    onclick='return doContractAction("<s:property value="%{url}" />");' /> 
</s:else> 

난 {키}를 값 = "%를 전달하기 위해 필요한 기능 doContractAction 체크되며 I는 키 값을 확인할 수 있고 그것이 Alert1 또는 경보 2 같으면. 팝업 창이 열립니다

어떻게 처리합니까?

+0

URL을 사용하여 p의 값을 얻을 수 있습니다; } – ronan

+1

달성하려는 목표는 무엇입니까? –

답변

1

당신은 고유 ID를 루프에서 각 요소의를 제공하기 위해 struts2 카운터를 사용할 수 있습니다, 내가 here

이제 고유 ID를 Button<p>에의를 제공 struts2에서 카운터를 참조 할 수있는 링크를 제공 한 지금 당신은해야합니다

<p id="p-0" align="left"> <input id="input-0" type="button"> 
<p id="p-1" align="left"> <input id="input-1" type="button"> 
... 
<p id="p-n" align="left"> <input id="input-n" type="button"> 

아래로 주어진 요소 지금 당신은 당신이 참조 할 수 this.id를 사용하여 버튼의 ID를 전달할 수 있습니다 here

input-id을 나눌 수 있고 p-id을 지정할 수 있습니다. 일단 당신은 p-id을 얻습니다. 지금 당신의 getURL이 공공 문자열의 getURL을 (즉 함수) {// 일부 코드 반환 URL에서 자바 클래스에 정의되어 getElementById()