cleaned up the code in here in prep for doing more extensive work shortly
This commit is contained in:
parent
b4c7aa4c8b
commit
899863578d
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String action = null;
|
||||
private String type = "servlet";
|
||||
private int real_type = -1;
|
||||
private HashMap params = new HashMap();
|
||||
private String newtopic_name = null;
|
||||
private String newtopic_value = null;
|
||||
private String pseud_name = null;
|
||||
private String pseud_value = null;
|
||||
private String attach_name = null;
|
||||
private boolean attach_value = false;
|
||||
private String text_name = null;
|
||||
private String text_value = null;
|
||||
private ArrayList buttons = new ArrayList();
|
||||
private String m_action = null;
|
||||
private String m_type = "servlet";
|
||||
private int m_real_type = -1;
|
||||
private HashMap m_params = new HashMap();
|
||||
private String m_newtopic_name = null;
|
||||
private String m_newtopic_value = null;
|
||||
private String m_pseud_name = null;
|
||||
private String m_pseud_value = null;
|
||||
private String m_attach_name = null;
|
||||
private boolean m_attach_value = false;
|
||||
private String m_text_name = null;
|
||||
private String m_text_value = null;
|
||||
private ArrayList m_buttons = new ArrayList();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class BodyTagSupport
|
||||
|
@ -62,11 +62,11 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("PostBoxTag.doStartTag(): entry");
|
||||
if (action==null)
|
||||
if (m_action==null)
|
||||
throw new JspTagException("<post:box/> action= attribute not specified!");
|
||||
HTMLRendering html = (HTMLRendering)(getRequestInput().queryService(HTMLRendering.class));
|
||||
real_type = html.convertLinkType(type);
|
||||
if (real_type<0)
|
||||
m_real_type = html.convertLinkType(m_type);
|
||||
if (m_real_type<0)
|
||||
throw new JspTagException("<post:box/> type= attribute not a valid link type");
|
||||
return EVAL_BODY_BUFFERED;
|
||||
|
||||
|
@ -84,13 +84,13 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
{
|
||||
if (logger.isDebugEnabled())
|
||||
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!");
|
||||
if (attach_name==null)
|
||||
if (m_attach_name==null)
|
||||
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!");
|
||||
if (buttons.isEmpty())
|
||||
if (m_buttons.isEmpty())
|
||||
throw new JspTagException("<post:box/> tag has no <post:button/> tags inside it!");
|
||||
|
||||
HTMLRendering html = (HTMLRendering)(getRequestOutput().queryService(HTMLRendering.class));
|
||||
|
@ -98,52 +98,52 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
try
|
||||
{ // write out what we came here to accomplish
|
||||
JspWriter out = pageContext.getOut();
|
||||
out.write("<FORM METHOD=\"POST\" ACTION=\"" + html.formatURL(action,real_type)
|
||||
+ "\"><DIV CLASS=\"content\">\n");
|
||||
Iterator it = params.entrySet().iterator();
|
||||
out.write("<form method=\"POST\" action=\"" + html.formatURL(m_action,m_real_type)
|
||||
+ "\"><div class=\"content\">\n");
|
||||
Iterator it = m_params.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{ // write the hidden parameters
|
||||
Map.Entry ntry = (Map.Entry)(it.next());
|
||||
out.write("<INPUT TYPE=\"HIDDEN\" NAME=\"" + ntry.getKey() + "\" VALUE=\"" + ntry.getValue()
|
||||
+ "\">\n");
|
||||
out.write("<input type=\"hidden\" name=\"" + ntry.getKey() + "\" value=\"" + ntry.getValue()
|
||||
+ "\" />\n");
|
||||
|
||||
} // end while
|
||||
|
||||
String my_font = html.getFontTag(html.CONTENT_FOREGROUND,"content");
|
||||
out.write("<TABLE BORDER=0 CELLPADDING=0>\n");
|
||||
if (newtopic_name!=null)
|
||||
out.write("<table border=\"0\" cellpadding=\"0\">\n");
|
||||
if (m_newtopic_name!=null)
|
||||
{ // write the "new topic name" field
|
||||
out.write("<TR><TD ALIGN=LEFT COLSPAN=2 CLASS=\"content\">\n"
|
||||
+ my_font + "New topic name:</FONT><BR>\n<SPAN CLASS=\"cinput\">"
|
||||
+ "<INPUT TYPE=\"TEXT\" CLASS=\"cinput\" NAME=\"" + newtopic_name
|
||||
+ "\" SIZE=37 MAXLENGTH=128 VALUE=\"");
|
||||
if (newtopic_value!=null)
|
||||
out.write(newtopic_value);
|
||||
out.write("\"></SPAN>\n</TD></TR>\n");
|
||||
out.write("<tr><td align=\"left\" colspan=\"2\" class=\"content\">\n"
|
||||
+ my_font + "New topic name:</font><br />\n<span class=\"cinput\">"
|
||||
+ "<input type=\"text\" class=\"cinput\" name=\"" + m_newtopic_name
|
||||
+ "\" size=\"37\" maxlength=\"128\" VALUE=\"");
|
||||
if (m_newtopic_value!=null)
|
||||
out.write(m_newtopic_value);
|
||||
out.write("\" /></span>\n</td></tr>\n");
|
||||
|
||||
} // end if
|
||||
|
||||
out.write("<TR><TD ALIGN=LEFT COLSPAN=2 CLASS=\"content\">\n"
|
||||
+ my_font + "Your name/header:</FONT><BR>\n<SPAN CLASS=\"cinput\">"
|
||||
+ "<INPUT TYPE=\"TEXT\" CLASS=\"cinput\" NAME=\"" + pseud_name
|
||||
+ "\" SIZE=37 MAXLENGTH=255 VALUE=\"");
|
||||
if (pseud_value!=null)
|
||||
out.write(pseud_value);
|
||||
out.write("\"></SPAN>\n" + my_font + "<INPUT TYPE=\"CHECKBOX\" NAME=\"" + attach_name
|
||||
+ "\" VALUE=\"Y\"");
|
||||
if (attach_value)
|
||||
out.write(" CHECKED");
|
||||
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
|
||||
+ "\n<A HREF=\"" + html.getExternalStaticPath("html-reference.html")
|
||||
+ "\" TARGET=\"_blank\">HTML Guide</A>\n</FONT></TD>\n</TR>\n<TR>"
|
||||
+ "<TD ALIGN=LEFT COLSPAN=2 CLASS=\"cinput\">\n<TEXTAREA NAME=\"" + text_name
|
||||
+ "\" WRAP=SOFT ROWS=7 COLS=51>");
|
||||
if (text_value!=null)
|
||||
out.write(text_value);
|
||||
out.write("</TEXTAREA>\n</TD></TR>\n<TR><TD ALIGN=CENTER 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\">"
|
||||
+ "<input type=\"text\" class=\"cinput\" name=\"" + m_pseud_name
|
||||
+ "\" size=\"37\" maxlength=\"255\" value=\"");
|
||||
if (m_pseud_value!=null)
|
||||
out.write(m_pseud_value);
|
||||
out.write("\" /></span>\n" + my_font + "<input type=\"checkbox\" name=\"" + m_attach_name
|
||||
+ "\" value=\"Y\"");
|
||||
if (m_attach_value)
|
||||
out.write(" checked=\"checked\"");
|
||||
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
|
||||
+ "\n<a href=\"" + html.getExternalStaticPath("html-reference.html")
|
||||
+ "\" target=\"_blank\">HTML Guide</a>\n</font></td>\n</tr>\n<tr>"
|
||||
+ "<td align=\"left\" colspan=\"2\" class=\"cinput\">\n<textarea name=\"" + m_text_name
|
||||
+ "\" wrap=\"soft\" rows=\"7\" cols=\"51\">");
|
||||
if (m_text_value!=null)
|
||||
out.write(m_text_value);
|
||||
out.write("</textarea>\n</td></tr>\n<tr><td align=\"center\" colspan=\"2\" class=\"content\">\n");
|
||||
boolean first = true;
|
||||
it = buttons.iterator();
|
||||
it = m_buttons.iterator();
|
||||
while (it.hasNext())
|
||||
{ // write out all the buttons
|
||||
String id = (String)(it.next());
|
||||
|
@ -155,7 +155,7 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
|
||||
} // end while
|
||||
|
||||
out.write("</TD></TR>\n</TABLE>\n</DIV></FORM>\n");
|
||||
out.write("</td></tr>\n</table>\n</div></form>\n");
|
||||
|
||||
} // end try
|
||||
catch (IOException e)
|
||||
|
@ -165,16 +165,16 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
} // end catch
|
||||
|
||||
// anything set by subtags must be cleared in doEndTag, not release
|
||||
params.clear();
|
||||
newtopic_name = null;
|
||||
newtopic_value = null;
|
||||
pseud_name = null;
|
||||
pseud_value = null;
|
||||
attach_name = null;
|
||||
attach_value = false;
|
||||
text_name = null;
|
||||
text_value = null;
|
||||
buttons.clear();
|
||||
m_params.clear();
|
||||
m_newtopic_name = null;
|
||||
m_newtopic_value = null;
|
||||
m_pseud_name = null;
|
||||
m_pseud_value = null;
|
||||
m_attach_name = null;
|
||||
m_attach_value = false;
|
||||
m_text_name = null;
|
||||
m_text_value = null;
|
||||
m_buttons.clear();
|
||||
return EVAL_PAGE;
|
||||
|
||||
} // end doEndTag
|
||||
|
@ -184,9 +184,9 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
if (logger.isDebugEnabled())
|
||||
logger.debug("PostBoxTag.release(): entry");
|
||||
super.release();
|
||||
action = null;
|
||||
type = "servlet";
|
||||
real_type = -1;
|
||||
m_action = null;
|
||||
m_type = "servlet";
|
||||
m_real_type = -1;
|
||||
|
||||
} // end release
|
||||
|
||||
|
@ -197,13 +197,14 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
|
||||
public void setAction(String v)
|
||||
{
|
||||
action = v;
|
||||
m_action = v;
|
||||
|
||||
} // end setAction
|
||||
|
||||
public void setType(String v)
|
||||
{
|
||||
type = v;
|
||||
m_type = v;
|
||||
m_real_type = -1;
|
||||
|
||||
} // end setType
|
||||
|
||||
|
@ -216,18 +217,18 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("PostBoxTag.addParam(\"" + name + "\",\"" + value + "\") entry");
|
||||
params.put(name,value);
|
||||
m_params.put(name,value);
|
||||
|
||||
} // end addParam
|
||||
|
||||
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/>!");
|
||||
if (param_name==null)
|
||||
throw new JspTagException("<post:newtopic/> parameter name not specified!");
|
||||
newtopic_name = param_name;
|
||||
newtopic_value = value;
|
||||
m_newtopic_name = param_name;
|
||||
m_newtopic_value = value;
|
||||
|
||||
} // end setNewTopic
|
||||
|
||||
|
@ -235,23 +236,23 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
{
|
||||
if (logger.isDebugEnabled())
|
||||
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/>!");
|
||||
if (param_name==null)
|
||||
throw new JspTagException("<post:pseud/> parameter name not specified!");
|
||||
pseud_name = param_name;
|
||||
pseud_value = value;
|
||||
m_pseud_name = param_name;
|
||||
m_pseud_value = value;
|
||||
|
||||
} // end setPseud
|
||||
|
||||
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/>!");
|
||||
if (param_name==null)
|
||||
throw new JspTagException("<post:attach/> parameter name not specified!");
|
||||
attach_name = param_name;
|
||||
attach_value = value;
|
||||
m_attach_name = param_name;
|
||||
m_attach_value = value;
|
||||
|
||||
} // end setAttach
|
||||
|
||||
|
@ -259,18 +260,18 @@ public class PostBoxTag extends VeniceConfBodyTagSupport
|
|||
{
|
||||
if (logger.isDebugEnabled())
|
||||
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/>!");
|
||||
if (param_name==null)
|
||||
throw new JspTagException("<post:text/> parameter name not specified!");
|
||||
text_name = param_name;
|
||||
text_value = value;
|
||||
m_text_name = param_name;
|
||||
m_text_value = value;
|
||||
|
||||
} // end setText
|
||||
|
||||
final void addButton(String id)
|
||||
{
|
||||
buttons.add(id);
|
||||
m_buttons.add(id);
|
||||
|
||||
} // end addButton
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user