/*
* This software and supporting documentation were developed by
*
* Siemens Corporate Technology
* Competence Center Knowledge Management and Business Transformation
* D-81730 Munich, Germany
*
* Authors (representing a really great team ;-) )
* Stefan B. Augustin, Thorbj�rn Hansen, Manfred Langen
*
* This software is Open Source under GNU General Public License (GPL).
* Read the text of this license in LICENSE.TXT
* or look at www.opensource.org/licenses/
*
* Once more we emphasize, that:
* THIS SOFTWARE IS MADE AVAILABLE, AS IS, WITHOUT ANY WARRANTY
* REGARDING THE SOFTWARE, ITS PERFORMANCE OR
* FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR
* ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
* PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
*
*/
// PortalTemplate
// ************ package ******************************************************
package KFM.GUI.Templates;
// ************ imports ******************************************************
import KFM.GUI.Templates.*;
import KFM.GUI.Page;
import KFM.GUI.KFM_HttpServletRequest; // For `quoteFormField�.
import KFM.RegExp;
import KFM.Converter;
import KFM.log.*;
import com.oroinc.text.regex.MatchResult; // Get rid of this when it's included in RegExp.
import java.util.*;
import java.text.MessageFormat;
/** Extend KFM Template with Portal hacks.
*
* - Provide a very preliminary form of nested `KfmIf�s.
* You may in addition to `KfmIf� now use `KfmIf1�, `KfmIf2� and `KfmIf3�,
* and nest different numbers inside each other.
* You need not nest in increasing number, e.g. `KfmIf3� need not be inside a `KfmIf2�.
*
* - Escape correctly in forms by using `KFM_HttpServletRequest.quoteFormField� (q.v.).
*
* @see Template
* @see KfmTemplate
*
* Please see `Template� and `KfmTemplate�.
*/
public class PortalTemplate extends KfmTemplate
{
/** Contains the mapping of Forms to Name and Description of InputFields. */
private Hashtable mMapFormToNameDescription; // of aForm -> { aInputFieldName -> aDescription }
// ************************************************************
// Methods
// ************************************************************
/** Prepare a template without loading it.
*
* @param theNamePrefix E.g. "NewProposal" for a template file
* "NewProposal." + Language + templateExtension
* for example "NewProposal.German.kfmt.htm".
* @param aPage A page that knows how to generate its footer.
*/
public PortalTemplate(
/* TemplateObserver observer,*/
String aDir,
String aNamePrefix,
String aDefaultStylesheet,
Page aPage)
{
super(aDir, aNamePrefix, aDefaultStylesheet, aPage);
}
/** Prepare a template without loading it. Supports the new logging concept (KFMLog).
*
* @param theNamePrefix E.g. "NewProposal" for a template file
* "NewProposal." + Language + templateExtension
* for example "NewProposal.German.kfmt.htm".
* @param aPage A page that knows how to generate its footer.
*/
public PortalTemplate(
/* TemplateObserver observer,*/
String aDir,
String aNamePrefix,
String aDefaultStylesheet,
Page aPage,
KFMLog aLog)
{
super(aDir, aNamePrefix, aDefaultStylesheet, aPage, aLog);
}
public void init()
{
super.init();
mMapFormToNameDescription = new Hashtable();
}
/** Evaluate all occurences of a KfmIf{n}-command.
*
* Redefined to provide a very preliminary form of nested `KfmIf�s.
* You may in addition to `KfmIf� now use `KfmIf1�, `KfmIf2� and `KfmIf3�,
* and nest different numbers inside each other.
* You need not nest in increasing number, e.g. `KfmIf3� need not be inside a `KfmIf2�.
*
* For all else, please consult the documentation of `Template.replaceAllKfmIf�.
*/
public boolean replaceAllKfmIf (String label, boolean keep)
{
boolean replacementOccured = super.replaceAllKfmIf(label, keep);
for(int i = 1; i <= 3; ++i) {
lWhile: while(true) {
// Note: endtagM must be *after* starttagM.
MatchResult starttagM = RegExp.match(cmdPattern("KfmIf" + i, label), html);
if(starttagM == null) {
break lWhile;
}
int offset = starttagM.endOffset(0);
String html2 = html.substring(offset);
MatchResult endtagM = RegExp.match("\\</KfmIf" + i + "\\s*\\>", html2);
if(endtagM == null) {
break lWhile;
}
replacementOccured = true;
String replacement = (keep ? html.substring(starttagM.endOffset(0), endtagM.beginOffset(0) + offset) : "" );
if(domark) {
replacement = markTag(starttagM.group(0)) + replacement + markTag(endtagM.group(0));
}
if(debug) {
replacement = commentifyTag(starttagM.group(0)) + replacement + commentifyTag(endtagM.group(0));
}
html = html.substring(0, starttagM.beginOffset(0))
+ replacement
+ html2.substring(endtagM.endOffset(0));
}
}
return replacementOccured;
}
// ************************************************************
// * Replace methods.
// ************************************************************
/** Replace a KFM-command by a text input field for use in forms, i.e. an INPUT entity with TYPE='TEXT'.
*
* This method necessary because `KfmTemplate::replaceTextInputField� does not handle
* FONTs, nor the different behaviour of `SIZE� in Netscape and IE, nor quote the value
* correctly.
*
* If aValue is
*
* Fetches the parameters `Formname�, `Description�, `NSSize� and `IEWidth� from the template, e.g.
* <KFM titleField Formname="StartForm" Description="Enter your name" NSSize="50" IEWidth="43"></KFM>
*
* See also `createTextInputField�.
*
*@param aKfmLabel Case insensitive label of the KFM-command, e.g. `titleField�, `emailField�.
*@param aName Value of INPUT's parameter `NAME�, it is also the name of the HTTP parameter.
*@param aValue Value of INPUT's parameter `VALUE�, it is also a value for the HTTP parameter named `name�.
* Angle brackets, single quotes, double quotes and ampersands are quoted correctly.
*@param maxLength Value of INPUT's parameter `MAXLENGTH�, maximum number of chars the user may type.
*/
public void replaceAllKfmTextInputField (
String aKfmLabel,
String aName,
String aValue,
String aMaxLength)
{
// A loop like this will only work correctly when the HTML code is wellformed and follows our restrictions.
// All params must appear.
String tNSSize, tIEWidth, tRepl;
do {
tNSSize = getKfmParam(aKfmLabel, "NSSize");
tIEWidth = getKfmParam(aKfmLabel, "IEWidth");
String tDescriptionFormName = getKfmParam(aKfmLabel, "Formname");
String tDescription = getKfmParam(aKfmLabel, "Description");
tRepl = "<A NAME='" + aKfmLabel + "'>"
+ createTextInputField(aKfmLabel, aName, aValue,
tDescriptionFormName, tDescription, tNSSize, tIEWidth, aMaxLength)
+ "</A>";
} while(replaceKfm(aKfmLabel, tRepl));
}
/** Call `replaceAllKfmTextInputField� with the user's email as default.
*
* Currently not working, see `cInputTextMailTempl� below.
*/
public void replaceAllKfmTextInputEmailField (
String aKfmLabel,
String aName,
String aValue,
String aMaxLength)
{
replaceAllKfmTextInputField(aKfmLabel, aName, aValue, aMaxLength);
}
/** Replace a KFM-command by a text area field for use in forms, i.e. an TEXTAREA entity.
*
* This method necessary because `KfmTemplate::replaceAllTextAreaField� does not handle
* FONTs, nor the different behaviour of `SIZE� in Netscape and IE, nor quote the value
* correctly.
*
* Fetches the parameters `Rows�, `NSSize� and `IEWidth� from the template, e.g.
* <KFM InputSubject Rows="3" NSSize="50" IEWidth="43"></KFM>
*
* See `createTextAreaField�.
*
*@param aKfmLabel Case insensitive label of the KFM-command, e.g. `titleField�, `emailField�.
*@param aName Value of INPUTs parameter `NAME�, it is also the name of the HTTP parameter.
*@param aContent Value of TEXTAREAs content, it is also a value for the HTTP parameter named `name�.
* Angle brackets, single quotes, double quotes and ampersands are quoted correctly.
* (Actually, we do not have to quote the single and double quotes,
* but we do for consistency with `createTextInputField�.)
* Note: Analogous to the parameter `VALUE� of the entity INPUT with TYPE='TEXT'.
*/
public void replaceAllKfmTextAreaField (
String aKfmLabel,
String aName,
String aContent)
{
// A loop like this will only work correctly when the HTML code is wellformed and follows our restrictions.
// All params must appear.
String tRows, tNSSize, tIEWidth, tRepl;
do {
tRows = getKfmParam(aKfmLabel, "Rows");
// `NSSize� used to be `Cols�, we now have consistency with text input fields.
tNSSize = getKfmParam(aKfmLabel, "NSSize");
tIEWidth = getKfmParam(aKfmLabel, "IEWidth");
tRepl = "<A NAME='" + aKfmLabel + "'>"
+ createTextAreaField(aKfmLabel, aName, aContent, tRows, tNSSize, tIEWidth)
+ "</A>";
} while(replaceKfm(aKfmLabel, tRepl));
}
/** Replace a KFM-command by a radio button for use in forms, i.e. an INPUT entity with TYPE='RADIO'.
*
* This method necessary because `KfmTemplate::replaceAllKfmRadioButton� does not exist.
*
* Note that this method is necessary when you want to put each radiobutton into the template
* by hand. When you want to get all radiobuttons from Java/DB, use `FormContentCreator�.
*
* Fetches the parameters `BgColor�, `Value� from the template, e.g.
* KFM InputQuality Value=1 BgColor='#def'
*
* See `createRadioButton�.
*
*@param aKfmLabel Case insensitive label of the KFM-command, e.g. `titleField�, `emailField�.
*@param aName Value of INPUTs parameter `NAME�, it is also the name of the HTTP parameter.
*@param aSelectdValue
* Note that this is the one selected value which get `CHECKED�, not the value
* that one radio button. The usual rules for `Value� do apply anyway, i.e.:
* Value of INPUT's parameter `VALUE�, it is also a value for the HTTP parameter named `name�.
* Angle brackets, single quotes, double quotes and ampersands are quoted correctly.
*/
public void replaceAllKfmRadioButton (
String aKfmLabel,
String aName,
String aSelectedValue)
{
// A loop like this will only work correctly when the HTML code is wellformed and follows our restrictions.
// All params must appear.
String tBgColor, tValue, tRepl, tClass;
do {
tValue = getKfmParam(aKfmLabel, "Value");
tClass = getKfmParam(aKfmLabel, "Class");
if(tClass.equals("")) {
tBgColor = getKfmParam(aKfmLabel, "BgColor");
// We can't put a name around all radio buttons, as there are several with the same name.
tRepl = /*"<A NAME='" + aKfmLabel + "'>"
+ */ createRadioButton(aKfmLabel, aName, tValue, tBgColor, tValue.equals(aSelectedValue))
/*+ "</A>"*/;
} else {
tRepl = /*"<A NAME='" + aKfmLabel + "'>"
+ */ createRadioButton2(aKfmLabel, aName, tValue, tClass, tValue.equals(aSelectedValue));
}
} while(replaceKfm(aKfmLabel, tRepl));
}
/** Replace a KFM-command by a checkbutton (checkbox) for use in forms, i.e. an INPUT entity with TYPE='CHECKBOX'.
*
* This method necessary because `KfmTemplate::replaceAllKfmCheckButton� does not exist.
*
* Analogous to `replaceAllKfmRadioButton�.
*/
public void replaceAllKfmCheckButton (
String aKfmLabel,
String aName,
String aSelectedValue)
{
// A loop like this will only work correctly when the HTML code is wellformed and follows our restrictions.
// All params must appear.
String tBgColor, tValue, tRepl, tClass;
do {
tValue = getKfmParam(aKfmLabel, "Value");
tClass = getKfmParam(aKfmLabel, "Class");
if(tClass.equals("")) {
tBgColor = getKfmParam(aKfmLabel, "BgColor");
// We can't put a name around all check buttons, as there are several with the same name.
tRepl = /*"<A NAME='" + aKfmLabel + "'>"
+ */ createCheckButton(aKfmLabel, aName, tValue, tBgColor, tValue.equals(aSelectedValue))
/*+ "</A>"*/;
} else {
tRepl = /*"<A NAME='" + aKfmLabel + "'>"
+ */ createCheckButton2(aKfmLabel, aName, tValue, tClass, tValue.equals(aSelectedValue));
}
} while(replaceKfm(aKfmLabel, tRepl));
}
/** called by execute */
private void replaceKfmDescriptionResetScript()
{
StringBuffer tCodeSB = new StringBuffer();
tCodeSB.append(
"<script>\n");
if(mMapFormToNameDescription.size() == 0) {
// no code required
} else {
tCodeSB.append(
"function focusTextField(aInput, aDescription) {\n"
+ " if(aInput.value == aDescription) {\n"
+ " aInput.value = \"\";\n"
+ " }\n"
+ " aInput.select();\n"
+ "}\n"
+ "\n"
+ "var mMapFormToObject = new Array();\n");
Iterator tFormIter = mMapFormToNameDescription.keySet().iterator();
while(tFormIter.hasNext()) {
String tFormname = (String) tFormIter.next();
tCodeSB.append("mMapNameToDescription = new Array();\n");
Properties tMapNameToDescription =
(Properties) mMapFormToNameDescription.get(tFormname);
Enumeration tNameEnum = tMapNameToDescription.propertyNames();
while(tNameEnum.hasMoreElements()) {
String tInputFieldName = (String) tNameEnum.nextElement();
String tDescription = tMapNameToDescription.getProperty(tInputFieldName);
tCodeSB.append("mMapNameToDescription[\"" + tInputFieldName + "\"] = " +
"\"" + Converter.quoteHtml(tDescription) + "\";\n");
}
tCodeSB.append("mMapFormToObject[\"" + tFormname + "\"] = mMapNameToDescription;\n");
}
}
tCodeSB.append(
"function resetDescriptionsAndSubmit(aSubmitForm) {\n");
if(mMapFormToNameDescription.size() > 0) {
tCodeSB.append(
" for(var tFormname in mMapFormToObject) {\n"
+ " for(var tInputFieldName in mMapFormToObject[tFormname]) {\n"
+ " tDescription = mMapFormToObject[tFormname][tInputFieldName];\n"
+ " if(document.forms[tFormname].elements[tInputFieldName].value == tDescription) {\n"
+ " document.forms[tFormname].elements[tInputFieldName].value = \"\";\n"
+ " }\n"
+ " }\n"
+ " }\n");
}
tCodeSB.append(
" return true; // Tell FORM's onSubmit to submit.\n"
+ "}\n");
tCodeSB.append(
"function insertDescriptionsOnLoad() {\n");
if(mMapFormToNameDescription.size() > 0) {
tCodeSB.append(
" for(var tFormname in mMapFormToObject) {\n"
+ " for(var tInputFieldName in mMapFormToObject[tFormname]) {\n"
+ " tDescription = mMapFormToObject[tFormname][tInputFieldName];\n"
+ " if(document.forms[tFormname].elements[tInputFieldName].value == \"\") {\n"
+ " document.forms[tFormname].elements[tInputFieldName].value = tDescription;\n"
+ " }\n"
+ " }\n"
+ " }\n");
}
tCodeSB.append(
"}\n");
tCodeSB.append("</script>\n");
replaceKfm("DescriptionResetCode", tCodeSB.toString());
}
// ************************************************************
// * Create methods: The variables.
// ************************************************************
// Should get a mutator method later.
// In that case, `cInputTextTempl� and `cTextAreaTempl� need to treat it as a parameter.
private static final String cFont = "Arial,Helvetica,Verdana";
/** Template (for `MessageFormat.format�) to construct a TEXT INPUT FIELD,
* Used by `createTextInputField�.
*
* <P>This hack works for Nav 4.5 and IE 5.0. Please see the background information
* on `SIZE� in `INPUT TYPE=TEXT SIZE� in the documentation of `createTextInputField�.</P>
*
* <P>Detail documentation:</P>
* <OL>
* <LI>IE 5.0 honors `font-family� and `width�. `width� must be *after* `font-family�.</LI>
* <LI>Nav 4.5 honors `FONT� and `SIZE�.
* If we leave out the enclosing `FONT�, then `SIZE� is calculated relative to the
* enclosing font, not relative to the font in `font-family�.</LI>
* </OL>
*
* <P>Note that the single quote is an escape character for `MessageFormat.format�
* and must be used twice to get a single quote.</P>
*/
private static final String cInputTextTempl =
"<FONT STYLE=''font-family: " + cFont + "''>"
+ "<INPUT TYPE=''TEXT'' NAME=''{0}'' SIZE=''{2}'' MAXLENGTH=''{4}'' "
+ "STYLE=''font-family: " + cFont + "; width: {3}em;'' "
+ "VALUE=''{1}''>"
+ "</FONT>";
private static final String cInputTextTemplNoMaxLength =
"<FONT STYLE=''font-family: " + cFont + "''>"
+ "<INPUT TYPE=''TEXT'' NAME=''{0}'' SIZE=''{2}'' "
+ "STYLE=''font-family: " + cFont + "; width: {3}em;'' "
+ "VALUE=''{1}''>"
+ "</FONT>";
private static final String cInputTextDescriptionTempl =
"<FONT STYLE=''font-family: " + cFont + "''>"
+ "<INPUT TYPE=''TEXT'' NAME=''{0}'' SIZE=''{2}'' MAXLENGTH=''{4}'' "
+ "STYLE=''font-family: " + cFont + "; width: {3}em;'' "
+ "VALUE=''{6}'' onClick=''javascript: focusTextField(this,\"{6}\");''>"
+ "</FONT>";
private static final String cInputTextDescriptionTemplNoMaxLength =
"<FONT STYLE=''font-family: " + cFont + "''>"
+ "<INPUT TYPE=''TEXT'' NAME=''{0}'' SIZE=''{2}'' "
+ "STYLE=''font-family: " + cFont + "; width: {3}em;'' "
+ "VALUE=''{6}'' onClick=''javascript: focusTextField(this,\"{6}\");''>"
+ "</FONT>";
// Template (for `MessageFormat.format�) to construct a TEXT INPUT FIELD.
// Used by `createTextInputField�.
// See `cInputTextTempl� for more info.
private static final String cTextAreaTempl =
"<FONT STYLE=''font-family: Arial,Helvetica,Verdana''>"
+ "<TEXTAREA NAME=''{0}'' ROWS=''{2}'' COLS=''{3}'' WRAP=''physical'' "
+ "STYLE=''font-family: " + cFont + "; width: {4}em;'' "
+ ">{1}</TEXTAREA>"
+ "</FONT>";
// Template (for `MessageFormat.format�) to construct a RADIO INPUT FIELD.
//
// @param {2} Color of the background, e.g. `#def�. See explanation of `aBackgroundColor�
// in `createRadioButton�.
// @param {3} either "" or "CHECKED".
private static final String cInputRadioTempl =
"<INPUT TYPE=''RADIO'' NAME=''{0}'' VALUE=''{1}'' "
+ "STYLE=''background: {2}'' {3}>";
private static final String cInputRadioTempl2 =
"<INPUT TYPE=''RADIO'' NAME=''{0}'' VALUE=''{1}'' "
+ "CLASS=''{2}'' {3}>";
// Template (for `MessageFormat.format�) to construct a CHECKBOX INPUT FIELD.
//
// Analogous to Radio stuff.
//
// Yes, a checkbox really has a background color, on Netscape it's a small strip of approx. one
// pixel to the left and below. On IE it's the entire height and width of the box that contains
// the checkbox.
private static final String cInputCheckTempl =
"<INPUT TYPE=''CHECKBOX'' NAME=''{0}'' VALUE=''{1}'' "
+ "STYLE=''background: {2}'' {3}>";
private static final String cInputCheckTempl2 =
"<INPUT TYPE=''CHECKBOX'' NAME=''{0}'' VALUE=''{1}'' "
+ "CLASS=''{2}'' {3}>";
// As cInputTextTempl, but use JavaScript to insert user's mail address.
/*
//xxx Nice try, but to get the user's email address,
//xxx we need to sign a certificate or whatever,
//xxx and I don't know how to do that.
// Used below.
private final String cInputTextTempl2 =
"<FONT STYLE=''font-family: Arial,Helvetica,Verdana''>"
+ "<INPUT TYPE=''TEXT'' NAME=''{0}'' VALUE=''"
// Note that the following line is one Java string.
// Between the HTML double quotes, insert JavaScript *code*
// to insert the user's email address. Currently just insert
// the value of the JavaScript variable `tEmail�, which
// has presumably been set somewhere in the HTML header.
+ "\" + tEmail + \""
+ "'' "
+ "STYLE=''font-family: Arial,Helvetica,Verdana; width: {3}em;'' "
+ "SIZE={2}>"
+ "</FONT>";
// Choose `cInputTextTempl2� when JavaScript is enabled, else `cInputTextTempl�.
private final String cInputTextMailTempl =
"<SCRIPT LANGUAGE='JavaScript'>\n"
+ "<!-- \n"
+ "document.write(\"" + cInputTextTempl2 + "\");\n"
+ "// -->\n"
+ "</SCRIPT>\n<NOSCRIPT>" + cInputTextTempl + "</NOSCRIPT>\n";
*/
// ************************************************************
// * Create methods: The methods.
// ************************************************************
/** Build a text input field for use in forms, i.e. an INPUT entity with TYPE='TEXT'.
*
* A text input field has one line and no scroll bars. See also `createTextAreaField�.
*
* This method necessary because `KfmTemplate::createTextInputField� does not handle
* FONTs, nor the different behaviour of `SIZE� in Netscape and IE, nor quote the value
* correctly.
*
* The officially correct way to specify the width of the text field in HTML 3.2,
* which is via INPUT's attribute `SIZE� (in number of characters), yields very different widths
* in Netscape 4.* and IE 5.0. There is also the CSS style parameter `width� (e.g. in ems), which
* Netscape 4.* ignores and IE 5.0 honors.
*
* Thus, as a workaround, we set INPUT's attribute `SIZE� for Netscape 4.* and INPUT's CSS style
* parameter `width� for IE 5.0. E.g. in the font Arial, Netscape's `SIZE=50� and IE's
* `width:43em� seem to be equivalent.
*
*@param aKfmLabel Case insensitive label of the KFM-command, e.g. `titleField�, `emailField�.
*@param aName Value of INPUT's parameter `NAME�, it is also the name of the HTTP parameter.
*@param aValue Value of INPUT's parameter `VALUE�, it is also a value for the HTTP parameter named `name�.
* Angle brackets, single quotes, double quotes and ampersands are quoted correctly.
*@param aDescription A description of what kind of information the user should enter.
*@param aDescriptionFormName The name of the Form which contains this InputField.
*@param aNSSize Value of INPUT's parameter `SIZE�,
* width of the text field in number of characters,
* which seems to be honored by Netscape 4.*.
*@param aIEWidth Value of INPUT's CSS style parameter `width�,
* width of the text field in ems (characters),
* which seems to be honored by IE 5.0.
*@param aMaxLength Value of INPUT's parameter `MAXLENGTH�, maximum number of chars the user may type.
* Since 2001-04-20, it may be `null� for no `MAXLENGTH�.
*@return HTML code for INPUT entity.
*/
public String createTextInputField (
String aKfmLabel, // Currently not used
String aName,
String aValue,
String aDescriptionFormName,
String aDescription,
String aNSSize, // for Netscape
String aIEWidth, // for IE
String aMaxLength)
{
String tTempl = null;
if(aDescriptionFormName == "" || aDescription == "" || aValue.length() > 0) {
tTempl = (aMaxLength == null)
? cInputTextTemplNoMaxLength
: cInputTextTempl;
} else {
addFormToNameDescription(aDescriptionFormName, aName, aDescription);
tTempl = (aMaxLength == null)
? cInputTextDescriptionTemplNoMaxLength
: cInputTextDescriptionTempl;
}
return MessageFormat.format(tTempl, new Object[] {
aName, Converter.quoteHtml(aValue),
aNSSize, aIEWidth, aMaxLength, aDescriptionFormName,
Converter.quoteHtml(aDescription)});
}
private void addFormToNameDescription(String aFormName, String aName, String aDescription)
{
Properties tProps = (Properties) mMapFormToNameDescription.get(aFormName);
if(tProps == null) {
tProps = new Properties();
mMapFormToNameDescription.put(aFormName, tProps);
}
tProps.put(aName, aDescription);
}
/** Build a text area field for use in forms, i.e. an TEXTAREA entity.
*
* This method necessary because `KfmTemplate::createTextAreaField� does not handle
* FONTs, nor the different behaviour of `COLS� in Netscape and IE, nor quote the value
* correctly.
*
* For details on handling of `COLS�, consult `createTextInputField�'s handling of `SIZE�.
*
* A text area field has several lines and scroll bars.
*
*@param aKfmLabel Case insensitive label of the KFM-command, e.g. `titleField�, `emailField�.
*@param aName Value of TEXTAREAs parameter `NAME�, it is also the name of the HTTP parameter.
*@param aContent Value of TEXTAREAs content, it is also a value for the HTTP parameter named `name�.
* Angle brackets, single quotes, double quotes and ampersands are quoted correctly.
* (Actually, we do not have to quote the single and double quotes,
* but we do for consistency with `createTextInputField�.)
* Note: Analogous to the parameter `VALUE� of the entity INPUT with TYPE='TEXT'.
*@param aRows Value of TEXTAREAs parameter `ROWS�,
* number of (character) rows of text area field.
*@param aNSSize Value of TEXTAREAs parameter `COLS�,
* width of the textarea field in number of characters,
* which seems to be honored by Netscape 4.*.
* Called `NSSize� for consistency with text fields.
*@param aIEWidth Value of INPUT's CSS style parameter `width�,
* width of the text field in ems (characters),
* which seems to be honored by IE 5.0.
*@return HTML code for TEXTAREA entity.
*/
public String createTextAreaField (
String aKfmLabel, // Currently not used
String aName,
String aContent,
String aRows,
String aNSSize, // for Netscape
String aIEWidth) // for IE
{
return MessageFormat.format(cTextAreaTempl, new Object[] {
aName, Converter.quoteHtml(aContent),
aRows, aNSSize, aIEWidth});
}
/** Build a radio button.
*
*@param aName Value of INPUTs parameter `NAME�, it is also the name of the HTTP parameter.
*@param aValue Value of INPUTs parameter `VALUE�, it is also a value for the HTTP parameter named `name�.
* Note that this is the value that this radio button has, not the selected value.
*@param aBackgroundColor
* As a radio button is a circle, the color of the background shows around the circle.
* (We are not talking about the color inside the circle, which is white, as we want it.)
* IE 5.0 correctly chooses the current background color, but Netscape 4.*
* does not. But NS 4.* accepts the CSS style parameter `background� for that,
* but for reasons of terminal stupidity at NS, only in the form `#000� to `#fff�.
*@param aSelected Boolean.
*@return HTML code for INPUT entity.
*/
public String createRadioButton (
String aKfmLabel, // Currently not used
String aName,
String aValue,
String aBackgroundColor,
boolean aSelected)
{
return MessageFormat.format(cInputRadioTempl, new Object[] {
aName, Converter.quoteHtml(aValue),
aBackgroundColor, (aSelected ? " CHECKED" : "")});
}
public String createRadioButton2 (
String aKfmLabel, // Currently not used
String aName,
String aValue,
String aClass,
boolean aSelected)
{
return MessageFormat.format(cInputRadioTempl2, new Object[] {
aName, Converter.quoteHtml(aValue),
aClass, (aSelected ? " CHECKED" : "")});
}
/** Build a checkbox button.
*
* Analogous to `createRadioButton�.
*/
public String createCheckButton (
String aKfmLabel, // Currently not used
String aName,
String aValue,
String aBackgroundColor,
boolean aSelected)
{
return MessageFormat.format(cInputCheckTempl, new Object[] {
aName, Converter.quoteHtml(aValue),
aBackgroundColor, (aSelected ? " CHECKED" : "")});
}
public String createCheckButton2 (
String aKfmLabel, // Currently not used
String aName,
String aValue,
String aClass,
boolean aSelected)
{
return MessageFormat.format(cInputCheckTempl, new Object[] {
aName, Converter.quoteHtml(aValue),
aClass, (aSelected ? " CHECKED" : "")});
}
// ************************************************************
// * End create methods.
// ************************************************************
/** Does all replacements.
*
* This function is intended to be called by all subclasses.
*
* Implements:
*/
public void execute ()
{
super.execute();
replaceKfmDescriptionResetScript();
}
}