With the latest changes and additions to the wicket core, all Wicket Examples can be run as a portlet except for the frames and prototype example.
And several initial changes have even been reverted!
The most important (and mostly only) change to Wicket Examples is the required upgrade to Servlet api 2.4 to allow the WicketFilter to work on RequestDispatcher include as required for portlets.
Additionally, I've written a new example, WicketExamplesMenuApplication which is a portlet context only Wicket example.
It is served by WicketExamplesMenuPortlet which extends WicketPortlet to "wrap" the available (Wicket) portlets in the war with a front-end menu, just like the static index.html start page in a Servlet environment.
But this MenuPortlet is quite a bit more fancy
It dynamically determines the available portlets by parsing portlet.xml and build its menu from it and renders it through a Wicket MenuPage.
Furthermore, it has 2 other Wicket Pages: HeaderPage and EditPage.
When one of the menu items is selected, the MenuPortlet will first invoke the WicketExamplesMenuApplication to render the HeaderPage. This page provides a back link to the main MenuPage.
Then, the MenuPortlet invokes the selected Wicket Example and renders it within its own portlet window!
So, effectively, this gives the same appearance and behavior as what the normal Servlet based WicketExampleHeader does.
But, to prevent that header back link from rendering (which links to the static index.html) in a portlet context, I've modified WicketExampleHeader slightly to make that link invisible in that case.
When rendered as a normal Servlet example, the behavior hasn't changed.
Finally, the MenuPortlet also provides a PortletMode.EDIT page, EditPage, which can be invoked from the Portlet window action icons (most left icon in the top right corner).
When the EditPage is rendered, it allows the user to select the default example to be displayed in VIEW mode.
This is initially the MenuPage showing all available examples, but when one of the other examples is chosen, this will be stored as Portlet Preference (thus persisted for this user),
after which it will automatically switch back the VIEW mode and the selected example is displayed.
The next time you open the portal page (like after stopping the portal or logging out), you'll notice the selected example now is displayed by default.