From b437a15e73778367b599db76009f4d28aeeb20b5 Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Sun, 27 Jun 2004 02:38:51 +0000 Subject: [PATCH] added content metadata processing and its first application, making the Front Page auto-refresh --- etc/ui-config.xml | 3 + scripts/top.js | 9 +- .../venice/ui/ContentMetadata.java | 28 +++++ src/com/silverwrist/venice/ui/LinkTypes.java | 6 +- .../venice/ui/config/RootConfig.java | 61 +++++----- .../ui/config/default-config.properties | 7 +- .../venice/ui/servlet/RequestImpl.java | 110 ++++++++++++++---- .../silverwrist/venice/ui/view/JSPView.java | 102 +++++++++++----- .../venice/ui/view/NestedJSPView.java | 71 +++++++---- .../venice/ui/view/SideBoxNestedView.java | 107 ++++++++++++----- 10 files changed, 364 insertions(+), 140 deletions(-) create mode 100644 src/com/silverwrist/venice/ui/ContentMetadata.java diff --git a/etc/ui-config.xml b/etc/ui-config.xml index 7647df5..eb9c104 100644 --- a/etc/ui-config.xml +++ b/etc/ui-config.xml @@ -68,6 +68,9 @@ 31536000 + + 300 + diff --git a/scripts/top.js b/scripts/top.js index 533a23a..b2a3372 100644 --- a/scripts/top.js +++ b/scripts/top.js @@ -8,9 +8,9 @@ // // The Original Code is the Venice Web Communities System. // -// The Initial Developer of the Original Code is Eric J. Bowersox , +// The Initial Developer of the Original Code is Eric J. Bowersox , // for Silverwrist Design Studios. Portions created by Eric J. Bowersox are -// Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. +// Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. // // Contributor(s): @@ -54,6 +54,11 @@ try view.menuSelector = Content.MENU_SELECTOR_TOP; view.pageQID = "top"; + // set it up to auto-refresh if configured to do that + ar = rinput.getConfigProperty("top.refresh"); + if (ar!=null) + view.addHTTPMetadata("refresh",ar); + // wrap the JSP view in our sidebox view for return rc = new SideBoxNestedView(rinput,view); diff --git a/src/com/silverwrist/venice/ui/ContentMetadata.java b/src/com/silverwrist/venice/ui/ContentMetadata.java new file mode 100644 index 0000000..6a1d5ea --- /dev/null +++ b/src/com/silverwrist/venice/ui/ContentMetadata.java @@ -0,0 +1,28 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.venice.ui; + +import java.util.Map; + +public interface ContentMetadata +{ + public Map getMetadata(); + + public Map getHTTPMetadata(); + +} // end interface ContentMetadata diff --git a/src/com/silverwrist/venice/ui/LinkTypes.java b/src/com/silverwrist/venice/ui/LinkTypes.java index 3348cae..d91f5f5 100644 --- a/src/com/silverwrist/venice/ui/LinkTypes.java +++ b/src/com/silverwrist/venice/ui/LinkTypes.java @@ -9,9 +9,9 @@ * * The Original Code is the Venice Web Communities System. * - * The Initial Developer of the Original Code is Eric J. Bowersox , + * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -25,4 +25,6 @@ public interface LinkTypes public static final int FRAME = 2; + public static final int FULLSERVLET = 3; + } // end interface LinkTypes diff --git a/src/com/silverwrist/venice/ui/config/RootConfig.java b/src/com/silverwrist/venice/ui/config/RootConfig.java index 360f4b3..cee01c9 100644 --- a/src/com/silverwrist/venice/ui/config/RootConfig.java +++ b/src/com/silverwrist/venice/ui/config/RootConfig.java @@ -9,9 +9,9 @@ * * The Original Code is the Venice Web Communities System. * - * The Initial Developer of the Original Code is Eric J. Bowersox , + * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -282,32 +282,32 @@ public class RootConfig implements LinkTypes, ColorSelectors // Retrieve the site logo. sect1 = loader.configGetSubSection(sect_h,"site-logo"); sect1_h = new DOMElementHelper(sect1); - StringBuffer tmpbuf = new StringBuffer("\"").append(site_title).append("\""); + tmpbuf.append(itmp).append("\" border=\"0\" />"); site_logo_img_tag = tmpbuf.toString(); // Get the link URL of the logo. @@ -334,9 +334,9 @@ public class RootConfig implements LinkTypes, ColorSelectors itmp = new Integer(100); int tmp_width = (VENICE_IMAGE_WIDTH * itmp.intValue()) / 100; int tmp_height = (VENICE_IMAGE_HEIGHT * itmp.intValue()) / 100; - venice_logo_tag = "\"""; + venice_logo_tag = "\"""; // Get the page icon and icon type, and the "favorites icon" (MS-specific). String page_icon_1 = null, page_icon_2 = null; @@ -344,7 +344,7 @@ public class RootConfig implements LinkTypes, ColorSelectors if (sect1!=null) { // get the URL and create the "shortcut icon" tag String url = loader.configGetText(sect1); - page_icon_2 = "\n"; + page_icon_2 = "\n"; } // end if @@ -353,9 +353,9 @@ public class RootConfig implements LinkTypes, ColorSelectors { // get the URL and type, and create the page icon tag String url = loader.configGetText(sect1); String type = loader.configGetAttribute(sect1,"type"); - page_icon_1 = "\n"; + page_icon_1 = "\n"; if (page_icon_2==null) // fill this in for the "shortcut icon" as well - page_icon_2 = "\n"; + page_icon_2 = "\n"; } // end if @@ -370,7 +370,7 @@ public class RootConfig implements LinkTypes, ColorSelectors // Get the default font face name. font_face = loader.configGetSubElementText(sect_h,"font"); - base_font = ""; + base_font = ""; // Load the stock font sizes. sect1 = sect_h.getSubElement("font-sizes"); @@ -406,11 +406,11 @@ public class RootConfig implements LinkTypes, ColorSelectors // Set up the content header array. content_hdr = new String[5]; - content_hdr[0] = "" + getFontTag(CONTENT_HEADER,"header") + ""; - content_hdr[1] = ""; - content_hdr[2] = "  " + getFontTag(CONTENT_HEADER,"subhead") + ""; - content_hdr[3] = ""; - content_hdr[4] = "
\n"; + content_hdr[0] = "" + getFontTag(CONTENT_HEADER,"header") + ""; + content_hdr[1] = ""; + content_hdr[2] = "  " + getFontTag(CONTENT_HEADER,"subhead") + ""; + content_hdr[3] = ""; + content_hdr[4] = "
\n"; // Get the "HTML Comments" flag. html_comments = sect_h.hasChildElement("html-comments"); @@ -652,16 +652,16 @@ public class RootConfig implements LinkTypes, ColorSelectors public final String getFontTag(int colorsel, int size) { - return ""; + return ""; } // end getFontTag public final String getFontTag(String color, int size) { - StringBuffer rc = new StringBuffer("'); return rc.toString(); @@ -669,10 +669,10 @@ public class RootConfig implements LinkTypes, ColorSelectors public final String getFontTag(int colorsel, String size) { - StringBuffer rc = new StringBuffer("'); return rc.toString(); @@ -680,12 +680,12 @@ public class RootConfig implements LinkTypes, ColorSelectors public final String getFontTag(String color, String size) { - StringBuffer rc = new StringBuffer("'); return rc.toString(); @@ -858,6 +858,7 @@ public class RootConfig implements LinkTypes, ColorSelectors m.put("absolute",new Integer(ABSOLUTE)); m.put("servlet",new Integer(SERVLET)); m.put("frame",new Integer(FRAME)); + m.put("fullservlet",new Integer(FULLSERVLET)); link_types = Collections.unmodifiableMap(m); } // end static initializer diff --git a/src/com/silverwrist/venice/ui/config/default-config.properties b/src/com/silverwrist/venice/ui/config/default-config.properties index 958fd7a..df27f3c 100644 --- a/src/com/silverwrist/venice/ui/config/default-config.properties +++ b/src/com/silverwrist/venice/ui/config/default-config.properties @@ -8,13 +8,14 @@ # # The Original Code is the Venice Web Communities System. # -# The Initial Developer of the Original Code is Eric J. Bowersox , +# The Initial Developer of the Original Code is Eric J. Bowersox , # for Silverwrist Design Studios. Portions created by Eric J. Bowersox are -# Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. +# Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. # # Contributor(s): # ------------------------------------------------------------------------------------- # Default values for the properties that are loaded from the ui-config.xml section. session.init=session_init.js login.cookie=VeniceAuth -login.cookie.age=31536000 \ No newline at end of file +login.cookie.age=31536000 +# no default for top.refresh diff --git a/src/com/silverwrist/venice/ui/servlet/RequestImpl.java b/src/com/silverwrist/venice/ui/servlet/RequestImpl.java index 7e7855d..47c72f6 100644 --- a/src/com/silverwrist/venice/ui/servlet/RequestImpl.java +++ b/src/com/silverwrist/venice/ui/servlet/RequestImpl.java @@ -50,12 +50,27 @@ public class RequestImpl implements RequestInput class OutputImpl implements RequestOutput { + /*==================================================================== + * Attributes + *==================================================================== + */ + private Writer wr = null; + /*==================================================================== + * Constructor + *==================================================================== + */ + OutputImpl() { // do nothing } // end constructor + /*==================================================================== + * Implementations from interface ServiceProvider + *==================================================================== + */ + public Object queryService(Class klass) { if (klass==HTMLRendering.class) @@ -70,6 +85,11 @@ public class RequestImpl implements RequestInput } // end queryService + /*==================================================================== + * Implementations from interface RequestOutput + *==================================================================== + */ + public Writer getWriter() throws IOException { if (wr==null) @@ -237,17 +257,51 @@ public class RequestImpl implements RequestInput { HTMLRendering html = (HTMLRendering)(RequestImpl.this.queryService(HTMLRendering.class)); - out.write("\n" + config.getPageTitle(c.getPageTitle(this)) + "\n" + out.write("\n" + config.getPageTitle(c.getPageTitle(this)) + "\n" + config.getBaseFontTag() + "\n"); if (config.usingStyleSheet()) - out.write("\n"); + out.write("\n"); String tmp = config.getPageIconTags(); if (tmp!=null) out.write(tmp); if (!(config.useSmartTags())) - out.write("\n"); - out.write("\n"); + out.write("\n"); + if (c instanceof ContentMetadata) + { // look for additional metadata on the content + ContentMetadata cm = (ContentMetadata)c; + Map meta = cm.getMetadata(); + if (meta==null) + meta = Collections.EMPTY_MAP; + Iterator it; + for (it=meta.entrySet().iterator(); it.hasNext(); ) + { // write the metadata + Map.Entry ntry = (Map.Entry)(it.next()); + out.write("\n"); + + } // end for + + meta = cm.getHTTPMetadata(); + if (meta==null) + meta = Collections.EMPTY_MAP; + for (it=meta.entrySet().iterator(); it.hasNext(); ) + { // write the metadata + Map.Entry ntry = (Map.Entry)(it.next()); + out.write("\n"); + + } // end for + + } // end if + + out.write("\n"); } // end writeFrameHead @@ -265,10 +319,10 @@ public class RequestImpl implements RequestInput String href = config.getSiteLogoLink(); if (href!=null) - out.write(""); + out.write(""); out.write(config.getSiteLogoImageTag()); if (href!=null) - out.write(""); + out.write(""); } // end writeSiteImageTag @@ -317,10 +371,20 @@ public class RequestImpl implements RequestInput class ExecImpl implements RequestExec { + /*==================================================================== + * Constructor + *==================================================================== + */ + ExecImpl() { // do nothing } // end constructor + /*==================================================================== + * Implementations from interface RequestExec + *==================================================================== + */ + public void error(int code) throws IOException { flushCookies(); @@ -454,7 +518,7 @@ public class RequestImpl implements RequestInput */ private static Logger logger = Logger.getLogger(RequestImpl.class); - private static int serial_gen = 1; + private static int s_serial_gen = 1; private static final String APP_ATTRIBUTE_STEM = "com.silverwrist.venice.ui.variables."; @@ -468,7 +532,7 @@ public class RequestImpl implements RequestInput *-------------------------------------------------------------------------------- */ - private int serial; // serial number of this request + private int m_serial; // serial number of this request private ServletContext ctxt; // the servlet context private HttpServletRequest request; // the servlet request data private HttpServletResponse response; // the servlet response data @@ -508,7 +572,7 @@ public class RequestImpl implements RequestInput synchronized (RequestImpl.class) { // add serial number - this.serial = serial_gen++; + m_serial = s_serial_gen++; } // end synchronized block @@ -751,15 +815,19 @@ public class RequestImpl implements RequestInput * "http://venice.example.org/venice/foobar". * * @param spath Servlet path to be expanded. + * @param encode true to encode the servlet path first, false to not do so. * @return The fully-expanded servlet path. */ - final String expandServletPath(String spath) + final String expandServletPath(String spath, boolean encode) { StringBuffer buf = new StringBuffer("http://"); buf.append(request.getServerName()); if (request.getServerPort()!=80) buf.append(':').append(request.getServerPort()); - buf.append(request.getContextPath()).append('/').append(spath); + if (encode) + buf.append(encodeServletPath(spath)); + else + buf.append(request.getContextPath()).append('/').append(spath); return buf.toString(); } // end expandServletPath @@ -772,7 +840,7 @@ public class RequestImpl implements RequestInput public String toString() { StringBuffer buf = new StringBuffer("{RequestImpl #"); - buf.append(serial).append("from [").append(request.getRemoteAddr()).append("] for "); + buf.append(m_serial).append("from [").append(request.getRemoteAddr()).append("] for "); buf.append(request.getServletPath()).append("}"); return buf.toString(); @@ -2000,6 +2068,8 @@ class HTMLRenderingImpl implements HTMLRendering return req.encodeServletPath(url); else if (type==FRAME) return req.encodeServletPath("frame/" + url); + else if (type==FULLSERVLET) + return req.expandServletPath(url,true); else throw new IndexOutOfBoundsException("invalid format type index for formatURL"); @@ -2102,13 +2172,13 @@ class HTMLRenderingImpl implements HTMLRendering public String getUserPhotoTag(String url, Dimension size) { - StringBuffer buf = new StringBuffer("\"\""); + buf.append("\" alt=\"\" align=\"left\" border=\"0\" width=\"").append(size.width).append("\" height=\""); + buf.append(size.height).append("\" />"); return buf.toString(); } // end getUserPhotoTag @@ -2160,21 +2230,21 @@ class HTMLRenderingImpl implements HTMLRendering public String getCommunityLogoTag(String url) { - StringBuffer buf = new StringBuffer("\"\""); + buf.append("\" alt=\"\" border=\"0\" width=\"").append(sz.width).append("\" height=\"").append(sz.height); + buf.append("\" />"); return buf.toString(); } // end getCommunityLogoTag public String expandServletPath(String spath) { - return req.expandServletPath(spath); + return req.expandServletPath(spath,false); } // end expandServletPath diff --git a/src/com/silverwrist/venice/ui/view/JSPView.java b/src/com/silverwrist/venice/ui/view/JSPView.java index de1dfd3..e7e30d9 100644 --- a/src/com/silverwrist/venice/ui/view/JSPView.java +++ b/src/com/silverwrist/venice/ui/view/JSPView.java @@ -9,35 +9,36 @@ * * The Original Code is the Venice Web Communities System. * - * The Initial Developer of the Original Code is Eric J. Bowersox , + * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.venice.ui.view; -import java.util.Date; -import java.util.HashMap; +import java.util.*; import javax.servlet.*; import com.silverwrist.venice.core.CommunityContext; import com.silverwrist.venice.ui.*; import com.silverwrist.venice.ui.helpers.HTMLRendering; import com.silverwrist.venice.ui.servlet.RequestImpl; -public class JSPView implements ContentJSP +public class JSPView implements ContentJSP, ContentMetadata { /*-------------------------------------------------------------------------------- * Attributes *-------------------------------------------------------------------------------- */ - private int menu_sel = MENU_SELECTOR_NOCHANGE; - private String title; - private String qid = null; - private String jsp_name; - private RequestInput rinput = null; - private HTMLRendering html = null; + private int m_menu_sel = MENU_SELECTOR_NOCHANGE; // menu selector output by this code + private String m_title; // page title + private String m_qid = null; // page Quick ID + private String m_jsp_name; // name of JSP page to forward to + private RequestInput m_rinput = null; // input request used by inner code + private HTMLRendering m_html = null; // HTML rendering helper + private HashMap m_metadata = null; // collection of metadata to output + private HashMap m_http_metadata = null; // collection of HTTP metadata to output /*-------------------------------------------------------------------------------- * Constructor @@ -46,8 +47,8 @@ public class JSPView implements ContentJSP public JSPView(String title, String jsp_name) { - this.title = title; - this.jsp_name = jsp_name; + m_title = title; + m_jsp_name = jsp_name; } // end constructor @@ -64,19 +65,19 @@ public class JSPView implements ContentJSP public int getMenuSelector() { - return menu_sel; + return m_menu_sel; } // end getMenuSelector public String getPageTitle(RequestOutput ro) { - return title; + return m_title; } // end getPageTitle public String getPageQID() { - return qid; + return m_qid; } // end getPageQID @@ -87,24 +88,47 @@ public class JSPView implements ContentJSP public String getJSPName() { - return jsp_name; + return m_jsp_name; } // end getJSPName public void initialize(RequestInput req) { - rinput = req; - html = (HTMLRendering)(req.queryService(HTMLRendering.class)); + m_rinput = req; + m_html = (HTMLRendering)(req.queryService(HTMLRendering.class)); } // end initialize public void terminate(RequestInput req) { - rinput = null; - html = null; + m_rinput = null; + m_html = null; } // end terminate + /*-------------------------------------------------------------------------------- + * Implementations from interface ContentMetadata + *-------------------------------------------------------------------------------- + */ + + public Map getMetadata() + { + if (m_metadata==null) + return Collections.EMPTY_MAP; + else + return Collections.unmodifiableMap(m_metadata); + + } // end getMetadata + + public Map getHTTPMetadata() + { + if (m_http_metadata==null) + return Collections.EMPTY_MAP; + else + return Collections.unmodifiableMap(m_http_metadata); + + } // end getHTTPMetadata + /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- @@ -112,39 +136,59 @@ public class JSPView implements ContentJSP public final void setMenuSelector(int sel) { - if (rinput==null) - menu_sel = sel; + if (m_rinput==null) + m_menu_sel = sel; } // end setMenuSelector public final void setPageQID(String s) { - if (rinput==null) - qid = s; + if (m_rinput==null) + m_qid = s; } // end setPageQID + public final void addMetadata(String name, String value) + { + if (m_rinput!=null) + return; + if (m_metadata==null) + m_metadata = new HashMap(); + m_metadata.put(name,value); + + } // end addMetadata + + public final void addHTTPMetadata(String name, String value) + { + if (m_rinput!=null) + return; + if (m_http_metadata==null) + m_http_metadata = new HashMap(); + m_http_metadata.put(name,value); + + } // end addHTTPMetadata + public final Object getRequestAttribute(String s) { - return ((rinput==null) ? null : rinput.getRequestAttribute(s)); + return ((m_rinput==null) ? null : m_rinput.getRequestAttribute(s)); } // end getRequestAttribute public final String formatDate(Date date) { - return ((html==null) ? null : html.formatDate(date)); + return ((m_html==null) ? null : m_html.formatDate(date)); } // end formatDate public final CommunityContext getCommunity() { - return ((rinput==null) ? null : rinput.getCommunity()); + return ((m_rinput==null) ? null : m_rinput.getCommunity()); } // end getCommunity public final String getActivityString(Date date) { - return ((html==null) ? null : html.getActivityString(date)); + return ((m_html==null) ? null : m_html.getActivityString(date)); } // end getActivityString diff --git a/src/com/silverwrist/venice/ui/view/NestedJSPView.java b/src/com/silverwrist/venice/ui/view/NestedJSPView.java index 1b74284..330ae0a 100644 --- a/src/com/silverwrist/venice/ui/view/NestedJSPView.java +++ b/src/com/silverwrist/venice/ui/view/NestedJSPView.java @@ -9,32 +9,32 @@ * * The Original Code is the Venice Web Communities System. * - * The Initial Developer of the Original Code is Eric J. Bowersox , + * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2002-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.venice.ui.view; -import java.util.Date; +import java.util.*; import javax.servlet.*; import com.silverwrist.venice.core.CommunityContext; import com.silverwrist.venice.ui.*; import com.silverwrist.venice.ui.helpers.HTMLRendering; import com.silverwrist.venice.ui.servlet.RequestImpl; -public class NestedJSPView implements ContentJSP +public class NestedJSPView implements ContentJSP, ContentMetadata { /*-------------------------------------------------------------------------------- * Attributes *-------------------------------------------------------------------------------- */ - private Content outer; - private String jspname; - private RequestInput rinput = null; - private HTMLRendering html = null; + private Content m_outer; // outer content being rendered + private String m_jspname; // JSP template to be rendered + private RequestInput m_rinput = null; // RequestInput object for use by internal code + private HTMLRendering m_html = null; // HTML rendering helper /*-------------------------------------------------------------------------------- * Constructor @@ -43,8 +43,8 @@ public class NestedJSPView implements ContentJSP public NestedJSPView(Content outer, String jspname) { - this.outer = outer; - this.jspname = jspname; + m_outer = outer; + m_jspname = jspname; } // end constructor @@ -55,25 +55,25 @@ public class NestedJSPView implements ContentJSP public boolean needFrame() { - return outer.needFrame(); + return m_outer.needFrame(); } // end needFrame public int getMenuSelector() { - return outer.getMenuSelector(); + return m_outer.getMenuSelector(); } // end getMenuSelector public String getPageTitle(RequestOutput ro) { - return outer.getPageTitle(ro); + return m_outer.getPageTitle(ro); } // end getPageTitle public String getPageQID() { - return outer.getPageQID(); + return m_outer.getPageQID(); } // end getPageQID @@ -84,24 +84,47 @@ public class NestedJSPView implements ContentJSP public String getJSPName() { - return jspname; + return m_jspname; } // end getJSPName public void initialize(RequestInput req) { - rinput = req; - html = (HTMLRendering)(req.queryService(HTMLRendering.class)); + m_rinput = req; + m_html = (HTMLRendering)(req.queryService(HTMLRendering.class)); } // end initialize public void terminate(RequestInput req) { - rinput = null; - html = null; + m_rinput = null; + m_html = null; } // end terminate + /*-------------------------------------------------------------------------------- + * Implementations from interface ContentMetadata + *-------------------------------------------------------------------------------- + */ + + public Map getMetadata() + { + if (m_outer instanceof ContentMetadata) + return ((ContentMetadata)m_outer).getMetadata(); + else + return Collections.EMPTY_MAP; + + } // end getMetadata + + public Map getHTTPMetadata() + { + if (m_outer instanceof ContentMetadata) + return ((ContentMetadata)m_outer).getHTTPMetadata(); + else + return Collections.EMPTY_MAP; + + } // end getHTTPMetadata + /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- @@ -109,31 +132,31 @@ public class NestedJSPView implements ContentJSP public final Content getOuterView() { - return outer; + return m_outer; } // end getOuterView public final Object getRequestAttribute(String s) { - return ((rinput==null) ? null : rinput.getRequestAttribute(s)); + return ((m_rinput==null) ? null : m_rinput.getRequestAttribute(s)); } // end getRequestAttribute public final String formatDate(Date date) { - return ((html==null) ? null : html.formatDate(date)); + return ((m_html==null) ? null : m_html.formatDate(date)); } // end formatDate public final CommunityContext getCommunity() { - return ((rinput==null) ? null : rinput.getCommunity()); + return ((m_rinput==null) ? null : m_rinput.getCommunity()); } // end getCommunity public final String getActivityString(Date date) { - return ((html==null) ? null : html.getActivityString(date)); + return ((m_html==null) ? null : m_html.getActivityString(date)); } // end getActivityString diff --git a/src/com/silverwrist/venice/ui/view/SideBoxNestedView.java b/src/com/silverwrist/venice/ui/view/SideBoxNestedView.java index 855cd36..5619ffa 100644 --- a/src/com/silverwrist/venice/ui/view/SideBoxNestedView.java +++ b/src/com/silverwrist/venice/ui/view/SideBoxNestedView.java @@ -9,95 +9,119 @@ * * The Original Code is the Venice Web Communities System. * - * The Initial Developer of the Original Code is Eric J. Bowersox , + * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.venice.ui.view; import java.io.IOException; +import java.util.Collections; +import java.util.Map; import javax.servlet.ServletException; import com.silverwrist.venice.core.UserContext; import com.silverwrist.venice.except.*; import com.silverwrist.venice.ui.*; import com.silverwrist.venice.ui.helpers.HTMLRendering; -public class SideBoxNestedView implements ContentDirect +public class SideBoxNestedView implements ContentDirect, ContentMetadata { - private Content inner; - private Content[] sideboxes; - private boolean do_configure; + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private Content m_inner; // the inner content object to be displayed + private Content[] m_sideboxes; // the sideboxes to be displayed + private boolean m_configure; // display the sidebox Configure button? + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ public SideBoxNestedView(RequestInput ri, Content inner) throws AccessError, DataException { - this.inner = inner; - this.sideboxes = ri.getSideBoxes(); - this.do_configure = ri.getUser().isLoggedIn(); + m_inner = inner; + m_sideboxes = ri.getSideBoxes(); + m_configure = ri.getUser().isLoggedIn(); } // end constructor + /*-------------------------------------------------------------------------------- + * Implementations from interface Content + *-------------------------------------------------------------------------------- + */ + public boolean needFrame() { - return inner.needFrame(); + return m_inner.needFrame(); } // end needFrame public int getMenuSelector() { - return inner.getMenuSelector(); + return m_inner.getMenuSelector(); } // end getMenuSelector public String getPageTitle(RequestOutput ro) { - return inner.getPageTitle(ro); + return m_inner.getPageTitle(ro); } // end getPageTitle public String getPageQID() { - return inner.getPageQID(); + return m_inner.getPageQID(); } // end getPageQID + /*-------------------------------------------------------------------------------- + * Implementations from interface ContentDirect + *-------------------------------------------------------------------------------- + */ + public void render(RequestOutput out) throws IOException { HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class)); try { // Write out the start of the content structure. - out.write("\n" - + "
\n"); + out.write("\n" + + "\n\n\n"); } // end for - if (do_configure) // write the Configure button below the sideboxes - out.write("" - + html.getButtonVisual("configure") + "\n"); + if (m_configure) // write the Configure button below the sideboxes + out.write("\n"); // Finish up. - out.write("\n
\n"); // Write out the inner content. - out.output(inner); + out.output(m_inner); - out.write("\n"); // break to the sidebox column + out.write("\n"); // break to the sidebox column - for (int i=0; i
\n" - + html.getFontTag(html.SIDEBOX_TITLE_FOREGROUND,"sidebox-title") + "" - + sideboxes[i].getPageTitle(out) + "\n
\n"); + out.write("
\n\n
" + + html.getFontTag(html.SIDEBOX_TITLE_FOREGROUND,"sidebox-title") + "" + + m_sideboxes[i].getPageTitle(out) + "
\n"); - out.output(sideboxes[i]); // output the sidebox content + out.output(m_sideboxes[i]); // output the sidebox content // close up the framework of this sidebox - out.write("

\n"); + out.write("

 
" + html.getButtonVisual("configure") + + "
"); + out.write("
\n"); } // end try catch (ServletException se) @@ -108,4 +132,27 @@ public class SideBoxNestedView implements ContentDirect } // end render + /*-------------------------------------------------------------------------------- + * Implementations from interface ContentMetadata + *-------------------------------------------------------------------------------- + */ + + public Map getMetadata() + { + if (m_inner instanceof ContentMetadata) + return ((ContentMetadata)m_inner).getMetadata(); + else + return Collections.EMPTY_MAP; + + } // end getMetadata + + public Map getHTTPMetadata() + { + if (m_inner instanceof ContentMetadata) + return ((ContentMetadata)m_inner).getHTTPMetadata(); + else + return Collections.EMPTY_MAP; + + } // end getHTTPMetadata + } // end class SideBoxNestedView