Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimefaces inline editing of datatable not working
    primarykey
    data
    text
    <p>Hey guys I'm trying to provide a possibility to inline-edit a row of a datatable with primefaces, but it doesn't seem to work properly. I can visually edit the values but when I click the save-icon, it doesn't update the changed values...</p> <p>Here is the code:</p> <p>Datatable:</p> <pre><code>&lt;p:dataTable id="ticketTypePrices" var="priceCategoryTicketType" value="#{EventInstanceController.priceCategoryTicketTypes}" editable="true"&gt; &lt;p:ajax event="rowEdit" update="@this" listener="#{EventInstanceController.onEditPrices}" /&gt; &lt;p:ajax event="rowEditCancel" listener="#{EventInstanceController.onCancelPrices}" update="@this" /&gt; &lt;p:column headerText="Preiskategorie"&gt; &lt;h:outputText value="#{priceCategoryTicketType.priceCategory.name}" /&gt; &lt;/p:column&gt; &lt;c:forEach items="#{EventInstanceController.ticketTypes}" var="item"&gt; &lt;p:column headerText="#{item.name}"&gt; &lt;p:cellEditor&gt; &lt;f:facet name="output"&gt; &lt;h:outputText value="#{priceCategoryTicketType.ticketTypes[item]}" /&gt; &lt;/f:facet&gt; &lt;f:facet name="input"&gt; &lt;p:inputText converter="bigDecimalConverter" value="#{priceCategoryTicketType.ticketTypes[item]}" style="width:50%" /&gt; &lt;/f:facet&gt; &lt;/p:cellEditor&gt; &lt;/p:column&gt; &lt;/c:forEach&gt; &lt;p:column style="width:3%"&gt; &lt;p:rowEditor /&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; </code></pre> <p>EventInstanceController.onEditPrices</p> <pre><code>public void onEditPrices(RowEditEvent event) { PriceCategoryTicketType pctt = (PriceCategoryTicketType)event.getObject(); System.out.println(pctt.getPriceCategory().getName()); for(int i = 0; i &lt; priceCategoryTicketTypes.size(); i++) { PriceCategoryTicketType pctickettype = priceCategoryTicketTypes.get(i); if(pctt.getPriceCategory().equals(pctickettype.getPriceCategory())) { for(Map.Entry&lt;TicketType, BigDecimal&gt; entry : pctt.getTicketTypes().entrySet()) { System.out.println("TicketType: " + entry.getKey().getName()); System.out.println("Price: " + entry.getValue()); } priceCategoryTicketTypes.set(i, pctt); } } } </code></pre> <p>It looks like this: <img src="https://i.stack.imgur.com/XFpOS.png" alt="Overview of the datatable"></p> <p>As you can see, the default values of each cell is 0. If I change the values (like on the picture) to f.e. 30 25 20 and hit the save-row-icon, the values will change back to 0 0 0.</p> <p>The System.out.println in the onEditPrices results to following:</p> <pre><code>INFO: TicketType: Standard INFO: Price: 0 INFO: TicketType: AHV INFO: Price: 0 INFO: TicketType: Student INFO: Price: 0 </code></pre> <p>Am I missing something? :(</p> <p>Info: I'm using primefaces version 4.0 (snapshot) but also tried and failed with stable version 3.5</p> <p>Thanks in advance, Xera</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload