Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Changing portlet mode through URLs

With whatever link you want to change modes, you need a PortletURL. Simply create the URL normally (PortletURL myPortletURL = response.createRenderURL()), then call the method: myPortletURL.setPortletMode(PortletMode.EDIT) for edit mode, or use VIEW for view mode and HELP for help mode... If you're extending the GenericPortlet, you then just have to implement doView(), doHelp(), and doEdit() each method will get called accordingly. You can also set your window states if you want to by calling myPortletURL.setWindowState(WindowState.MAXIMIZED) etc...

With thanks to Keith Zantow of VT for answering this question on the uPortal listThe most common method of switching portlet modes is through a URL. For example, you might create an "edit" URL that when clicked, sends the user to the portlet's edit mode. Portlet mode-switching links may be created through the use of the portlet JSP tag library:

Code Block
html
html

<portlet:renderURL mode="edit"/>

It is also possible to create a URL which will switch the mode of a portlet through direct use of the Java API:

Code Block
java
java

PortletURL myPortletURL = response.createRenderURL();
myPortletURL.setPortletMode(PortletModeEDIT);

Window states may also be set via either the JSP tag or Java API.

Changing portlet mode programmatically

...