转换器 写了 没有反应呀(做的批量录入功能)

vigoss1282 2012-08-24 10:32:20
转换类中的 代码
package com.action.inventoryManagerment;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


import org.apache.struts2.util.StrutsTypeConverter;

import com.bean.inventoryManagerment.purchasingThe.PurchasingThemThe;


public class inventoryConvert extends StrutsTypeConverter //这里要继承struts2提供的转换基类

{

public Object convertFromString(Map context, String[] values, Class toClass ) //struts2里面的转换函数,将String转换为想要的类型

{
List<PurchasingThemThe> result =new ArrayList<PurchasingThemThe>();
for (int i = 0; i < values.length ; i++ )
{
PurchasingThemThe HomeWorkReg = new PurchasingThemThe(); //新建一个对象
HomeWorkReg.getPurchasingThe().setImptGrnnumber(values[i]); //依次将值保存到集合中
i++;
HomeWorkReg.setImpttPurchaseBatch(values[i]);
i++;
HomeWorkReg.setImpttSteelRollNumber(values[i]);
i++;
HomeWorkReg.setImpttBrand(values[i]);
i++;
HomeWorkReg.setImpttSpecifications(values[i]);
i++;
HomeWorkReg.setImpttWeight(values[i]);
i++;
HomeWorkReg.setImpttWareHousingHeavy(values[i]);
i++;
HomeWorkReg.setImpttMaterialCoding(values[i]);
i++;
HomeWorkReg.setImpttMateriaType(values[i]);
i++;
return result;
}
return result;

}

@Override
public String convertToString(Map arg0, Object arg1) {
// TODO Auto-generated method stub
return null;
}


}
配置转换类
paytuition1=com.action.inventoryManagerment.inventoryConvert









...全文
109 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
vigoss1282 2012-08-24
  • 打赏
  • 举报
回复

///action中的处理
package com.action.inventoryManagerment;
public List<PurchasingThemThe> getPaytuition1() {
return paytuition1;
}
public void setPaytuition1(List<PurchasingThemThe> paytuition1) {
this.paytuition1 = paytuition1;
}

public List<PurchasingThemThe>paytuition1;

public List<PurchasingThemThe> result;

public List<PurchasingThemThe> getResult() {
return result;
}
public void setResult(List<PurchasingThemThe> result) {
this.result = result;
public String addPurchasingThemThe() throws Exception {
//request.getParameterValues("paytuition1");
int mapsize=paytuition1.size(); //获得List对象的长度

for (int i = 0; i < mapsize; i++) //依次对List集合里的数据进行处理,处理函数还是按单条记录处理时一样
{
String imptGrnnumber=paytuition1.get(i).getPurchasingThe().getImptGrnnumber(); //通过list对象的方法get(arg0)获取值
String imptPurchaseBatch=paytuition1.get(i).getImpttPurchaseBatch();
String impttSteelRollNumber=paytuition1.get(i).getImpttSteelRollNumber();
String impttBrand=paytuition1.get(i).getImpttBrand();
String impttSpecifications=paytuition1.get(i).getImpttSpecifications();
String impttWeight=paytuition1.get(i).getImpttWeight();
String impttWareHousingHeavy=paytuition1.get(i).getImpttWareHousingHeavy();
String impttMaterialCoding=paytuition1.get(i).getImpttMaterialCoding();
String impttMateriaType=paytuition1.get(i).getImpttMateriaType();

if(inventoryBizImpl.addPurchasingThemThe(imptGrnnumber,imptPurchaseBatch,impttSteelRollNumber,impttBrand,impttSpecifications,impttWeight,impttWareHousingHeavy,impttMaterialCoding,impttMateriaType)) //在业务控制器中定义的处理函数,用于向数据库中添加记录
return "success";
else
{
addActionError( "录入学生作业信息出错,请刷新后重试!");
return "input";
}
}
return null;

}

页面设计
<s:iterator value="#session.searchLogisticsEarthlyDesirablesBylmledPurchasingBatchInformation" status="stat" >
<tr>
<td scope="col">
<input type="hidden" name="paytuition1" value="<%=session.getAttribute("purchasingThe.imptGrnnumber")%>" />
<input type="hidden" name="paytuition1" value="sm0001" />
<input type="hidden" name="paytuition1" value="原料" />

<input type="text" name="paytuition1" id="purchasingThemThe.impttPurchas eBatch" readonly="readonly" class="textnone" value="<s:property value="lmledPurchasingBatch"/>" /></td>
<td scope="col"><input type="text" name="paytuition1" id="purchasingThemThe.impttBrand" readonly="readonly" class="textnone" value="<s:property value="lmledBrand"/>" /></td>
<td scope="col"><input type="text" name="paytuition1" id="purchasingThemThe.impttSteelRollNumber" readonly="readonly" class="textnone" value="<s:property value="lmledSteelCoilNumber"/>" /></td>
<td scope="col"><input type="text" name="paytuition1" id="purchasingThemThe.impttSpecifications" readonly="readonly" class="textnone" value="<s:property value="lmledSpecifications"/>" /></td>
<td scope="col"><input type="text" name="paytuition1" id="purchasingThemThe.impttWeight" readonly="readonly" class="textnone" value="<s:property value="lmledWeight"/>" /></td>
<td scope="col"><input type="text" name="paytuition1" id="purchasingThemThe.impttWareHousingHeavy" value="<s:property value="lmledWeight"/>" /></td>
</tr>
</s:iterator>

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧