cleaned up the code in here in prep for doing more extensive work shortly

This commit is contained in:
Eric J. Bowersox 2004-07-23 07:08:56 +00:00
parent b4c7aa4c8b
commit 899863578d

View File

@ -9,7 +9,7 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
@ -32,26 +32,26 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static Category logger = Category.getInstance(PostBoxTag.class); private static Logger logger = Logger.getLogger(PostBoxTag.class);
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Attributes * Attributes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private String action = null; private String m_action = null;
private String type = "servlet"; private String m_type = "servlet";
private int real_type = -1; private int m_real_type = -1;
private HashMap params = new HashMap(); private HashMap m_params = new HashMap();
private String newtopic_name = null; private String m_newtopic_name = null;
private String newtopic_value = null; private String m_newtopic_value = null;
private String pseud_name = null; private String m_pseud_name = null;
private String pseud_value = null; private String m_pseud_value = null;
private String attach_name = null; private String m_attach_name = null;
private boolean attach_value = false; private boolean m_attach_value = false;
private String text_name = null; private String m_text_name = null;
private String text_value = null; private String m_text_value = null;
private ArrayList buttons = new ArrayList(); private ArrayList m_buttons = new ArrayList();
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Overrides from class BodyTagSupport * Overrides from class BodyTagSupport
@ -62,11 +62,11 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("PostBoxTag.doStartTag(): entry"); logger.debug("PostBoxTag.doStartTag(): entry");
if (action==null) if (m_action==null)
throw new JspTagException("<post:box/> action= attribute not specified!"); throw new JspTagException("<post:box/> action= attribute not specified!");
HTMLRendering html = (HTMLRendering)(getRequestInput().queryService(HTMLRendering.class)); HTMLRendering html = (HTMLRendering)(getRequestInput().queryService(HTMLRendering.class));
real_type = html.convertLinkType(type); m_real_type = html.convertLinkType(m_type);
if (real_type<0) if (m_real_type<0)
throw new JspTagException("<post:box/> type= attribute not a valid link type"); throw new JspTagException("<post:box/> type= attribute not a valid link type");
return EVAL_BODY_BUFFERED; return EVAL_BODY_BUFFERED;
@ -84,13 +84,13 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("PostBoxTag.doEndTag(): entry"); logger.debug("PostBoxTag.doEndTag(): entry");
if (pseud_name==null) if (m_pseud_name==null)
throw new JspTagException("<post:box/> tag has no <post:pseud/> tag inside it!"); throw new JspTagException("<post:box/> tag has no <post:pseud/> tag inside it!");
if (attach_name==null) if (m_attach_name==null)
throw new JspTagException("<post:box/> tag has no <post:attach/> tag inside it!"); throw new JspTagException("<post:box/> tag has no <post:attach/> tag inside it!");
if (text_name==null) if (m_text_name==null)
throw new JspTagException("<post:box/> tag has no <post:text/> tag inside it!"); throw new JspTagException("<post:box/> tag has no <post:text/> tag inside it!");
if (buttons.isEmpty()) if (m_buttons.isEmpty())
throw new JspTagException("<post:box/> tag has no <post:button/> tags inside it!"); throw new JspTagException("<post:box/> tag has no <post:button/> tags inside it!");
HTMLRendering html = (HTMLRendering)(getRequestOutput().queryService(HTMLRendering.class)); HTMLRendering html = (HTMLRendering)(getRequestOutput().queryService(HTMLRendering.class));
@ -98,52 +98,52 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
try try
{ // write out what we came here to accomplish { // write out what we came here to accomplish
JspWriter out = pageContext.getOut(); JspWriter out = pageContext.getOut();
out.write("<FORM METHOD=\"POST\" ACTION=\"" + html.formatURL(action,real_type) out.write("<form method=\"POST\" action=\"" + html.formatURL(m_action,m_real_type)
+ "\"><DIV CLASS=\"content\">\n"); + "\"><div class=\"content\">\n");
Iterator it = params.entrySet().iterator(); Iterator it = m_params.entrySet().iterator();
while (it.hasNext()) while (it.hasNext())
{ // write the hidden parameters { // write the hidden parameters
Map.Entry ntry = (Map.Entry)(it.next()); Map.Entry ntry = (Map.Entry)(it.next());
out.write("<INPUT TYPE=\"HIDDEN\" NAME=\"" + ntry.getKey() + "\" VALUE=\"" + ntry.getValue() out.write("<input type=\"hidden\" name=\"" + ntry.getKey() + "\" value=\"" + ntry.getValue()
+ "\">\n"); + "\" />\n");
} // end while } // end while
String my_font = html.getFontTag(html.CONTENT_FOREGROUND,"content"); String my_font = html.getFontTag(html.CONTENT_FOREGROUND,"content");
out.write("<TABLE BORDER=0 CELLPADDING=0>\n"); out.write("<table border=\"0\" cellpadding=\"0\">\n");
if (newtopic_name!=null) if (m_newtopic_name!=null)
{ // write the "new topic name" field { // write the "new topic name" field
out.write("<TR><TD ALIGN=LEFT COLSPAN=2 CLASS=\"content\">\n" out.write("<tr><td align=\"left\" colspan=\"2\" class=\"content\">\n"
+ my_font + "New topic name:</FONT><BR>\n<SPAN CLASS=\"cinput\">" + my_font + "New topic name:</font><br />\n<span class=\"cinput\">"
+ "<INPUT TYPE=\"TEXT\" CLASS=\"cinput\" NAME=\"" + newtopic_name + "<input type=\"text\" class=\"cinput\" name=\"" + m_newtopic_name
+ "\" SIZE=37 MAXLENGTH=128 VALUE=\""); + "\" size=\"37\" maxlength=\"128\" VALUE=\"");
if (newtopic_value!=null) if (m_newtopic_value!=null)
out.write(newtopic_value); out.write(m_newtopic_value);
out.write("\"></SPAN>\n</TD></TR>\n"); out.write("\" /></span>\n</td></tr>\n");
} // end if } // end if
out.write("<TR><TD ALIGN=LEFT COLSPAN=2 CLASS=\"content\">\n" out.write("<tr><td align=\"left\" colspan=\"2\" class=\"content\">\n"
+ my_font + "Your name/header:</FONT><BR>\n<SPAN CLASS=\"cinput\">" + my_font + "Your name/header:</font><br/>\n<span class=\"cinput\">"
+ "<INPUT TYPE=\"TEXT\" CLASS=\"cinput\" NAME=\"" + pseud_name + "<input type=\"text\" class=\"cinput\" name=\"" + m_pseud_name
+ "\" SIZE=37 MAXLENGTH=255 VALUE=\""); + "\" size=\"37\" maxlength=\"255\" value=\"");
if (pseud_value!=null) if (m_pseud_value!=null)
out.write(pseud_value); out.write(m_pseud_value);
out.write("\"></SPAN>\n" + my_font + "<INPUT TYPE=\"CHECKBOX\" NAME=\"" + attach_name out.write("\" /></span>\n" + my_font + "<input type=\"checkbox\" name=\"" + m_attach_name
+ "\" VALUE=\"Y\""); + "\" value=\"Y\"");
if (attach_value) if (m_attach_value)
out.write(" CHECKED"); out.write(" checked=\"checked\"");
out.write("> Attach a file</FONT>\n</TD></TR>\n<TR>\n<TD ALIGN=LEFT CLASS=\"content\">\n" out.write(" /> Attach a file</font>\n</td></tr>\n<tr>\n<td align=\"left\" class=\"content\">\n"
+ my_font + "Message:</FONT>\n</TD>\n<TD ALIGN=RIGHT CLASS=\"content\">" + my_font + my_font + "Message:</font>\n</td>\n<td align=\"right\" class=\"content\">" + my_font
+ "\n<A HREF=\"" + html.getExternalStaticPath("html-reference.html") + "\n<a href=\"" + html.getExternalStaticPath("html-reference.html")
+ "\" TARGET=\"_blank\">HTML Guide</A>\n</FONT></TD>\n</TR>\n<TR>" + "\" target=\"_blank\">HTML Guide</a>\n</font></td>\n</tr>\n<tr>"
+ "<TD ALIGN=LEFT COLSPAN=2 CLASS=\"cinput\">\n<TEXTAREA NAME=\"" + text_name + "<td align=\"left\" colspan=\"2\" class=\"cinput\">\n<textarea name=\"" + m_text_name
+ "\" WRAP=SOFT ROWS=7 COLS=51>"); + "\" wrap=\"soft\" rows=\"7\" cols=\"51\">");
if (text_value!=null) if (m_text_value!=null)
out.write(text_value); out.write(m_text_value);
out.write("</TEXTAREA>\n</TD></TR>\n<TR><TD ALIGN=CENTER COLSPAN=2 CLASS=\"content\">\n"); out.write("</textarea>\n</td></tr>\n<tr><td align=\"center\" colspan=\"2\" class=\"content\">\n");
boolean first = true; boolean first = true;
it = buttons.iterator(); it = m_buttons.iterator();
while (it.hasNext()) while (it.hasNext())
{ // write out all the buttons { // write out all the buttons
String id = (String)(it.next()); String id = (String)(it.next());
@ -155,7 +155,7 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
} // end while } // end while
out.write("</TD></TR>\n</TABLE>\n</DIV></FORM>\n"); out.write("</td></tr>\n</table>\n</div></form>\n");
} // end try } // end try
catch (IOException e) catch (IOException e)
@ -165,16 +165,16 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
} // end catch } // end catch
// anything set by subtags must be cleared in doEndTag, not release // anything set by subtags must be cleared in doEndTag, not release
params.clear(); m_params.clear();
newtopic_name = null; m_newtopic_name = null;
newtopic_value = null; m_newtopic_value = null;
pseud_name = null; m_pseud_name = null;
pseud_value = null; m_pseud_value = null;
attach_name = null; m_attach_name = null;
attach_value = false; m_attach_value = false;
text_name = null; m_text_name = null;
text_value = null; m_text_value = null;
buttons.clear(); m_buttons.clear();
return EVAL_PAGE; return EVAL_PAGE;
} // end doEndTag } // end doEndTag
@ -184,9 +184,9 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("PostBoxTag.release(): entry"); logger.debug("PostBoxTag.release(): entry");
super.release(); super.release();
action = null; m_action = null;
type = "servlet"; m_type = "servlet";
real_type = -1; m_real_type = -1;
} // end release } // end release
@ -197,13 +197,14 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
public void setAction(String v) public void setAction(String v)
{ {
action = v; m_action = v;
} // end setAction } // end setAction
public void setType(String v) public void setType(String v)
{ {
type = v; m_type = v;
m_real_type = -1;
} // end setType } // end setType
@ -216,18 +217,18 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("PostBoxTag.addParam(\"" + name + "\",\"" + value + "\") entry"); logger.debug("PostBoxTag.addParam(\"" + name + "\",\"" + value + "\") entry");
params.put(name,value); m_params.put(name,value);
} // end addParam } // end addParam
final void setNewTopic(String param_name, String value) throws JspException final void setNewTopic(String param_name, String value) throws JspException
{ {
if (newtopic_name!=null) if (m_newtopic_name!=null)
throw new JspTagException("<post:newtopic/> may only appear once inside a <post:box/>!"); throw new JspTagException("<post:newtopic/> may only appear once inside a <post:box/>!");
if (param_name==null) if (param_name==null)
throw new JspTagException("<post:newtopic/> parameter name not specified!"); throw new JspTagException("<post:newtopic/> parameter name not specified!");
newtopic_name = param_name; m_newtopic_name = param_name;
newtopic_value = value; m_newtopic_value = value;
} // end setNewTopic } // end setNewTopic
@ -235,23 +236,23 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("PostBoxTag.setPseud(\"" + param_name + "\",\"" + value + "\") entry"); logger.debug("PostBoxTag.setPseud(\"" + param_name + "\",\"" + value + "\") entry");
if (pseud_name!=null) if (m_pseud_name!=null)
throw new JspTagException("<post:pseud/> may only appear once inside a <post:box/>!"); throw new JspTagException("<post:pseud/> may only appear once inside a <post:box/>!");
if (param_name==null) if (param_name==null)
throw new JspTagException("<post:pseud/> parameter name not specified!"); throw new JspTagException("<post:pseud/> parameter name not specified!");
pseud_name = param_name; m_pseud_name = param_name;
pseud_value = value; m_pseud_value = value;
} // end setPseud } // end setPseud
final void setAttach(String param_name, boolean value) throws JspException final void setAttach(String param_name, boolean value) throws JspException
{ {
if (attach_name!=null) if (m_attach_name!=null)
throw new JspTagException("<post:attach/> may only appear once inside a <post:box/>!"); throw new JspTagException("<post:attach/> may only appear once inside a <post:box/>!");
if (param_name==null) if (param_name==null)
throw new JspTagException("<post:attach/> parameter name not specified!"); throw new JspTagException("<post:attach/> parameter name not specified!");
attach_name = param_name; m_attach_name = param_name;
attach_value = value; m_attach_value = value;
} // end setAttach } // end setAttach
@ -259,18 +260,18 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("PostBoxTag.setText(\"" + param_name + "\",<value>) entry"); logger.debug("PostBoxTag.setText(\"" + param_name + "\",<value>) entry");
if (text_name!=null) if (m_text_name!=null)
throw new JspTagException("<post:text/> may only appear once inside a <post:box/>!"); throw new JspTagException("<post:text/> may only appear once inside a <post:box/>!");
if (param_name==null) if (param_name==null)
throw new JspTagException("<post:text/> parameter name not specified!"); throw new JspTagException("<post:text/> parameter name not specified!");
text_name = param_name; m_text_name = param_name;
text_value = value; m_text_value = value;
} // end setText } // end setText
final void addButton(String id) final void addButton(String id)
{ {
buttons.add(id); m_buttons.add(id);
} // end addButton } // end addButton