0
在我的struts2 web應用程序中,我有一個包含dojo sx:div的表單。當我刷新這個div時,所有表單的數據都是空的。當我點擊按鈕「Refres Div」時,屬性listIdSelected在方法範圍搜索,它是空的。我發現在某些情況下,JSP頁面中可能有幾種形式。是最好的解決方案嗎?我不喜歡這種做法,使用JSF這種情況更容易管理。所有表單的數據都爲null,其中dojo sx:div刷新
JSP文件:
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<link rel="stylesheet"
href="<s:url value="/css/jquery.multiselect.css"/>" type="text/css" />
<link rel="stylesheet"
href="<s:url value="/css/jquery.multiselect.filter.css"/>"
type="text/css" />
<link rel="stylesheet"
href="<s:url value="/css/themes/base/jquery.ui.theme.css"/>"
type="text/css" />
<script type="text/javascript"
src="<s:url value="/js/jquery-1.9.1.min.js" />"></script>
<script type="text/javascript"
src="<s:url value="/js/jquery-ui.min.js" />"></script>
<script type="text/javascript"
src="<s:url value="/js/jquery.multiselect.min.js" />"></script>
<script type="text/javascript"
src="<s:url value="/js/jquery.multiselect.filter.js" />"></script>
<script language="javascript">
$(function() {
$("select").multiselect({
multiple : true,
selectedList : 4,
height : 180
});
$("select").multiselect().multiselectfilter();
});
function refreshDiv() {
dojo.event.topic.publish("/listTopic", "0", "1");
}
</script>
<s:form id="idForm" action="validationAction.do" name="MyForm"
theme="simple">
<div class="contentTable">
<div class="tbl">
<table width="100%">
<tr>
<td><s:select id="idCombo" multiple="true" list="listItems"
name="listIdSelected" value="listIdSelected" listKey="id"
listValue="label" emptyOption="true" /></td>
</tr>
</table>
</div>
</div>
<div class="contentTable">
<div class="tbl">
<div class="bloc_action">
<input class="btn_action" type="button" onclick="refreshDiv();"
value="Refresh the div" />
</div>
<sx:div id="listDiv" href="searchAction.do" formId="listForm"
listenTopics="/listTopic" theme="ajax">
</sx:div>
</div>
</div>
<div class="bloc_action">
<s:submit cssClass="btn_action" value="Submit form"></s:submit>
</div>
</s:form>
Java文件:
package com.omb.controller.report;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.omb.ui.item.Item;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
@SuppressWarnings("serial")
public class MyAction extends ActionSupport implements Preparable {
Log log = LogFactory.getLog(MyAction.class);
private List<Item> listItems = new ArrayList<String>();
private List<String> listIdSelected;
public void prepare() throws Exception {
listItems.add(new Item("1", "Item 1"));
listItems.add(new Item("2", "Item 2"));
listItems.add(new Item("3", "Item 3"));
listItems.add(new Item("4", "Item 4"));
}
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = true)
public String validation() throws Exception {
// do validation
return SUCCES;
}
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = true)
public String search() throws Exception {
log.debug("listIdSelected.size() = " + listIdSelected.size());
return "displayResultList";
}
public List<Item> getListItems() {
return this.listItems;
}
public void setListItems(List<Item> listItems) {
this.listItems = listItems;
}
public List<Integer> getListIdSelected() {
return this.listIdSelected;
}
public void setListIdSelected(List<Integer> listIdSelected) {
this.listIdSelected = listIdSelected;
}
}
好像你正在使用錯誤的'formId'。 BTW S2 dojo插件很久以前就被棄用了。 –
這是一箇舊的應用程序,我恢復了演變。 Dojo插件在這個應用程序中非常用,我在struts2中沒有很大的經驗。而客戶端不想改變...我不明白你想在這裏說什麼「好像你正在使用錯誤的formId」 –
'
'vs''。 –