這是以下2個鏈接的延續....由於我無法張貼這些任何評論...發送參數從JSP Struts2的action類的方法
1. Populating a table based on values chosen from a drop down in struts2 application
和
我也有相同的場景,我需要從下拉列表中打印基於所選值的表格,在我的谷歌搜索中我得到了這個頁面,並且我在這裏使用了建議。但是,當我在我的下拉列表中選擇一個值,我得到的表格打印和頁面仍然留在同一頁面沒有任何更新和下面是我的代碼...幫助我在這...
javascript
<script type="text/javascript">
function showAllocationStatusJavaScript(){
var batchURL1="<s:property value="#batchURL"/>";
$.ajax({
url:batchURL1,
type: 'get',
beforeSend: function(){
$("#loading").show();
alert("parsed");
},
success: function(result){
if(result!=''){
$('myTableWrapper').html(result);
} else {
alert(result);
}
},
});
}
</script>
jsp的身體
<s:select label="Select Batch" headerKey="-1" headerValue="Select a Batch..."list="%{#session.Batchs}" Value="batch" name="batch" onchange="showAllocationStatusJavaScript()" id="batch"/>
URL標記
內<s:url action="doShowAllocationStatus" var="batchURL"><param value="%{batch}"/></s:url>
此表以打印我的列表
<div id="myTableWrapper">
<table align="center" border="2">
<tr>
<th>TAN</th>
<th>Curator</th>
<th>Curator Status</th>
<th>QC</th>
<th>QC Status</th>
</tr>
<s:iterator value="allocationList" >
<tr>
<td><s:property value="tan"/></td>
<td><s:property value="curator"/></td>
<td><s:property value="curator_status"/></td>
<td><s:property value="qc"/></td>
<td><s:property value="qc_status"/></td>
</tr>
</s:iterator>
</table>
</div>
struts.xml的
<action name="doShowAllocationStatus" class="controller.AllocateTAN" method="showAllocationStatus" >
<result name="success" type="dispatcher" >Allocation.jsp</result>
AllocateTAN動作類
//Fields that hold data...
private List<BatchInfo> allocationList =new ArrayList<BatchInfo>();
private String batch;
private List<String> batchs = new ArrayList<String>();
private String TAN;
private List<String> Tans = new ArrayList<String>();
private String user;
private List<String> users = new ArrayList<String>();
//and all getters and setters....
.....
//variable used to access DataBase...
CationDAO dao1 = new CationDAO() ;
//flow 1.: making all details available for the allocate TAN page...when page page is loaded 1st time
public String AllocatingTANpageDetails() throws SQLException{
Map<String, Object>session=ActionContext.getContext().getSession();
this.batchs=dao1.Batch_List();
session.put("Batchs", batchs);
//Tans=dao1.Tan_list(getBatch());
this.users=dao1.Users_List();
session.put("users", users);
return SUCCESS;
}
private void showTANlist(String Batch1) throws SQLException{
Map<String, Object>session=ActionContext.getContext().getSession();
Tans=dao1.Tan_list(Batch1);
session.put("Tans", Tans);
}
//flow 2.: showing Allocation Status in Table form...in same page
public String showAllocationStatus() throws SQLException {
Map<String, Object>session=ActionContext.getContext().getSession();
//setBatch(batch_value);
session.put("Batch",batch);
showTANlist(batch);
System.out.println("Processing Allocation List... ");
this.allocationList=(List<BatchInfo>)dao1.status(batch);
System.out.println("Finished...");
return SUCCESS;
}
//execute method form allocating a TAN for a user...
public String execute(){
return SUCCESS;
}
你的Action類更新allocationList? –
另外顯示我們的行動類代碼 –
是的,我正在更新! –