package e4s.tutorial; import java.io.*; import java.util.*; import java.text.*; import e4s.html.*; import e4s.html.input.extended.*; import e4s.translate.*; import e4s.servlet.*; /** * A simple class, that demonstrates the use of select fields in form elements. SELECT fields are based on the * E4SelectValues collection that holds - plain or structured - options for the selection. Special input behavior * enables entering values while selecting the drop-down (place focus on the city list and type some some characters). * * {@tutorial Example_Input_Select} * * @see e4s.html.IMG */ public class Example_Input_Select extends E4ModuleImplementation { public static E4Method selectExample = null; public static E4Method selectExample_Save = null; public void selectExample( HTML html ) { BODY body = html.BODY(); body.Message(E4Message.CAPTION,"This example illustrates the usage of INPUT/SELECT"); FORM form = body.FORM(selectExample_Save); E4SelectValues valuesA = new E4SelectValues(); valuesA.addElement("NYC","New York"); valuesA.addElement("Chicago","Chicago"); valuesA.addElement("SF",new E4LabelApp("San Francisco")); valuesA.addElement("London"); valuesA.addElement("Paris"); valuesA.addElement("Vienna"); valuesA.addElement("Rome"); SELECT selectA = form.SELECT(new E4InputFieldName("A"),"Un-Grouped Selection",valuesA); // this allows user input even on select elements for faster location of an item selectA.setSpecialInputBehavior(form); E4SelectValues values_US = new E4SelectValues(); values_US.addElement("NYC","New York"); values_US.addElement("Chicago","Chicago"); values_US.addElement("SF",new E4LabelApp("San Francisco")); E4SelectValues values_EU = new E4SelectValues(); values_EU.addElement("London"); values_EU.addElement("Paris"); E4SelectValues valuesB = new E4SelectValues(); valuesB.addOptionGroup("USA",values_US); valuesB.addOptionGroup("Europe",values_EU); SELECT selectB = form.SELECT(new E4InputFieldName("B"),"Grouped Selection",valuesB); form.FORM_Submit("Continue"); } public void selectExample_Save( HTML html, E4CgiParams params ) { params.toTable(html.TABLE()); A href = html.A(selectExample); href.print("[do it again]"); } }