On Apr 24, 2007, at 7:27 PM, Melchior, Joris wrote:
Another question to be sure we're thinking the same thing, would
any of
those 'manipulations' be persisted so that they show up across
sessions
and to everyone?
Yes they can be persisted, see the last line
This example is simply cut and pasted from the unit tests to give you
an idea of how to manipulate pages
public class MyPortlet
{
protected PageManager pageManager;
public void init(PortletConfig config)
throws PortletException
{
super.init(config);
pageManager = (PageManager) getPortletContext().getAttribute
(CommonPortletServices.CPS_PAGE_MANAGER_COMPONENT);
if (null == pageManager)
{
PortletException pe = new PortletException("Failed to
find the Page Manager on SiteViewController initialization");
throw new RuntimeException(pe);
}
}
public void processAction(ActionRequest request, ActionResponse
actionResponse) throws PortletException, java.io.IOException
{
...
Page page = pageManager.getPage(pagePath);
Fragment root = page.getRootFragment();
root.setDecorator("blue-gradient");
root.setName("jetspeed-layouts::VelocityTwoColumns");
root.setShortTitle("Root");
root.setTitle("Root Fragment");
root.setState("Normal");
root.setLayoutSizes("50%,50%");
root.getProperties().put("custom-prop1", "custom-prop-value1");
root.getProperties().put("custom-prop2", "custom-prop-value2");
Fragment portlet = pageManager.newPortletFragment();
portlet.setName("security::LoginPortlet");
portlet.setShortTitle("Portlet");
portlet.setTitle("Portlet Fragment");
portlet.setState("Normal");
portlet.setLayoutRow(88);
portlet.setLayoutColumn(99);
portlet.setLayoutX(12.34F);
portlet.setLayoutY(23.45F);
portlet.setLayoutZ(34.56F);
portlet.setLayoutWidth(45.67F);
portlet.setLayoutHeight(56.78F);
List preferences = new ArrayList(2);
FragmentPreference preference =
pageManager.newFragmentPreference();
preference.setName("pref0");
preference.setReadOnly(true);
List preferenceValues = new ArrayList(2);
preferenceValues.add("pref0-value0");
preferenceValues.add("pref0-value1");
preference.setValueList(preferenceValues);
preferences.add(preference);
preference = pageManager.newFragmentPreference();
preference.setName("pref1");
preferenceValues = new ArrayList(1);
preferenceValues.add("pref1-value");
preference.setValueList(preferenceValues);
preferences.add(preference);
portlet.setPreferences(preferences);
root.getFragments().add(portlet);
portlet = pageManager.newPortletFragment();
portlet.setName("some-app::SomePortlet");
portlet.setShortTitle("Some Portlet");
portlet.setTitle("Some Portlet Fragment");
portlet.setState("Normal");
portlet.setLayoutRow(22);
portlet.setLayoutColumn(11);
portlet.setLayoutX(11.11F);
portlet.setLayoutY(22.22F);
portlet.setLayoutZ(33.33F);
portlet.setLayoutWidth(44.44F);
portlet.setLayoutHeight(55.55F);
SecurityConstraints fragmentConstraints =
portlet.newSecurityConstraints();
fragmentConstraints.setOwner("user");
portlet.setSecurityConstraints(fragmentConstraints);
root.getFragments().add(portlet);
// store the page
pageManager.updatePage(page);