我正在開發基於struts 1.2.9的JSR-286標準portlet(由於歷史原因,我們希望重複使用很多現有的代碼)使用struts portlet橋樑。我想要一些鏈接來更改WindowState,但門戶網橋提供的FormTag和LinkTag沒有簡單的方法來設置WindowState。我很高興擴展這兩個標記,但我不確定如何繼續,我怎樣才能確定哪些請求參數需要添加在門戶不可知的方式?如何在基於Struts橋樑的portlet鏈接中設置WindowState?
0
A
回答
2
哦,還不如回答我的問題:-)
我不得不創建基於(不擴展)的支柱橋碼我TagsSupport,FormTag和鏈接標記的自己的版本。
我修改了TagsSupport.getUrl()和TagsSupport.getFormTagRenderFormStartElement()方法來接受一個WindowState參數,並在創建渲染和動作URL時使用它。
public static String getURL(PageContext pageContext, String url, PortletURLTypes.URLType type, WindowState ws)
...
if (type.equals(PortletURLTypes.URLType.ACTION))
{
final PortletURL portletURL = StrutsPortletURL.createActionURL(pageContext.getRequest(), url);
if (ws!=null) {
try {
portletURL.setWindowState(ws);
}
catch (WindowStateException e) {
e.printStackTrace();
}
}
return portletURL.toString();
}
else if (type.equals(PortletURLTypes.URLType.RENDER))
{
final PortletURL portletURL = StrutsPortletURL.createRenderURL(pageContext.getRequest(), url);
if (ws!=null) {
try {
portletURL.setWindowState(ws);
}
catch (WindowStateException e) {
e.printStackTrace();
}
}
return portletURL.toString();
}
...
和
public static String getFormTagRenderFormStartElement(PageContext pageContext, String formStartElement, WindowState ws)
{
if (PortletServlet.isPortletRequest(pageContext.getRequest()))
{
int actionURLStart = formStartElement.indexOf("action=") + 8;
int actionURLEnd = formStartElement.indexOf('"', actionURLStart);
String actionURL = formStartElement.substring(actionURLStart,
actionURLEnd);
final PortletURL portletURL = StrutsPortletURL.createActionURL(pageContext.getRequest(),
actionURL);
if (ws!=null) {
try {
portletURL.setWindowState(ws);
}
catch (WindowStateException e) {
e.printStackTrace();
}
}
formStartElement = formStartElement.substring(0, actionURLStart)
+ portletURL.toString()
+ formStartElement.substring(actionURLEnd);
}
return formStartElement;
}
我再變FormTag和鏈接標記以接受的WindowState屬性並將其傳遞給在TagsSupport方法。
private String windowState;
public String getWindowState() {
return windowState;
}
public void setWindowState(String windowState) {
this.windowState = windowState;
}
和
url = TagsSupport.getURL(pageContext, url, urlType, new WindowState(getWindowState()));
顯然則需要一個TLD引用我的修改標籤。
這是作爲補丁PB-91(也包含修改portlet模式的修補程序)提供給struts bridge項目的補丁。
相關問題
- 1. 設置基於它的鏈接的ID
- 2. 如何設置FitNesse以用於基於struts的應用程序?
- 3. Ruby to Python橋樑
- 4. 設置活動鏈接基於URL
- 5. CVS到SVN的橋樑
- 6. AWT橋樑的「Hello World」
- 7. 在無向圖中尋找橋樑?
- 8. 在圖C++(BOOST)中查找橋樑?
- 9. 在Android中使用Javascript橋樑
- 10. Portlet橋接器是做什麼的?
- 11. Ember.js QT w/Javascript橋樑
- 12. 橋樑模擬遊戲
- 13. 橋樑或工廠模式?
- 14. 橋樑+命令模式
- 15. QT和web開發橋樑
- 16. PHP中的Objective-C/Cocoa橋樑?
- 17. WKWebView中的javascript橋樑不起作用
- 18. 如何編碼TumbleSeed中的橋樑背後的邏輯? Unity
- 19. 在Liferay中運行基於Vaadin的Portlet
- 20. 的Qt Webkit的橋樑ActiveQt可串
- 21. 基於設備的鏈接重定向
- 22. 更快的替代UIWebView/Javascript橋樑?
- 23. iphone上的Lua-Objective-C橋樑
- 24. C++和PHP之間的通用橋樑
- 25. 建立Joomla和eGroupware之間的橋樑
- 26. 面向對象的方法橋樑
- 27. 如何更改基於cookie的鏈接?
- 28. Struts - 基於環境的配置
- 29. 如何在javascript和actionscript3之間建立橋樑
- 30. 如何顯示從Struts的portlet中的Excel內容在WebSphere Portal