Sunday, September 11, 2011

oracle weblogic portal_在單一portlet是ajax的情況下,控制portlet視窗的放大和縮小(解決CR270742)

一般來說,把portlet放大是用:

Web層用response.setWindowState(WindowState.MAXIMIZED);

或是在jsp用 <portlet:actionURL windowState="maximized" ... >

但是當你的portlet又有啟用ajax功能時,上述的做法將會沒有效用。

1

(這個情況在設定整個”桌面”啟動非同步化時,卻沒有影響)

2

下面是查到的資料:說一般將畫面放大或縮小的作法,注意標黃色的地方,它說:當你是非同步化時,將會沒有效用。

http://download.oracle.com/docs/cd/E13155_01/wlp/docs103/portlets/building.html#wp1073655

Minimizing or Maximizing a Portlet Programmatically

You can minimize or maximize a portlet either in the portlet file or in a portlet’s backing file. The actual code is the same for both. Here is an example of maximizing a (Java page flow) portlet:

PortletBackingContext context = PortletBackingContext.getPortletBackingContext(request);
context.setupStateChangeEvent(WindowCapabilities.MAXIMIZED.getName());

You can put this code in an action method of the Java page flow or in the handlePostbackData method of the backing file. When using the backing file, in order to get the handlePostbackData method to be called, you must have '_nfpb=true' in the URL.

These mechanisms do not work if asynchronous content rendering is enabled for the portlet.

同樣的,這個問題已經被列入 WebLogic Portal 10這一系列,版本的限制(或說是尚未解決的問題),唉~

http://download.oracle.com/docs/cd/E13218_01/wlp/docs100/relnotes/relnotes.html

Known Limitations and Workarounds in BEA WebLogic Portal 10.0

CR270742

When async rendering is enabled for a portlet, portlets can not directly change window modes or states

WebLogic Portal allows portlets to change the current window state and/or mode of a portlet either programmatically, or via parameters added to URLs. When async rendering (either via AJAX or iframes), these mechanisms will not provide a consistent view to the end user. Particularly, the title bar rendered above the portlet will not reflect the change in the mode or state immediately.

Platform: All

Workaround: None

即然,山不轉就路轉,路不轉就人轉,再不行,我愚公移山總可以了吧,相信沒有程式做不到的事情。

不過 移山的工作還是只能寄託 WebLogic下一版本的改良了。

以下是我的解決在ajax被使用的狀況下,如何控制portlet的畫面的最大化:

我是從這裡切入解決問題的:為什麼portlet自訂的「放大按鈕」在ajax啟用的情況下,仍然可以正常的放大視窗

這是我寫的jsp頁面的連結,portlet:param是我額外要傳的參數,不要管它

<portlet:actionURL windowState="maximized" var="receiverLink"></portlet:actionURL>

這是在瀏覽器開啟之後,上面的連結,被portlet「加工」產生出來的link,稍微把它排版了一下

<a href="javascript:bea.netuix.ajaxportlet.updateContents(%22T3800130691314889580120_async%22,%22

http://localhost:7001/XXXXXX/portal/desktop/T3800130691314889580120?

_nfpb=true&_st=e0FFU31RZ013T1FNK3JmbUZxMDllOTVHRkhXMm92bmVHd3VkQzVYdWNRT1ArTVhUaVFUUmc3QmkzZDR5bVVFRHAxWTZ4&

_windowLabel=T3800130691314889580120&

_urlType=action&

_state=maximized&wlpT3800130691314889580120

_nfsp=true&

_portlet.portalUrl=%252FportalWeb%252Fappmanager%252Fportal%252Fdesktop&

_portlet.portalId=portal%2509desktop&

_portlet.contentType=text%252Fhtml%253B+charset%253DUTF-8&

_portlet.contentOnly=true&

_portlet.contentMode=FRAGMENT&

_portlet.async=true&

_portlet.asyncMode=compat_9_2&

_portlet.discEnabled=true%22)">放大

</a>

這是weblogic portal,點 「放大的圖片」產生的link

<a href="http://localhost:7001/portalWeb/appmanager/portal/desktop?

_nfpb=true&amp;

_st=e0FFU31RZ013T1FNK3JmbUZxMDllOTVHRkhXMm92bmVHd3VkQzVYdWNRT1ArTVhUaVFUUmc3QmkzZDR5bVVFRHAxWTZ4&amp;

_windowLabel=T3800130691314889580120&amp;

_state=maximized&amp;

_pageLabel=gov_ris_portals_portal_portal_page_1">

<img src="/portalWeb/framework/skins/liquid_blue/images/titlebar-button-maximize.gif" alt="Maximize" title="Maximize" name="maximized" class="">

</a>

因為是非同步化的關系,link的前面會有 javascript:bea.netuix.ajaxportlet.updateContents(%22T3800130691314889580120_async%22

造成它無法正常的連結

那就先用笨方法,把它前面的字給移掉,讓它可以做正常的link。

link.href = /^.+updateContents.+,%22(.+)%22\)/.exec(link.href)[1];

這樣,的確可以讓畫面可以放大了,但是,css的套版卻不見了,變成下面這個樣子。

clip_image001

所以,再把網址列,捉下來比照:

這是正常的,點 「放大的圖片」的按鈕,有css套版的連結

http://localhost:7001/portalWeb/appmanager/portal/desktop?

_nfpb=true&

_st=e0FFU31lRndaOTBFTkF6Yk1VNG40dkkzNzZOcUJQZmV6UmlBWXhScXo0RFVWaXM2aWNyMzN5WDJhMGN0YUZIZlBaZm9F&

_windowLabel=T3800130691314889580120&

_state=maximized&

_pageLabel=gov_ris_portals_portal_portal_page_1#wlp_T3800130691314889580120

這是有問題的連結

http://localhost:7001/xxxxxxx/portal/desktop/T3800130691314889580120?

_nfpb=true&

_st=e0FFU31lRndaOTBFTkF6Yk1VNG40dkkzNzZOcUJQZmV6UmlBWXhScXo0RFVWaXM2aWNyMzN5WDJhMGN0YUZIZlBaZm9F&

_windowLabel=T3800130691314889580120&

_urlType=action&

_state=maximized&wlpT3800130691314889580120

_nfsp=true&

_portlet.portalUrl=%252FportalWeb%252Fappmanager%252Fportal%252Fdesktop&

_portlet.portalId=portal%2509desktop&

_portlet.contentType=text%252Fhtml%253B+charset%253DUTF-8&

_portlet.contentOnly=true&

_portlet.contentMode=FRAGMENT&

_portlet.async=true&

_portlet.asyncMode=compat_9_2&

_portlet.discEnabled=true

把上面的網址decode一下:http://meyerweb.com/eric/tools/dencoder/

http://localhost:7001/xxxxx/portal/desktop/T3800130691314889580120?

_nfpb=true&

_st=e0FFU31lRndaOTBFTkF6Yk1VNG40dkkzNzZOcUJQZmV6UmlBWXhScXo0RFVWaXM2aWNyMzN5WDJhMGN0YUZIZlBaZm9F&

_windowLabel=T3800130691314889580120&

_urlType=action&

_state=maximized&wlpT3800130691314889580120

_nfsp=true&

_portlet.portalUrl=/xxxxx/portal/desktop&

_portlet.portalId=portal desktop&

_portlet.contentType=text/html; charset=UTF-8&

_portlet.contentOnly=true&

_portlet.contentMode=FRAGMENT&

_portlet.async=true&

_portlet.asyncMode=compat_9_2&

_portlet.discEnabled=true

解法:

1.把/T3800130691314889580120,拿掉。

2.把_nfsp=true改成false。

url = url.replace(/\/\w+\?/, "?").replace("&_nfsp=true", "&_nfsp=false");
link.href = unescape(url);

這樣就可以有正常的css了

No comments:

Post a Comment