在我們的項目中,我們正在改變portlet項目的JSR版本(從168到286)。所有的portlet都是,面向portlet,使用的jsf版本是jsf1.2。我們有幾個模塊,但結構幾乎相同。他們是左側的portlet,他們充當用戶的左側導航。在右側,我們有主要portlet,它承載各種應用程序功能。 IPC用於將這些選定的值從左側portlet發送到右側portlet,並相應地爲右側的portlet設置視圖。Faces Portlet導航 - WebSphere Portal - JSR 286
在portlet的processEvent方法中,根據收到的值設置目標portlet的視圖。樣品的processEvent方法如下:
public void processEvent(EventRequest request, EventResponse response) throws PortletException, java.io.IOException
{
super.processEvent(request, response);
Event sampleEvent = request.getEvent();
if(sampleEvent.getName().toString().equals("ProcessEvent")) {
Object sampleProcessObject = sampleEvent.getValue();
System.out.println("Message Received : " + sampleProcessObject.toString());
TargetPortletView obj = (TargetPortletView) request.getPortletSession().getAttribute("pc_TargetPortletView"); // Managed Bean associated with the target Page
obj.setMessage(sampleProcessObject.toString());
request.getPortletSession().setAttribute("com.ibm.faces.portlet.page.view","/TargetPortletView.jsp");//Target JSP is set
}
}
但是,如果一些面導航發生在目標jsp和視圖被重定向到一個不同的JSP(例如A.jsp-> B.jsp-> C.jsp)。然後再次如果從左側portlet進行選擇,右側portlet的視圖保持不變,並且雖然IPC正常發生,但未更新。請讓我知道是否需要其他細節。提前致謝。
zarfarf - 謝謝你的回覆。我瞭解你分享的方法。但問題是我們沒有固定的目標頁面(如/TargetPortletView.jsp),所以「to-view-id」會因場景而異。因此,我們需要基於通過IPC接收到的輸入,從processEvent方法動態設置目標視圖ID的機制。 –