Foren

ResourceResponseImpl cannot be cast to ActionResponse

thumbnail
Bernd Prager, geändert vor 11 Jahren.

ResourceResponseImpl cannot be cast to ActionResponse

Junior Member Beiträge: 42 Beitrittsdatum: 20.12.12 Neueste Beiträge
I am trying to implement an IPC call in the Primfaces "DataTable - Instant Row Selection" example and try to use code from the new jsf2-ipc-events-customers-portlet example.

The failing code is
	public void onRowSelect(SelectEvent event) {
		this.selectedItem = (TableItem) event.getObject();

		// IPC event
		logger.trace("fire IPC");
		javax.xml.namespace.QName qName = new QName("http://sandp.com", "ipc.software", "x");
		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
		ActionResponse actionResponse = (ActionResponse) externalContext.getResponse();
		  	
		Serializable eventPayload = ((TableItem) event.getObject()).getName();
		actionResponse.setEvent(qName, eventPayload);
	}


I am using liferay-faces-bridge-impl-3.1.1-ga2.jar and primefaces-3.5.jar.

The error I am getting is
java.lang.ClassCastException: com.liferay.portlet.ResourceResponseImpl cannot be cast to javax.portlet.ActionResponse
	at com.sandp.dta.TableBean.onRowSelect(TableBean.java:68)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328)
	... 151 more


Can anybody help?

Thank you.
thumbnail
Neil Griffin, geändert vor 11 Jahren.

RE: ResourceResponseImpl cannot be cast to ActionResponse

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Bernd,

Unfortunately, Portlet 2.0 IPC (Events and Public Render Parameters) are incompatible with Ajax (javax.portlet.ResourceResponse). Instead, you they require a full postback (javax.portlet.ActionResponse). You would have to disable Ajax form submission in order to invoke IPC. I'm not sure if this is possible with the "rowSelect" event since that seems to be invoked via p:ajax.

Kind Regards,

Neil