Nope, I can't give you an example, because you can't do it.
Essentially, what you are saying is that you have a portal page, with a portlet on it. A user has intentionally added a portlet to that portal page. And what you want to do is, when a button or something is clicked, flip out the portlet a user wanted on their page, with another portlet that you are deciding you want the user to see. Nope, that's simply not allowed.
Don't mean to be glib, but portlet development really requires a mind shift. You have to totally rethink how you develop applications.
However, what you CAN do, is perhaps, when a button is clicked, display a different
JSP to the user that displays different content. Here's a very simple, free online tutorial that talks about forwarding to JSPs from a portlet:
Free CBT Tutorial on Portlet Development: Forwarding to JSPs from a JSR168 Portlet Alternatively, if you have a number of complex page transitions, you might want to use a
Struts or
Java Server Faces portlet. Bridges are avaialbe from apache. Of course, if you're a new to portlet development, you might not want to overly complicate things by integrating the struts portlet bridge, or
JSF portlet bridge into your application, but it's always an option. Here are some tutorials on creating the struts portlet, and the JSF portlet:
CBT Tutorial on Creating the JSR-168 Struts and JSF Portlets (deployed to LifeRay & JetSpeed) Good luck, and have fun developing for the portal.
-Cameron McKenzie