package org.projectapollo.demo.Frame;

import apollo.*;
import apollo.Template.*;
import apollo.Storable.*;
import org.projectapollo.demo.Frame.TopFrame.*;
import java.util.*;
import apollo.Session.*;

public class FrameBroker extends PageBroker {
    public FrameBroker(ManagerTracker MT, String fquid, PageBroker PB) throws TemplatePageException {
        super(MT,fquid,PB);
        this.registerPageHandler("TopFrame",new TopFrameBroker(MT,fquid+".TopFrame", this));
        MT.getPM().registerTemplatePage(FQUID,
new TemplatePage(MT,this));
    }
 
    public HTTPResponse render(TransactionTracker TT, HTTPRequest req, WebSession thisSession) throws ApolloException {
        Hashtable RT =
new Hashtable();
        if (req.hasValue("ReturnFQUID")) {
            thisSession.setValue(
"ReturnFQUID",req.getValue("ReturnFQUID"));
        }
        if (req.hasValue("Title")) {
            RT.put(
"Title", req.getValue("Title"));
        }
else {
            RT.put(
"Title", req.getValue("Destination"));
        }
     
        if (req.getValue("Destination").substring(0,1).equals("!")) {
            RT.put(
"Destination",req.getValue("Destination").substring(1));
        }
else {
            RT.put(
"Main",thisSession.encodeURL(req.getServletPath()+"?PageHandler="+req.getValue("Destination")));
        }
        String body;
        if (req.hasValue("Destination")) {
            body=req.getValue(
"Destination");
        }
else {
            body=
"null";
        }
 
        if (req.hasValue("Top")) {
            if (req.getValue("Top").substring(0,1).equals("!")) {
                RT.put(
"Top",req.getValue("Top").substring(1));
            }
else {
                RT.put(
"Top",thisSession.encodeURL(req.getServletPath()+"?PageHandler="+req.getValue("Top")+"&Body="+body));
            }
        }
else {
            RT.put(
"Top",thisSession.encodeURL(req.getServletPath()+"?PageHandler=Frame.TopFrame&Body="+body));
        }
        if (req.hasValue("Left")) {
            if (req.getValue("Left").substring(0,1).equals("!")) {
                RT.put(
"Left",req.getValue("Left").substring(1));
            }
else {
                RT.put(
"Left",thisSession.encodeURL(req.getServletPath()+"?PageHandler="+req.getValue("Left")+"&Body="+body));
            }
        }
else {
            RT.put(
"Left",thisSession.encodeURL(req.getServletPath()+"?PageHandler="+req.getValue("Destination")+".LeftFrame"));
        }
        if (req.hasValue("StatusBar")) {
            if (req.getValue("StatusBar").substring(0,1).equals("!")) {
                RT.put(
"StatusBar",req.getValue("StatusBar").substring(1));
            }
else {
                RT.put(
"StatusBar",thisSession.encodeURL(req.getServletPath()+"?PageHandler="+req.getValue("StatusBar")));
            }
        }
else {
            RT.put(
"StatusBar",thisSession.encodeURL(req.getServletPath()+"?PageHandler=Jobs.StatusBar"));
        }
        return MT.getPM().getPage(FQUID).render(RT,thisSession);
    }
}