我要制作一个表单。A用户录入信息后,B用户能够查看到A录入的表单信息。并添加新的数据更新表单。请问大家是怎么处理的? 我在Action中查询得打这条表单信息的info 对象(info对象中包含这个表单的信息字段);得到这个info对象后跳转到B用户能查看的页面。表单上面显示出A用户已经填写的信息,下面B用户填写,更新表单! 问题就出在这。我在B用户添加信息update后。A用户添加的信息全部被置空,只有B新增加的信息,请问问题出在哪儿,大家是怎么处理的(难道必须要将之前A用户提交的信息提取出来放到<s:hidden>中么,除开这个方法还有更好的解决方法么?) 1、这是Action中取出需要更新的表单记录对象
Java代码
public String viewOrder(){
HttpServletRequest request = ServletActionContext.getRequest();
Long orderId = Long.valueOf(request.getParameter("id"));
Info oi = orderDao.findByID(orderId);
this.setInfo(oi);
return "edit"; //取出Info对象,此处将转到修改这条信息的页面
} public String viewOrder(){
HttpServletRequest request = ServletActionContext.getRequest();
Long orderId = Long.valueOf(request.getParameter("id"));
Info oi = orderDao.findByID(orderId);
this.setInfo(oi);
return "edit"; //取出Info对象,此处将转到修改这条信息的页面
}
2、
Java代码
/*上面通过struts2 标签打印出A用户添加的信息*;下面由B用户添加表单的其他字段信息*/
<form action="info!update.action" method="post" name="serviceAction">
<div id="service" class="flowdiv" >
<s:hidden name="info.id"></s:hidden>
<table class="flowtable" id="servicePerson">
<tr>
<td width="694"><div>
<span style="width: 700px;height: 24px;display: block"><label style="width: 240px;height: 24px;display: block;float:left">制单人:<s:property value="info.makeOrderId" /></label>
<label>ERP单号:<s:textfield name="viewOrder.erpCode" /></label></span><br/>
<span style="width: 700px;height: 24px;display: block"><label style="width: 240px;height: 24px;display: block;float:left">技术审核:<s:textfield name="info.techer"></s:textfield>
</label><label>领导审核:<s:textfield name="info.leader"/></label>
</span>
</div>
</td>
</tr>
</table>
</div>
<s:submit value="保存" name="sepbt" cssClass="btnfloat"></s:submit>
</form> /*上面通过struts2 标签打印出A用户添加的信息*;下面由B用户添加表单的其他字段信息*/
<form action="info!update.action" method="post" name="serviceAction">
<div id="service" class="flowdiv" >
<s:hidden name="info.id"></s:hidden>
<table class="flowtable" id="servicePerson">
<tr>
<td width="694"><div>
<span style="width: 700px;height: 24px;display: block"><label style="width: 240px;height: 24px;display: block;float:left">制单人:<s:property value="info.makeOrderId" /></label>
<label>ERP单号:<s:textfield name="viewOrder.erpCode" /></label></span><br/>
<span style="width: 700px;height: 24px;display: block"><label style="width: 240px;height: 24px;display: block;float:left">技术审核:<s:textfield name="info.techer"></s:textfield>
</label><label>领导审核:<s:textfield name="info.leader"/></label>
</span>
</div>
</td>
</tr>
</table>
</div>
<s:submit value="保存" name="sepbt" cssClass="btnfloat"></s:submit>
</form> 3.提交以后A填写的所有数据将被清空,只有B新增的数据;
4.Hibernate 文件中 dynamic-update="true"
dynamic-insert="true"
Java代码
public String viewOrder(){
HttpServletRequest request = ServletActionContext.getRequest();
Long orderId = Long.valueOf(request.getParameter("id"));
Info oi = orderDao.findByID(orderId);
this.setInfo(oi);
return "edit"; //取出Info对象,此处将转到修改这条信息的页面
} public String viewOrder(){
HttpServletRequest request = ServletActionContext.getRequest();
Long orderId = Long.valueOf(request.getParameter("id"));
Info oi = orderDao.findByID(orderId);
this.setInfo(oi);
return "edit"; //取出Info对象,此处将转到修改这条信息的页面
}
2、
Java代码
/*上面通过struts2 标签打印出A用户添加的信息*;下面由B用户添加表单的其他字段信息*/
<form action="info!update.action" method="post" name="serviceAction">
<div id="service" class="flowdiv" >
<s:hidden name="info.id"></s:hidden>
<table class="flowtable" id="servicePerson">
<tr>
<td width="694"><div>
<span style="width: 700px;height: 24px;display: block"><label style="width: 240px;height: 24px;display: block;float:left">制单人:<s:property value="info.makeOrderId" /></label>
<label>ERP单号:<s:textfield name="viewOrder.erpCode" /></label></span><br/>
<span style="width: 700px;height: 24px;display: block"><label style="width: 240px;height: 24px;display: block;float:left">技术审核:<s:textfield name="info.techer"></s:textfield>
</label><label>领导审核:<s:textfield name="info.leader"/></label>
</span>
</div>
</td>
</tr>
</table>
</div>
<s:submit value="保存" name="sepbt" cssClass="btnfloat"></s:submit>
</form> /*上面通过struts2 标签打印出A用户添加的信息*;下面由B用户添加表单的其他字段信息*/
<form action="info!update.action" method="post" name="serviceAction">
<div id="service" class="flowdiv" >
<s:hidden name="info.id"></s:hidden>
<table class="flowtable" id="servicePerson">
<tr>
<td width="694"><div>
<span style="width: 700px;height: 24px;display: block"><label style="width: 240px;height: 24px;display: block;float:left">制单人:<s:property value="info.makeOrderId" /></label>
<label>ERP单号:<s:textfield name="viewOrder.erpCode" /></label></span><br/>
<span style="width: 700px;height: 24px;display: block"><label style="width: 240px;height: 24px;display: block;float:left">技术审核:<s:textfield name="info.techer"></s:textfield>
</label><label>领导审核:<s:textfield name="info.leader"/></label>
</span>
</div>
</td>
</tr>
</table>
</div>
<s:submit value="保存" name="sepbt" cssClass="btnfloat"></s:submit>
</form> 3.提交以后A填写的所有数据将被清空,只有B新增的数据;
4.Hibernate 文件中 dynamic-update="true"
dynamic-insert="true"
你的意思是说。A用户填写的信息经过action之后在B用户填写并提交之后,连A用户的一期提交。是吧?
可是现在问题是A之前的信息不存在了有个办法。。不用放到hidden,放到session也行。哈哈。。添加后清空。。不过之前做的都是hidden。。不过要是数据很多的话<hidden1><hidden2><hidden3><hidden4>.....
A<——新实例<——B这样应该可以解决你那个问题