\n");
} // end renderHere
/*--------------------------------------------------------------------------------
* Operations usable only from derived classes
*--------------------------------------------------------------------------------
*/
protected CDFormField modifyField(String name)
{
return (CDFormField)(form_fields.get(name));
} // end modifyField
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public void setTitle(String title)
{
this.title = title;
} // end setTitle
public void setSubtitle(String subtitle)
{
this.subtitle = subtitle;
} // end setSubtitle
public void setErrorMessage(String message)
{
this.error_message = message;
} // end setErrorMessage
public void setInstructions(String instructions)
{
this.instructions = StringUtil.encodeHTML(instructions);
} // end setInstructions
public void setHiddenField(String name, String value)
{
if (value!=null)
hidden_fields.put(name,value);
} // end setHiddenField
public void removeHiddenField(String name)
{
hidden_fields.remove(name);
} // end removeHiddenField
public void addCommandButton(CDCommandButton button, int position)
{
command_buttons.put(button.getName(),button);
if (position<0)
command_order.addElement(button);
else
command_order.insertElementAt(button,position);
} // end addCommandButton
public void addCommandButton(CDCommandButton button)
{
addCommandButton(button,-1);
} // end addCommandButton
public void addFormField(CDFormField field, int position)
{
String name = field.getName();
if (name!=null)
form_fields.put(name,field);
if (position<0)
form_order.addElement(field);
else
form_order.insertElementAt(field,position);
} // end addFormField
public void addFormField(CDFormField field)
{
addFormField(field,-1);
} // end addFormField
public boolean isButtonClicked(ServletRequest request, String name)
{
CDCommandButton button = (CDCommandButton)(command_buttons.get(name));
if (button!=null)
return button.isClicked(request);
// now look in all form fields for the embedded button
Enumeration enum = form_order.elements();
while (enum.hasMoreElements())
{ // zap the state of the fields
CDFormField fld = (CDFormField)(enum.nextElement());
button = fld.findButton(name);
if (button!=null)
return button.isClicked(request);
} // end while
return false;
} // end isButtonClicked
public void loadValues(ServletRequest request)
{
// Look for the values of the hidden fields first.
Enumeration enum = hidden_fields.keys();
Hashtable updates = new Hashtable();
while (enum.hasMoreElements())
{ // get updates to the hidden field values
String name = (String)(enum.nextElement());
String value = request.getParameter(name);
if (value!=null)
updates.put(name,value);
} // end while
hidden_fields.putAll(updates); // make all the updates be recognized
// Now look for the values of the form fields.
enum = form_order.elements();
while (enum.hasMoreElements())
{ // look for the first field that's marked "required"
CDFormField fld = (CDFormField)(enum.nextElement());
String name = fld.getName();
if (name!=null) // load the parameter value
fld.setValue(request.getParameter(name));
} // end while
} // end loadValues
public void clearAllFields()
{
Enumeration enum = form_order.elements();
while (enum.hasMoreElements())
{ // zap the state of the fields
CDFormField fld = (CDFormField)(enum.nextElement());
fld.setValue(null);
} // end while
} // end clearAllFields
public String getFieldValue(String fieldname)
{
String value = (String)(hidden_fields.get(fieldname));
if (value!=null)
return value;
CDFormField fld = (CDFormField)(form_fields.get(fieldname));
if (fld!=null)
return fld.getValue();
else
return null;
} // end getFieldValue
public void setFieldValue(String fieldname, String value)
{
CDFormField fld = (CDFormField)(form_fields.get(fieldname));
if (fld!=null)
fld.setValue(value);
else if (value!=null)
setHiddenField(fieldname,value);
} // end setFieldValue
public boolean isFieldEnabled(String fieldname)
{
CDFormField fld = (CDFormField)(form_fields.get(fieldname));
if (fld!=null)
return fld.isEnabled();
else
return false;
} // end isFieldEnabled
public void setFieldEnabled(String fieldname, boolean flag)
{
CDFormField fld = (CDFormField)(form_fields.get(fieldname));
if (fld!=null)
fld.setEnabled(flag);
} // end setFieldEnabled
public void validate() throws ValidationException
{
// validate each field in isolation
Enumeration enum = form_order.elements();
while (enum.hasMoreElements())
{ // look for the first field that's marked "required"
CDFormField fld = (CDFormField)(enum.nextElement());
fld.validate();
} // end while
// now validate the form as a whole
validateWholeForm();
} // end validate
public Object clone()
{
return new ContentDialog(this);
} // end clone
} // end class Dialog