Harmony 1.0.3 p:dataTable select event.getObject() is null

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
jobor
Posts: 33
Joined: 19 Dec 2011, 22:34
Location: the Netherlands

17 Dec 2018, 15:16

Hello,

Activating an Ajax listener on the datatable of the data.xhtml results in null result when event.GetObject() is invoked.

Code: Select all

<h1>DataTable</h1>
<p:dataTable var="car" value="#{dtSelectionView.cars7}" selectionMode="single" reflow="true"
		selection="#{dtSelectionView.selectedCar}" rowKey="#{car.id}" paginator="true" rows="10">
	<f:facet name="header">
		List of Cars
	</f:facet>

	<f:ajax event="rowSelect" listener="#{dtSelectionView.onRowSelect}" />

Code: Select all

public void onRowSelect(SelectEvent event) {
	Car car = (Car) event.getObject(); // car is null
        FacesMessage msg = new FacesMessage("Car Selected", car.getId()); // NPE on car.getId()
        FacesContext.getCurrentInstance().addMessage(null, msg);
}
To get the object into the event object PrimeFaces uses the clientId + "_instantSelectedRowKey request parameter.

Code: Select all

            if(eventName.equals("rowSelect")||eventName.equals("rowSelectRadio")||eventName.equals("contextMenu")
                    ||eventName.equals("rowSelectCheckbox")||eventName.equals("rowDblselect")) {
                String rowKey = params.get(clientId + "_instantSelectedRowKey");
                wrapperEvent = new SelectEvent(this, behaviorEvent.getBehavior(), this.getRowData(rowKey)); 
            }
But with Harmony this parameter is never send with the Ajax call

Form Data of the Ajax call with Harmony

Code: Select all

form: form
form:j_idt54_reflowDD: 0_0
form:j_idt54_selection: 3d90cc30
form:pickList_source_filter: 
form:pickList_source: San Francisco
form:pickList_source: London
form:pickList_source: Paris
form:pickList_source: Istanbul
form:pickList_source: Berlin
form:pickList_source: Barcelona
form:pickList_source: Rome
form:pickList_target_filter: 
form:j_idt86_values: San Francisco
form:j_idt86_values: London
form:j_idt86_values: Paris
form:j_idt86_values: Istanbul
form:j_idt86_values: Berlin
form:j_idt86_values: Barcelona
form:j_idt86_values: Rome
form:j_idt89_selection: 
form:j_idt117_mobiledropdown: 1
form:j_idt117_page: 0
form:j_idt131_selection: 
form:j_idt131_scrollState: 0,0
form:j_idt141_selection: 
form:j_idt141_scrollState: 0,0
form:j_idt151_selection: 
form:schedule_view: month
javax.faces.ViewState: -1485894272843045808:-533283486717817318
javax.faces.source: form:j_idt54
javax.faces.partial.execute: form:j_idt54 form:j_idt54
CLIENT_BEHAVIOR_RENDERING_MODE: UNOBSTRUSIVE
javax.faces.behavior.event: rowSelect
javax.faces.partial.ajax: true
data.xhtml	

And the Form Data of the PrimeFaces Demo datatable selection events Ajax call with [client_id]_instantSelectedRowKey

Code: Select all

javax.faces.partial.ajax: true
javax.faces.source: form:eventsDT
javax.faces.partial.execute: form:eventsDT
javax.faces.partial.render: form:msgs
javax.faces.behavior.event: rowSelect
javax.faces.partial.event: rowSelect
form:eventsDT_instantSelectedRowKey: e908b95c
form: form
form:singleDT_selection: 
form:eventsDT_selection: e908b95c
form:multipleDT_selection: 
form:radioDT_selection: 
form:checkboxDT_selection: 
javax.faces.ViewState: -2418059162813509700:7737298554821566507
selection.xhtml	
With regards,
Johan Borchers

Mac OS X 10.15.7
NetBeans 12.3
OpenJDK Zulu11.37
JSF Mojarra 2.3.14
PrimeFaces 10.0.0
Tomcat 9.0.43
MySQL 5.6.x

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

18 Dec 2018, 08:54

Please use <p:ajax instead of <f:ajax.

jobor
Posts: 33
Joined: 19 Dec 2011, 22:34
Location: the Netherlands

18 Dec 2018, 09:35

Many thanks !!

How simple can a solution be? :lol:

And why didn't I noticed it :oops:

Changed to <p:ajax and it works like charm.
With regards,
Johan Borchers

Mac OS X 10.15.7
NetBeans 12.3
OpenJDK Zulu11.37
JSF Mojarra 2.3.14
PrimeFaces 10.0.0
Tomcat 9.0.43
MySQL 5.6.x

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

18 Dec 2018, 16:16

Glad to hear, thanks a lot for the update! ;)

Best Regards,

Post Reply

Return to “Harmony - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest