I'm developing a web application where I have a list of an object called frames
, well, every time I click on a button I add a new object to that list, but the problem is this: When I try to add a new object for the 2nd time to this list, the first object that was previously inserted disappears, as if nothing was inserted, only the 2nd object being inserted, not the 1st and 2nd objects, ie , you are always saving the last inserted object. How do I save as many objects as I need to add to this list?
Well I have this so far, when the user clicks on add, will open a screen to fill some information about which object I mentioned: This is the button:
<p:commandLink id="btn_close_users_modal3" actionListener="#{messageBean.insertFrame()}"
styleClass="btn btn-default" >
<i class="fa fa-plus fa-fw" /> #{bundle['system.ui.label.add.frameAdd']}
</p:commandLink>
And this is my method, in which what you have to do and then adds to a list.
public void insertFrame() {
try {
// caso nao visualize a mensagem e salve direto, chama de qualquer forma esse metodo
teste();
frame.setContent(svg);
frame.setWriteContent(objSvg.getValueText1() + " / " + objSvg.getValueText2());
frame.setRemoved("f");
frame.setOrder(1);
frame.setLogo('f');
listAllFrames.add(frame);
MessageGrowl.info(MessageProperties.getString("message.sucesso"));
RequestContext.getCurrentInstance().execute("PF('framesModal').hide();");
// frameFacade.save(frame);
} catch (Exception e) {
e.printStackTrace();
}
}