QeelwaEtech / omnifaces

Automatically exported from code.google.com/p/omnifaces
0 stars 1 forks source link

OmniFaces Ajax utility's updateColumn() not updating p:dataTable #86

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Please refer to the following:

http://stackoverflow.com/questions/13128299/omnifaces-ajax-utilitys-updatecolumn
-not-updating-pdatatable

Environment details:

PrimeFaces 3.4.1, Mobile 0.9.3, Extensions 0.6.1 | MyFaces 2.1.9 (JSF 2.1) | 
JUEL 2.2.5
OmniFaces 1.3-SNAPSHOT | GlassFish 3.1.2.2 | Apache Derby | Google Chrome

Attached is the rendered HTML of the PrimeFaces dataTable; I wanted to attach 
this since I'm sure h:dataTable and p:dataTable rendered HTML are totally 
different.

Original issue reported on code.google.com by smithh03...@gmail.com on 29 Oct 2012 at 7:33

Attachments:

GoogleCodeExporter commented 9 years ago
I can't reproduce your problem. Can you please attach a copypaste of the ajax 
response body?

Original comment by balusc on 29 Oct 2012 at 8:54

GoogleCodeExporter commented 9 years ago
FYI, I tried the following, and it updates p:dataTable just like p:calendar 
p:ajax update="...".

Ajax.update(flightsDataTable.getClientId());

I'll retest to get the AJAX response.

Original comment by smithh03...@gmail.com on 29 Oct 2012 at 9:13

GoogleCodeExporter commented 9 years ago
AJAX response body attached.

I want to tell you something else in my next comment.

Original comment by smithh03...@gmail.com on 29 Oct 2012 at 9:24

Attachments:

GoogleCodeExporter commented 9 years ago
My test steps 'and' results include the following:

1. After page is rendered in browser, scroll down to flights panel
2. enter some values in some of the dataTable columns on 1st 2 rows
3. scroll back up to p:calendar, select the date, 8/22/2012
4. AJAX request is posted/sent
5. scroll back down to flights datatable
6. dataTable is 'not' updated at all, and dataTable data values are all the 
same as prior to # 3 above

I need to share something else with you, when I update the entire dataTable, 
only the date is updated, successfully, when using p:ajax update="..." OR 
OmniFaces Ajax utility's update(clientId). Seems as though the dataTable values 
are 'not' being submitted regardless of partialSubmit="true" or 
partialSubmit="false". Prior to today's code changes, partialSubmit="false" is 
included in the xhtml for p:calendar p:ajax ...

I have tried to add rowKey="#{flight.flightId}" as well as remove and re-add 
hashCode() and equals(), overrided, in the POJO. For whatever reason, this is 
not working at all.

Is this a defect related to OmniPartialViewContext, since I am and have been 
using OmniFaces 1.2, earlier on, and now 1.3-SNAPSHOT (on development and 
production server)?

Original comment by smithh03...@gmail.com on 29 Oct 2012 at 9:35

GoogleCodeExporter commented 9 years ago
Clarification to the statement below in previous comment:

I need to share something else with you, when I update the entire dataTable, 
only the date is updated, successfully, when using p:ajax update="..." OR 
OmniFaces Ajax utility's update(clientId). Seems as though the dataTable values 
are 'not' being submitted regardless of partialSubmit="true" or 
partialSubmit="false".

When I do p:ajax update="..." or OmniFaces Ajax.update(clientId), after 
completing step # 5 above, all of my dataTable values dissapear, and the only 
column populated with data is the date column. :(

I have looked at the code responsible for updating the 'date' member of the 
List<POJO>, and that code looks fine and does not seem responsible for wiping 
out any possible submitted values in the other members/attributes of the POJO. 
That code is as follows:

    public void updateFlightDateOnAdd(Date date) {
        List<FlightForOrder> list = new ArrayList<>();
        for (int i = 0; i < flightsForOrder.size(); i++) {
            FlightForOrder flight = flightsForOrder.get(i);
            flight.setFlightDate(date);
            //flight.setFlightTime(date);
            list.add(flight);
        }
        flightsForOrder = list;
    }

The code in production is not working as designed either.

Original comment by smithh03...@gmail.com on 29 Oct 2012 at 9:42

GoogleCodeExporter commented 9 years ago
The ajax response doesn't match the datatable's HTML output. Is the datatable's 
HTML output as in your 1st post the same HTML output as you have tested the 
ajax response on? Or have you made some changes thereafter?

Original comment by balusc on 29 Oct 2012 at 9:45

GoogleCodeExporter commented 9 years ago
Test (continued from comment #4 above):

7. Clicked the Save commandLink, which is an ajax="false" request
8. Verified that all data was submitted and saved
9. Since data was not updated via OmniFaces Ajax.updateColumn(), then all data 
in dataTable was saved to database, successfully

Please note, these test steps and results are only related to 
Ajax.updateColumn(); these are not test results of p:ajax update="..." or 
OmniFaces Ajax.update(clientId).

Original comment by smithh03...@gmail.com on 29 Oct 2012 at 9:49

GoogleCodeExporter commented 9 years ago
Response to comment # 6, that ajax response seems to be a typical response 
after completing the test steps. As test steps will show, I made no other 
changes on the form after step # 6 in comment # 4 above.

Hmmm, trying to figure out how best to answer your question in comment # 6...

Original comment by smithh03...@gmail.com on 29 Oct 2012 at 10:08

GoogleCodeExporter commented 9 years ago
Honestly, I don't know how HTML output (in ajax response) changed from the HTML 
output that was rendered after opening/displaying the xhtml page.

After the AJAX response, the dataTable looks the same, but all column values 
are lost except the values of the date column.

Original comment by smithh03...@gmail.com on 29 Oct 2012 at 10:10

GoogleCodeExporter commented 9 years ago
Please note that Date and Time p:column have conditional rendered components. 
Please refer to the xhtml in the stackoverflow question that I posted.

Original comment by smithh03...@gmail.com on 29 Oct 2012 at 10:11

GoogleCodeExporter commented 9 years ago
This form is 'huge', over 600k. I may need to tune the update="...", so it will 
only update the components that need to be updated.

Original comment by smithh03...@gmail.com on 29 Oct 2012 at 10:19

GoogleCodeExporter commented 9 years ago
FYI, HTML body 'probably' changes onload as this page adds Google Places 
Autocomplete to various inputText fields that are not binded to the bean. From 
what I can tell, everything is updated successfully except the Flights 
datatable, so I am moving flights dataTable closer to the top of the page, 
above the Google Places Autocomplete inputText's.

What did you see earlier in the HTML body that changed?

Original comment by smithh03...@gmail.com on 30 Oct 2012 at 12:02

GoogleCodeExporter commented 9 years ago
I could reproduce the problem. The cause was a panelgroup as column's direct 
child which didn't render anything to the HTML output. See also my answer 
http://stackoverflow.com/questions/13128299/omnifaces-ajax-utilitys-updatecolumn
-not-updating-pdatatable

I'm unsure how to best prevent this in the future. I could add an additional 
check if the direct child component would by itself render *anything* to the 
HTML output or not. But there are endless scenarios possible. I think it's 
better to update the javadoc accordingly to explain this "by design" behaviour 
clearly.

Original comment by balusc on 30 Oct 2012 at 12:48

GoogleCodeExporter commented 9 years ago
Shaking my head at the fact that I 'should have' tried that. I need to remember 
this going forward, and learn to assign IDs to any/all components, and avoid 
using h:panelGroup 'if' I am 'not' referencing h:panelGroup ID in an 
update="...". Anyway, thanks again, that solved the problem.

I don't know how you want to update the status of this issue, but you can 
update the status as you wish.

Original comment by smithh03...@gmail.com on 30 Oct 2012 at 1:11

GoogleCodeExporter commented 9 years ago
FYI, when you responded, I was about to use some existing Javascript that I 
have and using on the other page that is now using Ajax.updateColumn() that you 
helped me with earlier.

I have javascript for onchange="..." that will do the same as the java bean is 
doing on the server, and then updating via Ajax.updateColumn(). The client 
javascript, triggered by onchange="...", is for endusers like myself which are 
'keyboard users', that rather type in a date and press <Tab> key instead of 
using mouse (I hate using the mouse), but I have to use the mouse a lot in web 
browser/client/software. When I was developing Windows software, I could use 
all my keyboard shortcuts.

Anyway, thanks again.

Original comment by smithh03...@gmail.com on 30 Oct 2012 at 1:15

GoogleCodeExporter commented 9 years ago
I improved the javadocs: 
http://code.google.com/p/omnifaces/source/detail?r=0d021471a6719681f84d2046108a8
5bf192eefd5

Thank you for reporting :)

Original comment by balusc on 30 Oct 2012 at 1:18

GoogleCodeExporter commented 9 years ago
You're welcome! I'm loving OmniFaces and spreading the word, when possible!

Original comment by smithh03...@gmail.com on 30 Oct 2012 at 1:29

GoogleCodeExporter commented 9 years ago

Original comment by balusc on 11 Dec 2012 at 1:33