[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jetspeed-user
Subject:    RE: jsp screen loading
From:       Matt Pollak <mpollak () CreativeSolutions ! com>
Date:       2001-09-25 19:27:22
[Download RAW message or body]

As Spike is a colleague of mine, I'll try to clarify the problem we are
having.

> -----Original Message-----
> From: Spike [mailto:spike@interspike.com]
> Sent: Tuesday, September 25, 2001 6:08 AM
> To: jetspeed-user@jakarta.apache.org
> Subject: jsp screen loading
> 
> 
> Greetings Jetspeed Users,
> 
> This question is directed at those using a mix of velocity 
> and jsp pages in
> Jetspeed:
> 
> Suppose you have a *.jsp portlet that contains links and/or 
> buttons. When a
> user clicks on one of these the action class for that portlet 
> handles the
> submission. I understand how to call specific methods in the 
> action handler
> by appropriately naming the buttons but how does one load a new *.jsp
> screen? Specifically, from the action class we want to load a 
> screen that is
> not a portlet. The *.jsp screen that loads should look similar to a
> maximized portlet but be just another *.jsp page with it's 
> own action class
> to handle submissions. We have been able to get a *.jsp page 
> to load by
> setting the screen in the action class but the portlet frame 
> is missing. It
> seems there are a couple ways to do this but which is most 
> appropriate given
> the turbine/velocity template approach?

We have a number of portlets in our current configuration.  One of these
portlets displays a list of records that are in our database, and several
items (for each record) will have links that should take the user to an
interface for manipulating that data.  I was hoping to create several JSP
files to take care of those interfaces, and I would swap these in and out of
the current portlet.  Or at the very least to make these files imitate the
behavior of maximizing a portlet by taking over most of the screen. (I know
that most of you prefer VM portlets, but we are on a tight schedule and some
of the JSP functionality already exists, so it would be preferable to reuse
those.)    These jsp files are not registered in portlets.xreg as portlets.
I created an action class, "RedirectAction",  that accepts a URL (String)
from the request object, sets a session attribute, and sets a screen.  The
code follows, I am omitting the imports for the sake of brevity:


public class RedirectAction extends org.apache.turbine.modules.Action
{   
   public void doPerform(RunData data) throws Exception  
   {
      HttpServletRequest request = data.getRequest();      
      HttpSession session = data.getSession();
      
      if(request.getParameter("target") == null) {
         return;  
      }
      session.setAttribute("CSIPortletRedirect",
request.getParameter("target"));

      data.setScreen("RedirectScreen");    
   }
}


As part of this, I created a class called RedirectScreen that should get us
to the proper jsp file.  Its code follows, again omitting imports:


public class RedirectScreen extends org.apache.turbine.modules.Screen
{

    public ConcreteElement doBuild(RunData data)
        throws Exception
    {
        HttpSession session = data.getSession();
        EcsServletElement element ;
        String template =
(String)session.getAttribute("CSIPortletRedirect");
        session.removeAttribute("CSIPortletRedirect");
        
        try {

           Log.note("template:" + template);

           element = new EcsServletElement(data, template);

        } 
        catch (Exception e) 
        {
            String message = "JspPortlet: Could not include the following
JSP Page:  " + template + " : "+ e.getMessage();
            Log.error( message, e );
            return new StringElement( message );
        }
        return element;
    }
}


What this ends up doing is replacing the entire "body" or "Screen" portion
of the page, referring the the diagram in the Layout section of
http://jakarta.apache.org/turbine/turbine-2/fsd.html, with the JSP page, and
there are no controls on it or anything.  Can anyone suggest an alternative,
or what I might be missing, that might allow the JSP pages to take over the
current portlet, or at least appear to be a maximized portlet of their own?
Or how I might go about linking to them if I were to add them to
portlets.xreg?  (Although I am not sure that would work, as they are more of
pieces of one portlet, as opposed to portlets of their own.)

Any help is greatly appreciated,
Matt Pollak










 

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic