The moose likes Portals and Portlets and the fly likes Two Portlets in one window? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Two Portlets in one window?" Watch "Two Portlets in one window?" New topic

Two Portlets in one window?

Dennis Callag

Joined: Feb 02, 2007
Posts: 7
Hi everyone!

I've been surfing the Internet the whole day but haven't found a proper answer to my question / problem yet.

Hope you guys can help me: :-)

I have two Portlets A and B. I want Portlet A to display Portlet B in the _same window_ when a user clicks on an URL in Portlet A.
The user can return to Portlet A again by clicking on an URL in Portlet B.

Is it possible to display two Portlets in one window sequentially?

Cameron McKenzie

Joined: Feb 24, 2005
Posts: 12
No what you are asking for is completely and totally impossible.

Essentially, you want a user to add a portlet to a page. When they click on a url in that portlet, the portlet then should remove itself from the page entirely, which is actually a portal administrative task, and then, add a new portlet, to the same page, in it's place. Then, when a url in this second portlet is clicked, the portlet removes itself entirely from the page, causing all sorts of administrative steps to happen in the background, and then the new portlet appears. Lets not even get into the fact that when a portlet is removed from a page, all of the PortletPreferences or PortletData information is completely removed. Essentially, you'd have to write your own portal server to make this type of thing possible.

However, maybe your portlet has two JSP pages. When a link in one JSP is clicked, the second appears. When a link in the second JSP is clicked, the first one appears. The flow is managed by the portlet class, which correctly would be acting as a controller. I think this would be easier than trying to completely re-engineer a portal server.

Okay, my response is fairly snide and tongue in cheek. The fact is, with a portlet, you have to shift your mind a bit and think differently. It isn't a JSP/Servlet application anymore. But don't overcomplicate things. Keep it simple.

And just to note, with a live portal, portlets are very, very, very rarely ever added or removed from a page. People tend to get comfortable with their portal, and tend not to change it.

I've got a bunch of tutorials on JSR168 portlet development at my website (Check out my signature links) Please check them out. They might help you get more comfortable thinking in a portlet mindset.

-Cameron McKenzie

Where is Springfield? <a href="" target="_blank" rel="nofollow"></a><br /> <br />Portlet Tutorials & Java Certification mock exams: <a href="" target="_blank" rel="nofollow"></a><br /> <br />WebSphere Stuff: <a href="" target="_blank" rel="nofollow"></a>
Dennis Callag

Joined: Feb 02, 2007
Posts: 7
Cameron, thanks for your answer.
I expected already that it won't be possible.

heba emara

Joined: Mar 05, 2007
Posts: 3
I would recommend if you add other views (in the form of jsps) in the portlet and switch between the views if you like the idea I could help you more
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Heba has a very good point. It is fairly easy to have a class extend GenericPortlet and work as the controller in an MVC framework. Depending upon the PortletRequest coming in, the Portlet can forward to the appropriate JSP.

A fair possibility.

-Cameron McKenzie
I agree. Here's the link:
subject: Two Portlets in one window?
jQuery in Action, 3rd edition