我正在开发基于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