Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba
Class HtmlChoiceWriter

    java.lang.Object
      org.makumba.HtmlUtils
          org.makumba.HtmlChoiceWriter

    public class HtmlChoiceWriter

extends HtmlUtils

HtmlChoiceWriter creates HTML statements for printing choice inputs. It's capable of creating dropdown and list selects, and radio buttons and checkboxes.

Note: this class is still work in progress, and its API is not to be considered 100% stable yet. Especially the static methods may change or be removed.

FIXME : documentation needs improvement.

Since:
  makumba-0.5.9.15
Author:
  Frederik Habils

Field Summary
`static int` | `NO_CONV` No conversion.
`static int` | `TXT2HTML` Convert text encoding to legal HTML encoding.

Fields inherited from class org.makumba.HtmlUtils
`specials, tagExamples`

Constructor Summary
`HtmlChoiceWriter()` Default constructor.
`HtmlChoiceWriter(String name)` Constructor, sets the name of the choice control.

Method Summary
`String` | `getCheckboxSelect()` Creates HTML statement for a select-one control.
`String` | `getRadioSelect()` Creates HTML statement for a radio input control.
`String` | `getSelect()` Creates HTML statement for a select control.
`String` | `getSelectMultiple()` Creates HTML statement for a select-multiple HTML control.
`String` | `getSelectOne()` Creates HTML statement for a select-one control.
`static String` | `makeHtmlCheckboxSelect(String name, String[] values, String[] labels, String[] selectedValues, String checkboxLabelSeparator, String[] optionSeparator, String literalHtml, int convert2Html)` Returns a checkbox-input statement in HTML.
`static String` | `makeHtmlCheckboxSelect(String name, String[] values, String[] labels, String[] selectedValues, String checkboxLabelSeparator, String optionSeparator, String literalHtml, int convert2Html)` Returns a checkbox-input statement in HTML; shorthand for only one optionSeparator.
`static String` | `makeHtmlRadioSelect(String name, String[] values, String[] labels, String selectedValue, String checkboxLabelSeparator, String[] optionSeparator, String literalHtml, int convert2Html)` Returns a radio-input statement in HTML.
`static String` | `makeHtmlRadioSelect(String name, String[] values, String[] labels, String selectedValue, String checkboxLabelSeparator, String optionSeparator, String literalHtml, int convert2Html)` Returns a radio-input statement in HTML; shorthand for only one optionSeparator.
`static String` | `makeHtmlSelectMultiple(String name, String[] values, String[] labels, String[] selectedValues, int size, String literalHtml, int convert2Html)` Returns a select multiple statement in HTML.
`static String` | `makeHtmlSelectOne(String name, List<String> values, List<String> labels, String selectedValue, String literalHtml, int convert2Html)` Returns a select statement in HTML.
`static String` | `makeHtmlSelectOne(String name, String[] values, String[] labels, String selectedValue, String literalHtml, int convert2Html)` Returns a select statement in HTML.
`void` | `setConvert2Html(int n)` Configures the encoding transformation to be applied to labels and values of the choice control.
`void` | `setDeprecatedValues(List<String> deprecated)` Sets the deprecated values (zero or more).
`void` | `setDeprecatedValues(String[] deprecated)` Sets the deprecated values (zero or more).
`void` | `setFormIdentifier(Object formCount)`
`void` | `setLabels(Iterator<String> labels)` Sets the labels of each of the options for the choice control.
`void` | `setLabels(List<String> labels)` Sets the labels of each of the options for the choice control.
`void` | `setLabels(String[] labels)` Sets the labels of each of the options for the choice control.
`void` | `setLiteralHtml(String html)` Sets a literal html text to be included in the choice control.
`void` | `setMultiple(boolean yn)` Sets whether the choice control accepts 'multiple' selections or not.
`void` | `setMultiple(String mult)` Sets whether the choice control accepts 'multiple' selections or not.
`void` | `setName(String name)` Sets the name of the choice control.
`void` | `setOptionSeparator(List<String> s)` Sets the separator between different options.
`void` | `setOptionSeparator(String s)` Sets the separator between different options.
`void` | `setOptionSeparator(String[] s)` Sets the separator between different options.
`void` | `setSelectedValues(List<String> selected)` Sets the selected values (zero or more).
`void` | `setSelectedValues(String selected)` Sets the selected value, in case there is only one.
`void` | `setSelectedValues(String[] selected)` Sets the selected values (zero or more).
`void` | `setSize(int n)` Sets the size of the choice control.
`void` | `setTickLabelSeparator(String s)` Sets the separator between the 'tickbox' and the label.
`void` | `setValues(Iterator<String> values)` Sets the values of each of the options for the choice control.
`void` | `setValues(List<String> values)` Sets the values of each of the options for the choice control.
`void` | `setValues(String[] values)` Sets the values of each of the options for the choice control.

Methods inherited from class org.makumba.HtmlUtils
`detectHtml, maxLineLength, string2html, stripHTMLTags, text2html`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NO_CONV

    public static int NO_CONV

  No conversion.

### TXT2HTML

    public static int TXT2HTML

  Convert text encoding to legal HTML encoding.

Constructor Detail

### HtmlChoiceWriter

    public HtmlChoiceWriter()

  Default constructor.

### HtmlChoiceWriter

    public HtmlChoiceWriter(String name)

  Constructor, sets the name of the choice control.

Method Detail

### setName

    public void setName(String name)

  Sets the name of the choice control.

### setValues

    public void setValues(List<String> values)

  Sets the values of each of the options for the choice control. Labels and Values must be in the same order.

### setValues

    public void setValues(String[] values)

  Sets the values of each of the options for the choice control. Labels and Values must be in the same order.

### setValues

    public void setValues(Iterator<String> values)

  Sets the values of each of the options for the choice control. Labels and Values must be in the same order.

### setLabels

    public void setLabels(List<String> labels)

  Sets the labels of each of the options for the choice control. Labels and Values must be in the same order.

### setLabels

    public void setLabels(String[] labels)

  Sets the labels of each of the options for the choice control. Labels and Values must be in the same order.

### setLabels

    public void setLabels(Iterator<String> labels)

  Sets the labels of each of the options for the choice control. Labels and Values must be in the same order.

### setSelectedValues

    public void setSelectedValues(String selected)

  Sets the selected value, in case there is only one. Most suitable if this is a select-one choice control.

### setSelectedValues

    public void setSelectedValues(String[] selected)

  Sets the selected values (zero or more). The input can be in any order, not related to the setValues and setLabels methods. The input array is changed by this method (sorted).

### setSelectedValues

    public void setSelectedValues(List<String> selected)

  Sets the selected values (zero or more). The input can be in any order, not related to the setValues and setLabels methods. The input List is not changed by this method.

### setDeprecatedValues

    public void setDeprecatedValues(String[] deprecated)

  Sets the deprecated values (zero or more). The input can be in any order, not related to the setValues and setLabels methods. The input array is changed by this method (sorted).

### setDeprecatedValues

    public void setDeprecatedValues(List<String> deprecated)

  Sets the deprecated values (zero or more). The input can be in any order, not related to the setValues and setLabels methods. The input List is not changed by this method.

### setMultiple

    public void setMultiple(boolean yn)

  Sets whether the choice control accepts 'multiple' selections or not.

### setMultiple

    public void setMultiple(String mult)

  Sets whether the choice control accepts 'multiple' selections or not. Any string that contains 'multiple' will be regarded as 'true'.

### setSize

    public void setSize(int n)

  Sets the size of the choice control. Relevant for 'select' controls only, not for tickbox controls.

### setConvert2Html

    public void setConvert2Html(int n)

  Configures the encoding transformation to be applied to labels and values of the choice control. Use the public constants of the class as inputs.

### setLiteralHtml

    public void setLiteralHtml(String html)

  Sets a literal html text to be included in the choice control. E.g. <select LITERALHTML>

### setTickLabelSeparator

    public void setTickLabelSeparator(String s)

  Sets the separator between the 'tickbox' and the label. Default is a space.

### setOptionSeparator

    public void setOptionSeparator(String s)

  Sets the separator between different options. Only relevant for tickbox type of choice controls. Default is a space.

### setOptionSeparator

    public void setOptionSeparator(String[] s)

  Sets the separator between different options. Only relevant for tickbox type of choice controls. Default is a space. When there is more than one separator, the writer will cycle through all separators, when writing each of the options.

### setOptionSeparator

    public void setOptionSeparator(List<String> s)

  Sets the separator between different options. Only relevant for tickbox type of choice controls. Default is a space. When there is more than one separator, the writer will cycle through all separators, when writing each of the options.

### getSelect

    public String getSelect()

  Creates HTML statement for a select control. Will use the 'multiple' setting to choose a select-one or select-multiple output. If labels and values iterator has different sizes, the smaller applies.

### getSelectOne

    public String getSelectOne()

  Creates HTML statement for a select-one control. If labels and values iterator has different sizes, the smaller applies. If selectedValues has more than 1 element, then only the first is considered as selected value.

### getSelectMultiple

    public String getSelectMultiple()

  Creates HTML statement for a select-multiple HTML control. If labels and values iterator has different sizes, the smaller applies.

### getRadioSelect

    public String getRadioSelect()

  Creates HTML statement for a radio input control. If labels and values iterator has different sizes, the smaller applies. If selectedValues has more than 1 element, then all these will be set as CHECKED (which is incorrect HTML).

### getCheckboxSelect

    public String getCheckboxSelect()

  Creates HTML statement for a select-one control. If labels and values iterator has different sizes, the smaller applies.

### makeHtmlSelectOne

    public static String makeHtmlSelectOne(String name,
                                           List<String> values,
                                           List<String> labels,
                                           String selectedValue,
                                           String literalHtml,
                                           int convert2Html)

  Returns a select statement in HTML.

  Parameters:
    `name` - The name of the parameter that is set by this SELECT
    `values` - List of the values (String) of the options, same order as 'labels'
    `labels` - List of the labels (String) of the options, same order as 'values'
    `selectedValue` - The selected value, if any (String, or null)
    `literalHtml` - Extra HTML to be added literally to the SELECT tag.
    `convert2Html` - Configuration whether `values` and `labels` must be converted ('escaped') to HTML during the writing out. Default is "NO_CONV". Any input other than {TXT2HTML, NO_CONV} has unpredictable result.

### makeHtmlSelectOne

    public static String makeHtmlSelectOne(String name,
                                           String[] values,
                                           String[] labels,
                                           String selectedValue,
                                           String literalHtml,
                                           int convert2Html)

  Returns a select statement in HTML.

  See Also:
    `makeHtmlSelectOne(String, List, List, String, String, int)`

### makeHtmlSelectMultiple

    public static String makeHtmlSelectMultiple(String name,
                                                String[] values,
                                                String[] labels,
                                                String[] selectedValues,
                                                int size,
                                                String literalHtml,
                                                int convert2Html)

  Returns a select multiple statement in HTML.

  Parameters:
    `name` - The name of the parameter that is set by this SELECT
    `values` - Array of the values (String) of the options, same order as 'labels'
    `labels` - Array of the labels (String) of the options, same order as 'values'
    `selectedValues` - Array of selected values (String), if any, or null.
    `size` - Number of lines in the input box.
    `literalHtml` - Extra HTML to be added literally to the SELECT tag.
    `convert2Html` - Configuration whether `values` and `labels` must be converted ('escaped') to HTML during the writing out. Default is "NO_CONV". Any input other than {TXT2HTML, NO_CONV} has unpredictable result.
  See Also:
    `makeHtmlSelectOne(String, List, List, String, String, int)`

### makeHtmlRadioSelect

    public static String makeHtmlRadioSelect(String name,
                                             String[] values,
                                             String[] labels,
                                             String selectedValue,
                                             String checkboxLabelSeparator,
                                             String[] optionSeparator,
                                             String literalHtml,
                                             int convert2Html)

  Returns a radio-input statement in HTML. Radio input is a "select one" alternative.

  Parameters:
    `name` - The name of the parameter that is set by this INPUT type=RADIO
    `values` - Array of the values (String) of the options, same order as 'labels'
    `labels` - Array of the labels (String) of the options, same order as 'values'
    `selectedValue` - The selected value, if any (String, or null)
    `checkboxLabelSeparator` - String to separate the clickable box and the label.
    `optionSeparator` - String[] with separators between the different Option-Elements; repeatedly cycles thru this array.
    `literalHtml` - Extra HTML to be added literally to the SELECT tag.
    `convert2Html` - Configuration whether `values` and `labels` must be converted ('escaped') to HTML during the writing out. Default is "NO_CONV". Any input other than {TXT2HTML, NO_CONV} has unpredictable result.
  See Also:
    `makeHtmlSelectOne(String, String[], String[], String, String, int)`, `makeHtmlRadioSelect(String, String[], String[], String, String, String, String, int)`

### makeHtmlCheckboxSelect

    public static String makeHtmlCheckboxSelect(String name,
                                                String[] values,
                                                String[] labels,
                                                String[] selectedValues,
                                                String checkboxLabelSeparator,
                                                String[] optionSeparator,
                                                String literalHtml,
                                                int convert2Html)

  Returns a checkbox-input statement in HTML. Radio input is a "select multiple" alternative.

  Parameters:
    `name` - The name of the parameter that is set by this INPUT type=CHECKBOX
    `values` - Array of the values (String) of the options, same order as 'labels'
    `labels` - Array of the labels (String) of the options, same order as 'values'
    `selectedValues` - Array of selected values (String), if any, or null.
    `checkboxLabelSeparator` - String to separate the clickable box and the label.
    `optionSeparator` - String[] with separators between the different Option-Elements; repeatedly cycles thru this array.
    `literalHtml` - Extra HTML to be added literally to the SELECT tag.
    `convert2Html` - Configuration whether `values` and `labels` must be converted ('escaped') to HTML during the writing out. Default is "false". Any input other than {"true", "false", null} has unpredictable result.
  See Also:
    `makeHtmlSelectMultiple(String, String[], String[], String[], int, String, int)`, `makeHtmlCheckboxSelect(String, String[], String[], String[], String, String, String, int)`

### makeHtmlRadioSelect

    public static String makeHtmlRadioSelect(String name,
                                             String[] values,
                                             String[] labels,
                                             String selectedValue,
                                             String checkboxLabelSeparator,
                                             String optionSeparator,
                                             String literalHtml,
                                             int convert2Html)

  Returns a radio-input statement in HTML; shorthand for only one optionSeparator.

  See Also:
    `makeHtmlRadioSelect(String name, String[] values, String[] labels, String selectedValue, String checkboxLabelSeparator, String[] optionSeparator, String literalHtml, int convert2Html)`

### makeHtmlCheckboxSelect

    public static String makeHtmlCheckboxSelect(String name,
                                                String[] values,
                                                String[] labels,
                                                String[] selectedValues,
                                                String checkboxLabelSeparator,
                                                String optionSeparator,
                                                String literalHtml,
                                                int convert2Html)

  Returns a checkbox-input statement in HTML; shorthand for only one optionSeparator.

  See Also:
    `makeHtmlCheckboxSelect(String name, String[] values, String[] labels, String[] selectedValues, String checkboxLabelSeparator, String[] optionSeparator, String literalHtml, int convert2Html)`

### setFormIdentifier

    public void setFormIdentifier(Object formCount)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20