Excerpt | ||
---|---|---|
| ||
On the principle "anything's better than nothing", a capture of Ate's email to users@wicket" |
...
BTW: this inteface also won't be needed anymore for proper JSR-286 containers. Once they are available I'll upgrade the Wicket
Portlet support to really work out-of-the-box and portal specific configurations won't be needed then.
...
WicketPortlet
The implementations of these two interfaces need to be provided to the WicketPortlet.
There are three ways of doing that, the simplest is providing a WicketPortlet.properties
file in the classpath under package org.apache.wicket.protocol.http.portlet
.
The one I provide with Jetspeed 2 (out-of-the-box through a shared library) contains the following:
Code Block |
---|
# Default Jetspeed-2 provided WicketPortlet ServletContextProvider and PortletResourceURLFactory
org.apache.portals.bridges.common.ServletContextProvider=org.apache.jetspeed.portlet.ServletContextProviderImpl
org.apache.portals.bridges.common.PortletResourceURLFactory=org.apache.jetspeed.portlet.PortletResourceURLFactoryImpl
|
...
Defining these through WicketPortlet.properties
though will allow you to keep this portal specific configuration out of your application and thus be more portable.
web.xml
Additionally, you You will also need to modify the wicket filter mapping in your web.xml
to support handling both direct requests as well include dispatch requests, e.g.
Code Block | ||||
---|---|---|---|---|
| ||||
<filter-mapping>
<filter-name>AjaxApplication</filter-name>
<url-pattern>/ajax/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
|
Note: this requires at least a Servlet 2.4 descriptor just as in the wicket-examples application.
Enabling portlet support
By default portlet support will *not* be enabled (as of wicket 1.3.0-beta5), because even when deployed in a portlet supporting web container, a Wicket application might not or should not be used as portlet.
So, you'll have to provide a configuration setting to let WicketFilter detect if it actually is running in a Portlet Context.
This can be done using a boolean (true|false) value on three different levels: as filter parameter, web.xml context parameter, or finally as property in the above described WicketPortlet.properties.
WicketFilter will check for such a configuration in the above order.
To define this on filter level (possibly overriding a setting on web.xml or WicketPortlet.properties level):
Code Block | ||||
---|---|---|---|---|
| ||||
<filter>
<filter-name>MyWicketApplication</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>detectPortletContext</param-name>
<param-value>true</param-value>
</init-param>
...
</filter>
|
To define this on web.xml context level as default for the whole of the web application (possibly overriding a setting on WicketPortlet.properties level):
Code Block | ||||
---|---|---|---|---|
| ||||
<context-param>
<param-name>org.apache.wicket.detectPortletContext</param-name>
<param-value>true</param-value>
</context-param>
|
Finally, you can also set this globally through the classpath in WicketPortlet.properties:
Code Block |
---|
org.apache.wicket.detectPortletContext=true
|
Note: Jetspeed-2 provides the above default/global setting out of the box, so you won't need to configure this for your web application when deploying on Jetspeed-2.
portlet.xml
Finally, in your portlet.xml
, you need to define a portlet init-param named "wicketFilterPath"
with as value the url-pattern of your wicket application, but without the trailing /*
, e.g.:
Code Block | ||||
---|---|---|---|---|
| ||||
<portlet>
<description>Examples using wicket's built-in AJAX.</description>
<portlet-name>AjaxApplication</portlet-name>
<display-name>ajax</display-name>
<portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
<init-param>
<name>wicketFilterPath</name>
<value>/ajax</value>
</init-param>
<supports>
<mime-type>*/*</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<portlet-info>
<title>Wicket Ajax Example</title>
<keywords>Wicket</keywords>
</portlet-info>
</portlet>
|
...