I use this to put the information inside the object MerchanType that is in the Order object
Code:
<s:form action="ordersFilter" theme="simple" cssClass="yform">
<s:hidden name="order.users.intIdUser" id="order.users.intIdUser"
value="" />
<table>
...
<td><s:label>Tipo de mercancĂa: </s:label></td>
<td><s:select id="order.merchanType.intIdMercType"
name="order.merchanType.intIdMercType"
headerValue="--- Seleccione Tipo Mercancia ---" headerKey="0"
list="listadoTipoMercancias" listKey="intIdMercType"
listValue="varMercTypeDescription" /></td>
...
</table>
</s:form>
When the user don't select anything, the merchan object gets initialize with a 0 value.
Then I do this
Code:
public class Orders implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private Integer intIdOrder;
private MerchanType merchanType;
private Date datDateRec;
private Date datLastModified;
private Date datAlbaran;
private String varMercType;
...
public void update(Orders order) {
Orders persistent = orderDAO.loadById(order.getIntIdOrder());
if (persistent != null) {
try {
BeanUtils.copyProperties(persistent, order);
orderDAO.persist(persistent);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
} else {
orderDAO.persist(order);
}
With this and the configuration I have, I only get updated the information of the order object (for example datAlbaran) that isn't in another object (for example the merchanType object where the id of the type of merchan is stored)
When there is no merchanType selected I've tried initializing it to a new MerchanType or to null to get rid of the 0 value that I get from the form but then I get the error I mention before
Why does the insert work with insert="false"? I don't really know. I tried that configuration in order to solve this problem with the not selected information and it worked but with the update, if I put the update="false" I get updated the information of the order object but not the information stored in the other objects of the class Order