Reputation: 430
I need help and it's really confusing. I've tried to follow all example on the web about IPC - pass Parameter between portlet using event.
Here's my code if I only want to pass my attribute
using event:
QName qName = new QName("http://liferay.com/events", "ipc.send");
response.setEvent(qName, pitchType);
and then in my getter Event Portlet my code
@ProcessEvent(qname = "{http://liferay.com/events}ipc.send")
public void catchBall(EventRequest request, EventResponse response) {
Event event = request.getEvent();
String send = (String) event.getValue();
response.setRenderParameter("send", send);
}
it only passes one parameter with and only String.
I've tried passing Object like Foo
to this parameter but no luck. It won't run.
Any idea how to pass Object via event?
please really need help here.. :(
Upvotes: 1
Views: 2187
Reputation: 48067
Passing custom objects as event parameters can be tricky, especially when you go across plugin boundaries: The class must be available to both plugins in this case, otherwise the event can naturally not be received properly.
A common recommendation is to keep the communication on the UI layer (e.g. in portlet events) very shallow and not rely on heavy objects. Keep in mind that this communication should not really be business-layer, thus it's ok to pass around identifiers, primary keys or other placeholders for the real data. Assume nobody might be interested in receiving the event, then you shouldn't have too much effort to build the event in the first place.
Alternatively you can cache the interesting object on your business layer, so that it will be quickly available if it indeed is being worked on (e.g. if the event is received)
Upvotes: 2