环境描述:就像你一般在论坛上发表文章,可能带附件,附件的数量是你手动添加删除的!!
/************************************************************************
*** 添加审批表单模板
************************************************************************/
// 增长的索引
var itemindex = 1000;
// 数量
var counter = 0;
// 模板
var itemtemplate = '';
itemtemplate += '
';
itemtemplate += ' 表单字段';
itemtemplate += ' ';
itemtemplate += ' 值类型 ';
itemtemplate += ' 字符串';
itemtemplate += ' 数字(整数)';
itemtemplate += ' 日期(yyyy-mm-dd)';
itemtemplate += ' ';
itemtemplate += ' ';
itemtemplate += '
';// 添加
function additem() {
var s = itemtemplate.replace(/#itemindex#/g, itemindex);
$(#divformfields).append(s);
itemindex ++;
counter ++;
}
// 删除
function delitem(index) {
$(#item_ + index).remove();
counter = counter - 1;
}
public class flowformconfigactionform extends actionform {
private int id;
private string name;
private string processname;
private string formfilltemplatepath;
private string formshowtemplatepath;
private map flowformfieldcfgmap = new treemap();
/** 表单复杂属性 */
public flowformfieldconfig getflowformfieldcfgelement(string key){
if(!flowformfieldcfgmap.containskey(key)){
flowformfieldcfgmap.put(key, new flowformfieldconfig());
}
return flowformfieldcfgmap.get(key);
}
*u*****
public class flowformfieldconfig {
private int id;
private string name;
private class> valuetype;
主要要原理是:struts1.*在jsp显示的时候,会先从formbean里通过get***方法拿出属性的值!!
flowformfieldcfgelement(#itemindex#).name 这是核心,如果flowformfieldcfgelement(#itemindex#)为空的话,就会出错,所以在/** 表单复杂属性 */
public flowformfieldconfig getflowformfieldcfgelement(string key){
if(!flowformfieldcfgmap.containskey(key)){
flowformfieldcfgmap.put(key, new flowformfieldconfig());
}
return flowformfieldcfgmap.get(key);
}
做了判断!!
如果还有不懂的人可以给我留言!!
