首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件开发 >

项目开发过程中技术小结

2012-11-23 
项目开发过程中技术总结有很多细节往往在项目设计阶段想不到,而到了实际开发的时候才发现其实没那么简单,

项目开发过程中技术总结
有很多细节往往在项目设计阶段想不到,而到了实际开发的时候才发现其实没那么简单,下面将开发过程中用到的一些小技术小结一下。
1、struts中doubleselect标签的使用
   很多时候会用到级联下拉框,例如通过下拉框选择一个省份希望在另一个下拉框中显示该省的城市,这时候我们考虑使用doubleselect标签。基本格式如下:
<s:doubleselect  name="tablerelation.hostTableId"
       list="tsMap.keySet()"   listKey="id" listValue="tableName"
       doubleName="tablerelation.hostFieldId"  doubleList="tsMap[top]"
       doubleListKey="id" doubleListValue="fieldName">
</s:doubleselect>,name是一级下拉框的name,list是一级下拉框的取值集,listValue是一级下拉框的显示值,listKey是对应的值,doubleName是二级下拉框的name,doubleList是二级下拉框的取值集,doubleListvalue是二级下拉框的显示值,doubleListkey是对应的值。
2. 将批量数据传入action时,采用Set<T>
  例如,我们要同时将两条表记录传到action中以便存储到数据表T中。我们在action中定义Set<T> records = new HashSet<T>();在jsp中为两个记录的标签命名时采用如下方式<input type="records.makeNew[index].field_x">,其中index表示记录索引,假设有两条记录,index取值为0和1,field_x为T中字段名。另外需要配置文件ActionName_conversion.properties中,配置如下:
KeyProperty_records=id
Element_records=org.sigsit.resource.T,这样就可以把两条记录的值同时传到action中了。
3. jsp中点击按钮打开模式页面,同时将模式页面填的值传回到jsp中实现
类似于数据库中定义好表结构,点击保存时弹出对话框填写表名,我们是通过jsp实现。我们在a.jsp中实现js函数openWindow(),代码如下:
function openwindow(){
    var link="b.jsp";//要打开的jsp
    var str= window.showModalDialog(link,window,"status:no;scroll:no;dialogWidth:235px;dialogHeight:100px");
    if(str!=null&&str!="undefined"){
document.getElementById("inputValue").value=str;
document.getElementById("form1").submit();
    }
},然后我们在b.jsp中实现js函数bconfirm()和bcancle(),分别用于确定和取消按钮,具体代码如下:
function bconfirm(){
var name = document.getElementById("inputName").value;
window.returnValue = name;
window.close();
}
function bcancel(){
   window.close();
},注意,在a.jsp中要有<input type="hidden" name="inputValue"/>,b.jsp中要有<input type="text" name="inputName"/>。这样就可以将b.jsp中填写的值传到a.jsp中,同时提交a.jsp中的表单。

热点排行