updating my extendeddatatable....
corte86 Apr 6, 2010 5:40 PMHi all...i'm facing this problem...i have this relation 1 warehouse which serves n stores....and i'm trying to have a page where i can update warehouse details and stores details which are displayed in an extendeddatatable.....problem? view is ok....updating values for warehouse is ok....not updating stores details.....if i debug it storesDetails
have old values in it, when i press persistall
....
this is my xhtml
<ui:define name="body"> <h:form id="parametersForm"> <rich:panel id="panelparameters"> <f:facet name="header">#{empty selectedWh ? 'Select Warehouse' : 'Edit Warehouse Parameters'}</f:facet> <s:decorate id="WarehouseField" template="layout/edit.xhtml"> <ui:define name="label">Warehouses</ui:define> <h:selectOneMenu value="#{selectedWh}" id="warehouses"> <s:selectItems value="#{listaWarehouse}" var="wh" label="#{wh.name}" noSelectionLabel="Select Warehouse..." /> <s:convertEntity/> <a:support event="onchange" bypassUpdates="false" ajaxSingle="true" reRender="panelparameters, paneltable " /> </h:selectOneMenu> </s:decorate> <s:decorate id="palletHandlingCostField" template="layout/edit.xhtml"> <ui:define name="label">Pallet handling cost</ui:define> <h:inputText id="palletHandlingCost" required="true" value="#{parameters.selectedWh.parametri().palletHandlingCost}" size="13"> <a:support event="onblur" reRender="palletHandlingCostField" bypassUpdates="true" ajaxSingle="true" /> </h:inputText> </s:decorate> <s:decorate id="palletRentField" template="layout/edit.xhtml"> <ui:define name="label">Pallet rent</ui:define> <h:inputText id="palletRent" required="true" value="#{parameters.selectedWh.parametri().palletRent}" size="13"> <a:support event="onblur" reRender="palletRentField" bypassUpdates="true" ajaxSingle="true" /> </h:inputText> </s:decorate> <s:decorate id="parcelHandlingCostField" template="layout/edit.xhtml"> <ui:define name="label">Parcel handling cost</ui:define> <h:inputText id="parcelHandlingCost" required="true" value="#{parameters.selectedWh.parametri().parcelHandlingCost}" size="13"> <a:support event="onblur" reRender="parcelHandlingCostField" bypassUpdates="true" ajaxSingle="true" /> </h:inputText> </s:decorate> <s:decorate id="storesDeliveryCostField" template="layout/edit.xhtml"> <ui:define name="label">Stores delivery cost</ui:define> <h:inputText id="storesDeliveryCost" required="true" value="#{parameters.selectedWh.parametri().storesDeliveryCost}" size="13"> <a:support event="onblur" reRender="storesDeliveryCostField" bypassUpdates="true" ajaxSingle="true" /> </h:inputText> </s:decorate> <div style="clear:both"/> </rich:panel> <div class="actionButtons" align="right"> <h:commandButton id="parameters" value="Save All" action="#{parameters.persistAll()}"/> </div> <rich:panel id="paneltable"> <f:facet name="header">#{empty selectedWh ? 'Empty Store List, select Warehouse First' : 'Edit Stores Parameters'}</f:facet> <rich:extendedDataTable id="table" var="stores" height="300px" selectionMode="none" value="#{storeDetails}" width="100%" rendered="#{not empty selectedWh.warehouseId}"> <rich:column sortable="true" sortBy="#{stores.code}" filterBy="#{stores.code}" filterEvent="onkeyup" width="8%" label="storecodesss"> <f:facet name="header"> <h:outputText value="#{messages['storeCode']}" /> </f:facet> <h:outputText value="#{stores.code}" /> </rich:column> <rich:column sortable="true" sortBy="#{stores.name}" filterBy="#{stores.name}" filterEvent="onkeyup" width="15%" label="storename"> <f:facet name="header"> <h:outputText value="#{messages['store.name']}" /> </f:facet> <h:outputText value="#{stores.name}" /> </rich:column> <rich:column sortable="false" style="{text-align:center;}" width="7%" label="shiptipe"> <f:facet name="header"> <h:outputText value="#{messages['paramWhStore.shippingType']}" /> </f:facet> <rich:inplaceSelect value="#{stores.parametri().shippingType}" id="shippingType" layout="block" listWidth="50px" selectWidth="30px"> <f:selectItem id="mType" itemLabel="M" itemValue="M"/> <f:selectItem id="bType" itemLabel="B" itemValue="B"/> </rich:inplaceSelect> </rich:column> <rich:column sortable="false" style="{text-align:center;}" width="20%" label="shiprate"> <f:facet name="header"> <h:outputText value="#{messages['paramWhStore.shippingRate']}" /> </f:facet> <rich:inplaceInput layout="block" value="#{stores.parametri().shippingRate}" converterMessage="Price value should be integer. Price at row #{selectedRow+1} can't be changed." id="shipRate" selectOnEdit="true" editEvent="onclick" > <a:support event="onchange" reRender="shipRate" bypassUpdates="false"/> </rich:inplaceInput> </rich:column> <rich:column sortable="false" style="{text-align:center;}" width="20%" label="shiptipe"> <f:facet name="header"> <h:outputText value="#{messages['paramWhStore.saturation']}" /> </f:facet> <rich:inplaceInput layout="block" value="#{stores.parametri().saturation}" converterMessage="Price value should be integer. Price at row #{selectedRow+1} can't be changed." id="saturation" showControls="true" selectOnEdit="true" editEvent="onclick"> <a:support event="onviewactivated" reRender="shipRate" bypassUpdates="true" /> </rich:inplaceInput> </rich:column> <rich:column sortable="false" style="{text-align:center;}" width="20%" label="shiptipe"> <f:facet name="header"> <h:outputText value="#{messages['paramWhStore.multipleStoresDel']}" /> </f:facet> <rich:inplaceInput layout="block" value="#{stores.parametri().multipleStoresDel}" converterMessage="Price value should be integer. Price at row #{selectedRow+1} can't be changed." id="multStDel" selectOnEdit="true" editEvent="onclick"> </rich:inplaceInput> </rich:column> <rich:column sortable="false" style="{text-align:center;}" width="10%" label="checked"> <h:selectBooleanCheckbox value="#{not empty stores.parametri().paramWhStoreId}" /> </rich:column> </rich:extendedDataTable> </rich:panel> </h:form> </ui:define> </ui:composition>
this is my javabean for managing all...
@Name("parameters") public class Parameters { @Logger private Log log; @In StatusMessages statusMessages; @In(create=true) MdBusinessUnitHome mdBusinessUnitHome; @In(required=false) @Out(required=false) MdWarehouse selectedWh; @Out(required=false) List<MdWarehouse> listaWarehouse; @In private EntityManager entityManager; // Tabella stores, con details @DataModel List<MdStore> storeDetails; public List<MdStore> getStoreDetails() { return storeDetails; } public void setStoreDetails(List<MdStore> storeDetails) { this.storeDetails = storeDetails; } @Factory("listaWarehouse") public void setListaWarehouse(){ this.listaWarehouse = mdBusinessUnitHome.getMdWarehouses(); } @Factory("storeDetails") public void buildStoreDetails(){ System.out.println("entro in buildstoredetails"); if (selectedWh == null){ selectedWh = new MdWarehouse(); System.out.println("Il warehouse selezionato è null"); }else{ System.out.println(" Il warehouse selezionato è :" + selectedWh.getName()); } storeDetails = (ArrayList<MdStore>) mdBusinessUnitHome.getMdStores(); System.out.println("La businessUnit contiene n° wh: " + storeDetails.size()); Iterator<MdStore> i = mdBusinessUnitHome.getMdStores().iterator(); while (i.hasNext()){ MdStore corrente = i.next(); System.out.println("Analizzo lo store " + corrente.getName()); // Parametri dello store corrente ParamWhStore parametri = corrente.parametri(); // Controllo che non sia un oggetto vuoto if ((parametri.getParamWhStoreId() != null) ){ System.out.println("parametri: " + parametri.getSaturation() ); Integer warehouseId = parametri.getParamWarehouse().getMdWarehouse().getWarehouseId(); // Se lo store corrente è servito da un altro warehouse lo rimuovo dal datamodel if (warehouseId.equals(selectedWh.getWarehouseId()) == false){ System.out.println("Rimuovo lo store dalla view perchè è assegnato ad un diverso wh"); storeDetails.remove(corrente); } }else{ System.out.println("paramwhStoreId = null"); } } } public MdWarehouse getSelectedWh() { if (selectedWh == null){ return new MdWarehouse(); }else{ return selectedWh; } } public void parameters() { // implement your business logic here log.info("parameters.parameters() action called with: #{parameters.value}"); statusMessages.add("parameters #{parameters.value}"); } @Transactional public void persistAll(){ System.out.println(entityManager.getFlushMode()); MdStore m = storeDetails.get(0); m.setAddress("via fiume adda n° 13!"); entityManager.merge(m); System.out.println("merge fatto"); for(int i=0; i<storeDetails.size(); i++){ if (storeDetails.get(i).parametri() != null){ if (storeDetails.get(i).parametri().getSaturation() != null){ entityManager.merge(storeDetails.get(i).parametri()); System.out.println("Memorizzo parametri di: " + storeDetails.get(i).getName()); System.out.println("Saturation: " + storeDetails.get(i).parametri().getSaturation()); System.out.println("Shipping Rate: " + storeDetails.get(i).parametri().getShippingRate()); System.out.println("Shipping Type: " + storeDetails.get(i).parametri().getShippingType()); System.out.println("MultipleStoresDel: " + storeDetails.get(i).parametri().getMultipleStoresDel()); }else{ System.out.println("Non memorizzo i parametri di: getsaturation null"); } }else{ System.out.println("NON Memorizzo parametri di: " + storeDetails.get(i).getName()); } } // entityManager.persist(new MdStore( mdBusinessUnitHome.getInstance(), "code44", "Bruntino", null, null, null, null, null, null, null, null )); entityManager.flush();// oggetti da persistere statusMessages.add("Modifiche eseguite correttamente"); } }
thanks in advance for any hint....