对于数据集 列表允许删除和修改,还要在同一一个页面实现添加,如何实现?
因为
|
which will use the value of the request parameter named "method" to pick the appropriate "execute" method, which must have the same signature (other than method name) of the standard Action.execute method. For example, you might have the following three methods in the same action:
|
and call one of the methods with a URL like this: http://localhost:8080/myapp/saveSubscription.do?method=update
管理员可以在这个界面上动态加载与减少选项的个数,就有点像点击一个按钮,然后增加表格中的一行,或者再点击一个按钮,就删除表格中的一行。
不知道这个是不是你想要的东东
上传图片看不见,上传了一个附件::::
就是在列表上可以修改列内容,点击“修改”按牛提交;
在最末行可以添加新内容,点“添加”按纽提交;
可以复选多行,点“删除”按纽提交;
h除
碚f, 你要透^ javascript 砜刂
假O裼 DispatchAction , ⒄丈厦嫫渌怂
假O判ψ atype, 你要嵌入 input hidden name="action"
1,修改...
onclick="javascript:updateData(1)" , 1 是指序, jsp 要A先a生
另外嵌入一 input hidden name="uid"
updateDate(id) {
document.forms[0].uid.value=id;
document.forms[0].atype.value="update";
document.forms[0].submit();
}
2.新增
onclick="javascript:insertData()" ,
insertData() {
document.forms[0].atype.value="insert";
document.forms[0].submit();
}
3.h除
onclick="javacript:deleteData()" ,
deleteData() {
document.forms[0].atype.value="delete";
document.forms[0].submit();
}
h除的程式比^麻, 你自己想一想如何去接 checkbox array .
不^你的 update }也是和 delete 一拥
基本上, ActionForm 都是可以接收 Array 的,
你可以在 FormBean 就封b成 List,
Action 就可以直接用了
for example,
JSP
<%@ page language="java"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html>
<html:form action="/" >
<logic:iterate id="bean" name="exampleListForm" property="beanList" indexId="i"/>
<html:text name="exampleListForm" property="<%=\"employee[\" + i \"].name\"%>">
<html:text name="exampleListForm" property="<%=\"employee[\" + i \"].salary\"%>">
</logic:iterate>
</html:form>
</html:html>
FormBean:
import java.util.ArrayList;
import java.util.List;
import org.apache.struts.action.ActionForm;
public class ExampleListForm extends ActionForm {
private List beanList = new ArrayList();
public List getBeanList(){
return beanList;
}
public void setBeanList(List list){
beanList = list;
}
public Employee getEmployee(int index){
while(index >= beanList.size()){
beanList.add(new Employee());
}
return (Employee)beanList.get(index);
}
public void setEmployee(int index,Employee emp){
beanList.set(index,emp);
}
}
BeanClass
public class Employee {
private String name;
private String salary;
public String getName() {
return name;
}
public String getSalary() {
return salary;
}
public void setName(String name) {
this.name = name;
}
public void setSalary(String salary) {
this.salary = salary;
}
}
只要你能用 jsp 出淼,
一定可以改成 struts 架 ^^~