package e4s.tutorial;
import e4s.html.HTML;
import e4s.html.E4Method;
import e4s.html.input.extended.DATEFIELD;
import e4s.html.input.extended.E4Fieldset;
import e4s.html.input.extended.E4InputFieldName;
import e4s.html.input.extended.E4SelectValues;
import e4s.html.input.list.E4InputList;
import e4s.servlet.E4SessionObject_Intf;
import e4s.servlet.E4ModuleImplementation;
import e4s.translate.E4LabelNone;
/**
* Using input list for multiple input rows.
*
* {@tutorial Example_E4InputList}
*
* @see e4s.html.input.list.E4InputList
*/
public class Example_InputList extends E4ModuleImplementation
{
public static E4Method start = null;
private static class TestInput extends E4InputList implements E4SessionObject_Intf
{
private final E4InputFieldName FIELD_A = new E4InputFieldName("A");
private final E4InputFieldName FIELD_B = new E4InputFieldName("B");
private final E4InputFieldName FIELD_C = new E4InputFieldName("C");
private final E4InputFieldName FIELD_D = new E4InputFieldName("D");
private final E4InputFieldName FIELD_E = new E4InputFieldName("E");
public TestInput()
throws Exception
{
E4Fieldset fieldset = new E4Fieldset();
fieldset.TEXTFIELD(FIELD_A,"Text",10);
fieldset.SELECT(FIELD_B,"Select",getSelection());
fieldset.CHECKBOX(FIELD_C,"Check");
DATEFIELD d = fieldset.DATEFIELD(FIELD_D,"Date");
d.noTimeFormat();
fieldset.LONGFIELD(FIELD_E,"Integer");
setFields(fieldset);
setShowRowCount(true);
setCaption(new E4LabelNone("ListInput element"));
setNewRows(3);
setPageSize(5);
}
private E4SelectValues getSelection()
{
E4SelectValues res = new E4SelectValues();
res.addElement(1,new E4LabelNone("Alpha"));
res.addElement(2,new E4LabelNone("Beta"));
res.addElement(3,new E4LabelNone("Gamma"));
return res;
}
public int getNumRows()
{
return 20;
}
public void setRow(int row, E4Fieldset fieldset)
throws Exception
{
String rnd = "";
for( int i = 0; i < 8; i++ )
rnd += (char)('A' + (int)(Math.random() * 26));
fieldset.setValue(FIELD_A,rnd);
fieldset.setValue(FIELD_B,"Alpha");
fieldset.setValue(FIELD_C,true);
fieldset.setValue(FIELD_D,new java.util.Date());
fieldset.setValue(FIELD_E,10 * (row + 1));
}
public void saveRow(int row, boolean deleted, E4Fieldset fieldset)
throws Exception
{
// here we could save our values
}
}
public void start( HTML html )
throws Exception
{
TestInput test = new TestInput();
setSessionObject(test);
html.BODY().addElement(test);
}
}