1

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.. :(

4

1 回答 1

2

将自定义对象作为事件参数传递可能会很棘手,尤其是当您跨越插件边界时:在这种情况下,该类必须对两个插件都可用,否则自然无法正确接收事件。

一个常见的建议是保持 UI 层(例如,在 portlet 事件中)的通信非常浅,而不是依赖重对象。请记住,这种通信不应该是真正的业务层,因此可以为真实数据传递标识符、主键或其他占位符。假设没有人可能对接收事件感兴趣,那么您首先不应该花费太多精力来构建事件。

或者,您可以将感兴趣的对象缓存在您的业务层上,以便在它确实正在处理时(例如,如果收到事件)可以快速使用

于 2013-04-21T10:58:40.413 回答