* wouldn't be secure.
*/
public void doInsert(RunData data, Context context)
throws Exception
{
Product entry = new Product();
data.getParameters().setProperties(entry);
String myCode=data.getParameters().getString("productcode");
entry.setCreatedBy(data.getUser().getUserName());
entry.setCreated(new Date());
entry.setModifiedBy(data.getUser().getUserName());
entry.setModified(new Date());
if (myCode.equals("AUTO"))
{
entry.setProductCode(getTempCode());
Connection conn = Transaction.begin(ProductPeer.DATABASE_NAME);
boolean success = false;
try {
entry.save(conn);
entry.setProductCode(getRowCode("PR", entry.getProductId()));
entry.save(conn);
Transaction.commit(conn);
success = true;
} finally {
if (!success) Transaction.safeRollback(conn);
}
}
else
{
entry.save();
}
}