I'm facing some problems in the following scenario. I've a page where I have multiple fields and I need to add multiple item, using an autocomplete component. For instance, I've a checkout object, and I need to add different product, with quantity, into a table and others fields such as the date etc... This is the part I'm facing some problems:
<p:panelGrid columns="3" layout="grid"
styleClass="ui-panelgrid-blank form-group">
<h:panelGroup styleClass="md-inputfield">
<p:autoComplete id="acEquipment"
value="#{createOrderSelectionView.equipment}"
completeMethod="#{createOrderSelectionView.completeTextEquipment}"
style="margin-bottom:10px;" var="equipment"
itemLabel="#{equipment}" converter="equipmentConverter"
itemValue="#{equipment.pk}" forceSelection="true">
</p:autoComplete>
</h:panelGroup>
<h:panelGroup styleClass="md-inputfield">
<p:inputText value="#{createOrderSelectionView.quantity}"
required="true"
requiredMessage="Inserisci la quantità del materiale"
label="Quantità" />
<p:outputLabel value="Quantità" />
</h:panelGroup>
<h:panelGroup styleClass="md-inputfield">
<p:commandButton type="reset" value="Aggiungi materiale"
icon="ui-icon-plus"
style="width:auto;margin-bottom:10px; float:left;"
action="#{createOrderSelectionView.addEquipmentQuantity()}"
update="equipmentQuantityTable">
<f:ajax execute="@this" render="@form" />
</p:commandButton>
</h:panelGroup>
</p:panelGrid>
This panelGrid is inside a big form, that I'm using with a command button to save the object. The beans has the following method:
public void addEquipmentQuantity() {
System.out.println(productionOrder.getEquipmentQuantities().size());
if (quantity != null) {
productionOrder.getEquipmentQuantities().add(new EquipmentQuantity(quantity, equipment));
this.equipment = null;
this.quantity = null;
}
System.out.println(productionOrder.getEquipmentQuantities().size());
}
public void onRemoveEquipmentQuantity(EquipmentQuantity equipmentQuantity) {
productionOrder.getEquipmentQuantities().remove(equipmentQuantity);
}
The problem is that the object isn't inserted in the datable; where am I wrong?
EDIT
The question was not duplicated as reported. The problem, which has been fixed by me and with the help of the comments, was due to the not correct usage of the session. For other, please use the @ViewScoped and render="@Id of the table".