Datatable rowedit surfaces do not update cell element

I have a datatable with rowedit. One column of my table is a list box, list items are displayed dynamically (depending on the value in another box) I use rowEditInit to set the selectedrow element. And I want to update the list to get the correct values. This does not work. When i do

<p:ajax event="rowEditInit" listener="#{workOrderDetail.onEdit}" update="orderitemstable" /> 

Then, when I click on the pencil icon, I see a line switcher in edit mode and extracting list items. But he immediately went into non-editing mode.

But when I do

 <p:ajax event="rowEditInit" listener="#{workOrderDetail.onEdit}" update="rmactionenumid" /> 

Then clicking on the pencil icon places the line in edit mode, but the call is not made to retrieve the list items. I believe that this does not cause an update on rmactionenumid.

Any ideas?

Roel

Here is my jsf code

  <p:ajax event="rowEditInit" listener="#{workOrderDetail.onEdit}" update="rmactionenumid" /> <p:column > <p:cellEditor> <f:facet name="output"> <h:outputText id="rmactionenumidlabel" value="#{orderItem.rmActionRepr}" > </h:outputText> </f:facet> <f:facet name="input"> <h:selectOneListbox id="rmactionenumid" value="#{orderItem.rmActionEnumId}" size="1" valueChangeListener="#{workOrderDetail.setActionRepr}"> <f:selectItems value="#{workOrderDetail.actionItems}"/> <p:ajax event="change" update="partdiscount,labourdiscount,totalprice,:detail:wodetail:totals" execute="@this" /> </h:selectOneListbox> </f:facet> </p:cellEditor> </p:column> <p:column > <p:rowEditor id="edit" /> </p:commandLink> </p:column> </p:dataTable> 

and here is my java bean code

 public List<SelectItem> getActionItems() throws MWSException { ArrayList<SelectItem> actions = new ArrayList<SelectItem>(); if (getSelectedOrderItem() != null) { ListManager lm = new ListManager(getWA().getMwsProxy()); MWSGenericMapList items = lm.nativeSearch(getWS().getUser(), HdfWebConstants.NS_VEHICLEPARTACTIONS, 0, 0, 200, false, getSelectedOrderItem().getVehiclePartCode()); for (int i = 0; i < items.size(); i++) { actions.add(new SelectItem(items.get(i).get("rmaction_enumid").toString(), items.get(i).get("rmaction") .toString())); } } return actions; } public void setSelectedOrderItem(IMWSOrderItem newSelectedOrderItem) throws MWSException { this.selectedOrderItem = newSelectedOrderItem; } public void onEdit(RowEditEvent event) throws MWSException { setSelectedOrderItem((IMWSOrderItem) event.getObject()); } 

I am using PF3.5

+7
jsf datatable primefaces listbox
source share
5 answers

It fails because update="rmactionenumid" is in this construct relative to the table itself, and not in the current row of the table.

Basically, he is looking for a component with a client identifier of formId:tableId:rmactionenumid instead, for example. second line is formId:tableId:1:rmactionenumid . Technically, <p:ajax> should be placed inside <p:column> , but this will not work for the rowEditInit event.

You will need to create your own update client identifier based on the UIData component, available as an argument to RowEditEvent , and add the compiled client identifier to PartialViewContext#getRenderIds() .

So, delete <p:ajax update> and extend the onUpdate() method as follows:

 public void onEdit(RowEditEvent event) { UIData table = (UIData) event.getComponent(); String updateClientId = table.getClientId() + ":" + table.getRowIndex() + ":rmactionenumid"; FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add(updateClientId); // ... } 
+16
source share

By the lines of the BalusC answer:

Since you are using Primefaces 3.5, you can also use its utility classes ComponentUtils and RequestContext:

 String actId = ComponentUtils.findComponentClientId( "rmactionenumid" ); RequestContext.getCurrentInstance().update( actId ); 

will do the same as the fragment sent by BalusC.

+3
source share

OMG, it took me a long time to figure this out. BalusC, as always, is dead for money, but what eluded me was that the Datatable update does not update all its children, as I expected. Updating the table actually updates the rows (deleted rows in the base model disappear) and reorders the rows if the base model was reordered, but the values ​​in the outputText widgets inside the CellEditor containers are not updated, except for those that were edited if you did not provide the <p:ajax /> tag <p:ajax /> ones you want to update, which in my case was all of them. I suppose there was an assumption that when CellEditor initiated an Ajax call, the Datatable parent would only update the edited child cell. I never understood why CellEditor needed both InputText and OutputText contained for work.

This led to terrifying problems for me when several users edited the same Datatable at the same time in different sessions. UserA will do the editing and get the table correctly updated, potentially with rows in a different order. Then UserB, whose Datatable is now deprecated, will do the editing, and the editing will be correctly saved in the database (since the row had a unique hidden identifier), but the editing will move to the wrong row in the Datatable (but the correct column), and UserB, even after the update, will not will see the UserA change in another cell. As soon as I put the <p:ajax update="datatableID" /> in the inputText body, it worked correctly. I still had concurrency problems that I had to solve separately, but at least Datatable was right after editing.

BalusC, if you are there, please correct my bad assumptions here.

+1
source share

I ran into the same problem. You can do the following:

Place the registrar object under your update method (or you can just write system.out.println) to check if your method is available on the jsf page. If yes, write you an action.

For me, I checked if my method is available. And after I saw my row entries were still not updating. What I did was create a new object of the desired row under this method and copy the contents of the string values ​​to my new object via getters / seters. And then I could update my line. This method works for me.

0
source share

It might help someone. I had a similar problem and tried my best on the Internet. In the end, I gave up, but later corrected it. The problem was that I had several h: form> used in my .xhtml and the changes were not propagated for some reason. Hope this helps someone.

0
source share

All Articles