www.element4solution.com

e4s.html.input.list
Class E4InputList

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.html.E4HtmlObject
          extended by e4s.html.E4HtmlElementGeneral
              extended by e4s.html.input.list.E4InputList
All Implemented Interfaces:
E4HtmlElement_Intf, E4ClientObject_Intf, E4SessionObject_Intf

public abstract class E4InputList
extends E4HtmlElementGeneral
implements E4HtmlElement_Intf, E4SessionObject_Intf, E4ClientObject_Intf

Display a few lines of input data with direct editing possibilities. Support changing the order of rows, deletion, line numbering, printing. You need to implement and instanciate a class which is derived from this class, and define one row of input fields using the #setFields(e4s.html.input.extended.E4InputField_Intf) function. Then, add this object to your HTML context using the #add2body(e4s.html.BODY,e4s.servlet.E4ServletImplementation_Intf. Specify the number of existing (not new) rows using the implemented getNumRows() function in your class. Some new input rows will be added additionally, their number can be set using a call to setNewRows(int). You should make this object session persistant by using e4s.servlet.E4ServletImplementation_Intf#setSessionObject(String, Object). On creation, you can provide a {@link e4s.html.E4Method} method which will be called. On the first run, data is queried in your class using the overridden method {@link #setValue(int, e4s.html.input.extended.E4Fieldset}. This function will be called for every input row, starting at 0. To save the values after the user clicks the save button, your class will be called by the function {@link #saveRow(int, boolean, e4s.html.input.extended.E4Fieldset)}. {@tutorial Example_E4InputList}


Field Summary
static int _SORTING_ALL
           
static int _SORTING_NON_EMPTY_ROWS_ONLY
           
static int _SORTING_NONE
           
static java.lang.String JS_NAME_SAVE
           
static E4InputFieldName PARAM_SESS_OBJ
           
 
Fields inherited from class e4s.html.E4HtmlElementGeneral
m_elements, m_needed_scripts
 
Fields inherited from class e4s.html.E4HtmlObject
m_parent_e4sID
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4InputList()
          Constructor for the E4InputList element unsing a default method implementation.
E4InputList(E4Method mref_update)
          Constructor for the E4InputList element.
 
Method Summary
static java.lang.String _getSVNVersionString()
          Get version info string from subversion.
 void add2body(BODY body, E4ServletImplementation_Intf servlet)
          This function adds the input-list element to the body and (if printing is active) calls the printer dialog.
protected  void addRowPrinting(TR tr, int n, E4ServletImplementation_Intf servlet)
           
 E4InputField_Intf beforeDisplay(int row, E4InputFieldName_Intf fieldname, E4InputField_Intf field)
          Is called before a field is displayed in the form.
protected  E4InputFieldName changeName(E4InputFieldName_Intf fieldname, int n)
           
 void collectScripts(E4ScriptsVec vec, E4ServletImplementation_Intf servlet)
          Collect the scripts required.
 void collectStylesForEditing(E4StylesHash v, E4ServletImplementation_Intf servlet)
          Build a list (Vector) with style definitions used so far during display of this page.
 void collectTranslationsForEditing(E4TranslationsVec v, E4ServletImplementation_Intf servlet)
          Collect the scripts required.
 E4HtmlElement_Intf finishedSavingValues()
          This function is called after the last call to {@link #saveRow(int,boolean,e4s.html.input.extended.E4Fieldset) to refresh the data by the instanciating method.
 Align getAlign(int column, E4InputField_Intf field)
           
 E4Label_Intf getCaption()
          Get the caption for the data components.
 boolean getEnableDelete()
           
 boolean getEnablePrinting()
          Is printing enabled?
 boolean getEnableSorting()
           
 E4InputField_Intf[] getFields()
          Get the fields defined for this E4InputList.
 E4Color getHighlightColor()
          Get the color for row highlighting.
 int getNewRows()
          Get the number of new rows to be appended after existing rows.
abstract  int getNumRows()
          Get the initial number of rows.
 java.lang.String getObjectID()
          Get a session object, by default this will be the class name, which will not work when your application uses different objects of this class - so it is recommended that you will implement this function in yout instance.
 int getPageSize()
          Get the number of rows displayed per page.
 E4CgiParams getParameters()
          Get the parameters once stored using #processParams(e4s.html.E4CgiParams).
 boolean getShowRowCount()
           
 STYLE_Name getStyleHeader()
           
 STYLE_Name getStyleTable()
           
 boolean isPrinting()
          Get the current display mode.
 boolean isValidated()
           
 boolean processParams(E4CgiParams params, E4ServletImplementation_Intf servlet)
          Process teh parameters (input values and internal navigation and controlling stuff).
abstract  void saveRow(int row, boolean deleted, E4Fieldset fieldset)
          Saves the changed value on save.
 void setCaption(E4Label_Intf caption)
          Set the caption for the horizontal data components.
 void setCaption(java.lang.String caption)
          Set the caption for the data components.
 void setEnableDelete(boolean delete)
           
 void setEnablePrinting(boolean mode)
          Enable printing.
 void setEnableSorting(boolean sorting)
          Deprecated.  
 void setEnableSorting(int sorting)
          Define if sorting will be possible or not.
 void setField(E4InputField_Intf field)
          Add a field to the representation of a row.
 void setFields(E4Fieldset fieldset)
          Define the data fields for one representative row.
 void setFields(E4InputField_Intf[] fields)
          Define the data fields for one representative row.
 void setHighlightColor(E4Color color)
          Set the color for row highlighting.
 void setNewRows(int newrows)
          Set the number of new rows to be appended after existing rows.
 void setPageSize(int pagesize)
          Set the number of rows displayed per page.
abstract  void setRow(int row, E4Fieldset fieldset)
          Set the initial values of the fields.
 void setShowRowCount(boolean show)
           
 void setStyleHeader(STYLE_Name m_style_header)
           
 void setStyleTable(STYLE_Name m_style_table)
           
 void swapIndex(int a, int b, E4CgiParams params)
          This function is called when sorting is enabled and the user selects a up/down arrow.
 void toHtml(E4StringBufferHtml buf, E4ServletImplementation_Intf servlet)
          Render this object.
 boolean validateRow(int row, E4Fieldset fieldset)
           
 
Methods inherited from class e4s.html.E4HtmlElementGeneral
addScript, addScript, addScript, addStyleForEditing, addTranslationForEditing, buildStyleAttribute, buildStyleClassReference, collectStylesForEditing, collectStylesForEditing, collectTranslationsForEditing, createScript, createScript, debugToString, findElement, findElement, findElement, findElement, getElements, getElementsVec, getField, getId, getLastElement, getStringContent, getStyle, getSTYLE, getStyle, hasScripts, hasSTYLE, isContentClass, isE4InputField_Intf, openTag, removeAll, removeElementById, removeElements, removeElements, removeStyle, setId, setReadOnly, setStyle, setStyle, setSTYLE, setValue, Style, Style, toHtml_hidden, validate
 
Methods inherited from class e4s.html.E4HtmlObject
E4ID, E4ID, set_e4sID
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, finalize, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, toString, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface e4s.html.E4HtmlElement_Intf
addScript, addScript, addScript, debugToString, findElement, findElement, getElements, getElementsVec, getField, getId, getStringContent, isContentClass, removeAll, removeElementById, removeElements, set_e4sID, setId, setReadOnly, setValue, toHtml_hidden, validate
 

Field Detail

_SORTING_NONE

public static final int _SORTING_NONE
See Also:
setEnableSorting(int), _SORTING_ALL, _SORTING_NON_EMPTY_ROWS_ONLY, Constant Field Values

_SORTING_ALL

public static final int _SORTING_ALL
See Also:
setEnableSorting(int), _SORTING_NONE, _SORTING_NON_EMPTY_ROWS_ONLY, Constant Field Values

_SORTING_NON_EMPTY_ROWS_ONLY

public static final int _SORTING_NON_EMPTY_ROWS_ONLY
See Also:
setEnableSorting(int), _SORTING_NONE, _SORTING_ALL, Constant Field Values

PARAM_SESS_OBJ

public static final E4InputFieldName PARAM_SESS_OBJ

JS_NAME_SAVE

public static final java.lang.String JS_NAME_SAVE
See Also:
Constant Field Values
Constructor Detail

E4InputList

public E4InputList(E4Method mref_update)
Constructor for the E4InputList element.

Parameters:
mref_update - a method, should call #processParams(e4s.html.E4CgiParams) and add2body(e4s.html.BODY, e4s.servlet.E4ServletImplementation_Intf).
See Also:
E4InputList()

E4InputList

public E4InputList()
Constructor for the E4InputList element unsing a default method implementation.

See Also:
E4InputList(e4s.html.E4Method), E4ModuleListHandling.processE4InputList
Method Detail

getNumRows

public abstract int getNumRows()
                        throws java.lang.Exception
Get the initial number of rows. This function is abstract, so it requires to be implemented in an above instance. It will be called more often. If the number of rows is in the range 20 or more, we recommend paging which can be set using setPageSize(int).

Returns:
the number of existing rows (might be 0)
Throws:
java.lang.Exception
See Also:
setNewRows(int), setPageSize(int), setRow(int,e4s.html.input.extended.E4Fieldset), setFields(e4s.html.input.extended.E4Fieldset), saveRow(int,boolean,e4s.html.input.extended.E4Fieldset)

setRow

public abstract void setRow(int row,
                            E4Fieldset fieldset)
                     throws java.lang.Exception
Set the initial values of the fields. This function is abstract, so it requires to be implemented in an above instance. It will be called initial once only.

Parameters:
row - the current row, starting with 0 and less than getNumRows() + getNewRows(). Data of the row might also be empty.
fieldset - a fieldset containing the form input elements with the basically names specified, even if the form using different names.
Throws:
java.lang.Exception
See Also:
getNumRows(), setFields(e4s.html.input.extended.E4Fieldset), saveRow(int,boolean,e4s.html.input.extended.E4Fieldset)

saveRow

public abstract void saveRow(int row,
                             boolean deleted,
                             E4Fieldset fieldset)
                      throws java.lang.Exception
Saves the changed value on save. This function is abstract, so it requires to be implemented in an above instance.

Parameters:
row - the current row, starting with 0 and less than getNumRows() + getNewRows(). Data of the row might also be empty.
deleted - true means, that this row has been deleted (if deletion is supported setEnableDelete(boolean).
fieldset - a fieldset containing the form input elements with the basically names specified, even if the form using different names.
Throws:
java.lang.Exception
See Also:
getNumRows(), setFields(e4s.html.input.extended.E4Fieldset), setRow(int,e4s.html.input.extended.E4Fieldset)

finishedSavingValues

public E4HtmlElement_Intf finishedSavingValues()
                                        throws java.lang.Exception
This function is called after the last call to {@link #saveRow(int,boolean,e4s.html.input.extended.E4Fieldset) to refresh the data by the instanciating method. This implementation is empty, it is intended to be overridden whenever needed.

Returns:
null, if the data shall be displayed again, or any Html-Element that shall be displayed instead (use an empty DIV or E4LabelNone if nothing shall be displayed, but edititing shall not be take place again)
Throws:
java.lang.Exception
See Also:
saveRow(int,boolean,e4s.html.input.extended.E4Fieldset)

setFields

public void setFields(E4InputField_Intf[] fields)
Define the data fields for one representative row. The array index indicates the column. When running, this fields are expanded to rows given each field an individual value by setRow(int, e4s.html.input.extended.E4Fieldset). Each field will get a unique name while rolled out to the different input rows.

Parameters:
fields - an array of fields, each representing a column in the input table
See Also:
getFields(), setFields(e4s.html.input.extended.E4Fieldset)

setFields

public void setFields(E4Fieldset fieldset)
Define the data fields for one representative row. The fieldset index indicates the whole row. When running, this fields are expanded to rows given each field an individual value by setRow(int, e4s.html.input.extended.E4Fieldset). Each field will get a unique name while rolled out to the different input rows.

Parameters:
fieldset - contains the fields (one row only)
See Also:
getFields(), #setFields(e4s.html.input.extended.E4InputField_Intf)

setField

public void setField(E4InputField_Intf field)
Add a field to the representation of a row.

See Also:
setFields(e4s.html.input.extended.E4Fieldset), setFields(e4s.html.input.extended.E4InputField_Intf[])

getEnableSorting

public boolean getEnableSorting()

getEnableDelete

public boolean getEnableDelete()

setEnableSorting

public void setEnableSorting(int sorting)
Define if sorting will be possible or not. Sorting means, that tone or two gray arrows are displayed in the first two columns. In the case, sorting is enabled and the user clicks on one of those buttons the function swapIndex(int, int, e4s.html.E4CgiParams) will be called.

Parameters:
sorting - a value of _SORTING_NONE disables sorting, a value of _SORTING_ALL enables sorting for all (including empty) rows and a value of _SORTING_NON_EMPTY_ROWS_ONLY only for rows that do have data.
See Also:
_SORTING_ALL, _SORTING_NON_EMPTY_ROWS_ONLY, _SORTING_NONE, getEnableSorting(), swapIndex(int, int, e4s.html.E4CgiParams)

setEnableSorting

public void setEnableSorting(boolean sorting)
Deprecated. 

See Also:
setEnableSorting(int)

setEnableDelete

public void setEnableDelete(boolean delete)

getShowRowCount

public boolean getShowRowCount()

setShowRowCount

public void setShowRowCount(boolean show)

toHtml

public void toHtml(E4StringBufferHtml buf,
                   E4ServletImplementation_Intf servlet)
            throws java.lang.Exception
Render this object.

Specified by:
toHtml in interface E4HtmlElement_Intf
Overrides:
toHtml in class E4HtmlElementGeneral
Parameters:
servlet - the servlet context.
Throws:
java.lang.Exception

collectScripts

public void collectScripts(E4ScriptsVec vec,
                           E4ServletImplementation_Intf servlet)
Collect the scripts required.

Specified by:
collectScripts in interface E4HtmlElement_Intf
Overrides:
collectScripts in class E4HtmlElementGeneral
Parameters:
vec - collect the names of all scripts
servlet - the servlet context
See Also:
E4JavaScript

collectTranslationsForEditing

public void collectTranslationsForEditing(E4TranslationsVec v,
                                          E4ServletImplementation_Intf servlet)
Collect the scripts required.

Specified by:
collectTranslationsForEditing in interface E4HtmlElement_Intf
Overrides:
collectTranslationsForEditing in class E4HtmlElementGeneral
Parameters:
v - the Vector where the styles will be collected, may not be null
servlet - the current servlet instance
See Also:
E4Label_Intf

collectStylesForEditing

public void collectStylesForEditing(E4StylesHash v,
                                    E4ServletImplementation_Intf servlet)
Description copied from class: E4HtmlElementGeneral
Build a list (Vector) with style definitions used so far during display of this page. Run throught all subclasses elements and collect their styles as well. Note, that a style will only be added one time. The Vector contains elements of class E4StyleUsage.

Specified by:
collectStylesForEditing in interface E4HtmlElement_Intf
Overrides:
collectStylesForEditing in class E4HtmlElementGeneral
Parameters:
v - the Vector where the styles will be collected, may not be null
servlet - the servlet context
See Also:
E4ServletImplementation_Intf.sessionCanEditStyles(), #collectStylesForEditing(e4s.html.style.E4StylesHash, STYLE_Name, boolean)

processParams

public boolean processParams(E4CgiParams params,
                             E4ServletImplementation_Intf servlet)
                      throws java.lang.Exception
Process teh parameters (input values and internal navigation and controlling stuff).

Parameters:
params - the parameters received in the E4Method call
Returns:
true, if values have been saved
Throws:
java.lang.Exception
See Also:
add2body(e4s.html.BODY, e4s.servlet.E4ServletImplementation_Intf), getParameters()

swapIndex

public void swapIndex(int a,
                      int b,
                      E4CgiParams params)
This function is called when sorting is enabled and the user selects a up/down arrow. This always indicates two index: from and to. The function can be overwritten but it is important to call the super implementation right here.

Parameters:
a - first index
b - second index (!= a)
params - the current parameters needed to be passed throught to change the values of the input fields
See Also:
setEnableSorting(int), getEnableSorting()

add2body

public void add2body(BODY body,
                     E4ServletImplementation_Intf servlet)
This function adds the input-list element to the body and (if printing is active) calls the printer dialog.

Parameters:
body - the above body element where this grid shall be added.
See Also:
#processParams(e4s.html.E4CgiParams)

validateRow

public boolean validateRow(int row,
                           E4Fieldset fieldset)

addRowPrinting

protected void addRowPrinting(TR tr,
                              int n,
                              E4ServletImplementation_Intf servlet)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getAlign

public Align getAlign(int column,
                      E4InputField_Intf field)

beforeDisplay

public E4InputField_Intf beforeDisplay(int row,
                                       E4InputFieldName_Intf fieldname,
                                       E4InputField_Intf field)
Is called before a field is displayed in the form. The field contains the value of the current row, and a fieldname based upon the row.

Parameters:
row - the current row (0 < row <= getNumRows() + getNewRows())
fieldname - the name of the field as defined in setField(e4s.html.input.extended.E4InputField_Intf), this is not the current name of the field
field - the current field
Returns:
the field unchanged (default implementation)

changeName

protected E4InputFieldName changeName(E4InputFieldName_Intf fieldname,
                                      int n)

getStyleHeader

public STYLE_Name getStyleHeader()

setStyleHeader

public void setStyleHeader(STYLE_Name m_style_header)

getStyleTable

public STYLE_Name getStyleTable()

setStyleTable

public void setStyleTable(STYLE_Name m_style_table)

getNewRows

public int getNewRows()
Get the number of new rows to be appended after existing rows.

Returns:
the number of new rows (0 = none, 3 = default)
See Also:
setNewRows(int), getNumRows()

setNewRows

public void setNewRows(int newrows)
Set the number of new rows to be appended after existing rows.

Parameters:
newrows - greqter or equal than 0, the default value is 3
See Also:
getNewRows(), getNumRows()

getHighlightColor

public E4Color getHighlightColor()
Get the color for row highlighting.

Returns:
the color or null if not defined
See Also:
TR.getHighlightColor(), setHighlightColor(e4s.html.E4Color)

setHighlightColor

public void setHighlightColor(E4Color color)
Set the color for row highlighting.

Parameters:
color - the color or null if no highlighting is wanted
See Also:
TR.setHighlightColor(e4s.html.E4Color), getHighlightColor()

setEnablePrinting

public void setEnablePrinting(boolean mode)
Enable printing.

Parameters:
mode - true, if printing is enabled
See Also:
getEnablePrinting(), isPrinting()

getEnablePrinting

public boolean getEnablePrinting()
Is printing enabled?

Returns:
true, if printing is enabled
See Also:
setEnablePrinting(boolean), isPrinting()

isPrinting

public boolean isPrinting()
Get the current display mode.

Returns:
true, if the user has clicked the print-button.
See Also:
setEnablePrinting(boolean), getEnablePrinting()

setPageSize

public void setPageSize(int pagesize)
Set the number of rows displayed per page. The initial value is -1, so no pages are displayed, instead all data will be visible on one page without paging.

Parameters:
pagesize - the pagesize, -1 (default) disables paging
See Also:
getPageSize()

getPageSize

public int getPageSize()
Get the number of rows displayed per page. The initial value is -1, so no pages are displayed, instead all data will be visible on one page without paging.

Returns:
the pagesize, -1 (default) disables paging
See Also:
setPageSize(int)

getObjectID

public java.lang.String getObjectID()
Get a session object, by default this will be the class name, which will not work when your application uses different objects of this class - so it is recommended that you will implement this function in yout instance.

Specified by:
getObjectID in interface E4ClientObject_Intf
Specified by:
getObjectID in interface E4SessionObject_Intf
Returns:
getClass().getName()

setCaption

public void setCaption(E4Label_Intf caption)
Set the caption for the horizontal data components.

Parameters:
caption - the caption_horizontal to set
See Also:
getCaption(), setCaption(String), setCaption(e4s.translate.E4Label_Intf)

setCaption

public void setCaption(java.lang.String caption)
Set the caption for the data components.

Parameters:
caption - the caption to be set
See Also:
getCaption(), setCaption(e4s.translate.E4Label_Intf), setCaption(String)

getCaption

public E4Label_Intf getCaption()
Get the caption for the data components.

Returns:
the caption
See Also:
setCaption(String), setCaption(e4s.translate.E4Label_Intf)

getParameters

public E4CgiParams getParameters()
Get the parameters once stored using #processParams(e4s.html.E4CgiParams).

Returns:
the CGI parameters

getFields

public E4InputField_Intf[] getFields()
Get the fields defined for this E4InputList. This are only the fields for one row, the index of the array represents the column. The fields are duplicated for each input row by assigning a new field name each. You can read out field behavior, but you should not assign or read any values or the field's name.

Returns:
an array of defined fields (representative header only)
See Also:
#setFields(e4s.html.input.extended.E4InputField_Intf), setFields(e4s.html.input.extended.E4Fieldset)

isValidated

public boolean isValidated()

_getSVNVersionString

public static java.lang.String _getSVNVersionString()
Get version info string from subversion.

Returns:
the version info string.
See Also:
E4Util.getRevisionCodeFromSVN(Class)

www.element4solution.com