Hi
I have build my own framework for create, update or delete entities, show lists from entity-table or edite a specific entity.
So I have a abstrakt class to save/edit an entity
public abstract class AbstractEditorBean<T extends BaseEntity> extends AbstractBusinessBean<T> implements Serializable
public abstract class AbstractListBean<T extends BaseEntity> extends AbstractBusinessBean<T> implements Serializable
@TransactionAttribute(TransactionAttributeType.REQUIRED) @End public String save(){ T entity = getEntity(); preProcedure(); try{ if(state == NEW){ em.persist(entity); } if(state == MODIFIED){ em.merge(entity); } em.flush(); }catch(Exception ex){ //ejbCtx.setRollbackOnly(); ex.printStackTrace(); } return "save"; } @SuppressWarnings("unchecked") @Begin(nested=true) public String edit(){ try{ T find = (T)em.find(getEntityClass(), id); setEntity(find); state = MODIFIED; }catch(Exception ex){ ex.printStackTrace(); } return "edit"; }
most important part is missing here - what is on the page.