I have found the solution, but I would like to ask the Portal developers if there is a
more elegant solution.
If not, will a later version of JBoss Portal support
- injecting default portlets into "special" regions (like the navigation region,
but with real portlets)
- or support markup in layouts that specify portlets to be injected at the place of the
markup, for example
| <p:injectPortlet instance="InjectMePortletInstance">
| <parameters/>
| </p:injectPortlet>
|
And the solution for Injecting content to a custom region for the current version is:
1. Create a class Named
MyPageCustomizerInterceptor that extends ControllerInterceptor
2. Get JBoss source and copy the contents of:
org.jboss.portal.core.aspects.controller.PageCustomizerInterceptor
into your class code.
Import a bunch of JBoss libraries
3. there is a part in the code in the "invoke" method:
| if (tabbedNav != null)
| {
| ....
| }
|
|
instantly after this code insert the following (of course modified to your preferences).
Modify the "BLAH2" and the "inject_region" strings to your needs.
|
| String toInject = "<h1>AT LAST! I have injected my custom
stuff!</h1>";
| Map windowProps = new HashMap();
| windowProps.put(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER,
"emptyRenderer");
| windowProps.put(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER,
"emptyRenderer");
| windowProps.put(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER,
"emptyRenderer");
| WindowResult res = new WindowResult("", toInject,
Collections.EMPTY_MAP, windowProps, null, WindowState.NORMAL, Mode.VIEW);
| WindowContext blah = new WindowContext("BLAH2",
"inject_region", "0", res);
| rendition.getPageResult().addWindowContext(blah);
| Region region =
rendition.getPageResult().getRegion2("inject_region");
| DynaRenderOptions.NO_AJAX.setOptions(region.getProperties());
|
3. Put your classes into a jar and put them under
JBOSS_HOME\server\default\lib\
4. Modify
JBOSS_HOME\server\default\deploy\jboss-portal.sar\META-INF\jboss-service.xml
replace org.jboss.portal.core.aspects.controller.PageCustomizerInterceptor in
| <mbean
code="org.jboss.portal.core.aspects.controller.PageCustomizerInterceptor"
|
with the full classname of your class
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4194164#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...