You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by "Luta, Raphael (VUN)" <Ra...@groupvu.Com> on 2003/01/17 10:34:19 UTC

RE: How to refer to another JSP (from a JSP portlet) staying with in "portlet context"

De : Mike Davis [mailto:thedivrox@yahoo.com]
> 
> Hi Mark,
>      To be clear, what I am trying to do is (within a JSP 
> Portlet) present a hyperlink (with some attached request 
> parameters) that refers to itself within the normal context.  
>  Is there some other link type (tag) I can use to do this 
> (link? navigation?) ?   
> This would look like in a "regular" JSP something like:
> myJSP.jsp---------
> // lots of stuff here
> <a href="myJSP.jsp?myparm=somevalue">click here</a>
> // more stuff
> ------ end myJSP.jsp -----
> The portletlink tag does what I want other than rendering in 
> the Maximized view as described previously...
> Thanks again,
>                      Mike
>  

IF you plan to extensively use the JSPPorlet (or VelocityPortlet),
I'd advise you to become familiar with the MVC model 2 pattern as
implemented by Turbine 2.

http://jakarta.apache.org/turbine/turbine-22/model2+1.html

JSPPortlet and VelocityPortlet *enforce* the use of such patterns, so 
to control your templates depending on the state of your portlet you
need to use the Action class to control your next template.

Best practice:
- define your portlet as a state machine,
- use a "state" parameter in your templates to indicate which state you
want to reach
- Optional: you may want to include a "prevstate" and or "nextstate"
parameters if you want to provide contextual back/next navigation
- define in your portlet registry entry (or though name conventions)
  the template associated with each state.

In your PortletAction build() methods you can use setTemplate()
to indicate which template will use to display your data.

So you need to use something like <a
href="<js:jslink/>?state=details">...</a>
(I haven't checked the exact JSP syntax as I tend to use Velocity)

And have in your buildNormalContext() sdomething like :

String state = request.getParameter("state");
String template = null;
if (state!=null)
{
  template = portlet.getInitParameters("template."+state);
  if (template != null)
  {
    setTemplate(data,template);
  }
  else
  {
    // unknown state, display an error message or revert to default state
  }
}

You'll find that thinking in terms of state machines and controlling the
actual template names through the registry parameters will give you a lot
of maintenance flexibility and a very clear design (UML state diagrams
are your friends) at a very low cost in terls of complexity.

--
Raphaƫl Luta - raphael@apache.org
Jakarta Jetspeed - Enterprise Portal in Java
http://jakarta.apache.org/jetspeed/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>