www.element4solution.com

e4s.html
Class E4HtmlElementGeneral

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.html.E4HtmlObject
          extended by e4s.html.E4HtmlElementGeneral
Direct Known Subclasses:
E4BasicTextInput, E4FieldsetLayout, E4Grid, E4HtmlContent, E4HtmlElement, E4HtmlElementGeneralPersistant, E4InputList, E4Label, E4LabelData, E4LabelNone, E4MenuItem, E4Message, E4TabbedMenuElement, IMG.IMAP

public abstract class E4HtmlElementGeneral
extends E4HtmlObject

General class for HTML elements. This base class defines some of the function necessary to handle HTML elements throught the e4s environment, hold and build their sub-elements, Java-Script and E4CSS elements.

Since:
JDK 1.4
See Also:
E4HtmlElement, E4HtmlContent, E4HtmlContentElement

Field Summary
protected  E4ElementsVec m_elements
          Vector of all subelements of the rs.html classes.
protected  E4ScriptsVec m_needed_scripts
          Vector containing all Java scripts defined.
 
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
E4HtmlElementGeneral()
           
E4HtmlElementGeneral(E4HtmlElementGeneral e)
           
E4HtmlElementGeneral(E4ID parent_id)
           
 
Method Summary
 void addScript(E4HtmlElement_Intf element, E4ServletImplementation_Intf servlet)
          Add the E4JavaScript entries of the specified element to the current element.
 void addScript(E4JavaScript_Intf jscript)
          Add this E4JavaScript to the scripts Vector.
 void addScript(E4JavaScript_Intf jscript, boolean force_replace)
           
 void addStyleForEditing(E4StylesHash v, E4ServletImplementation_Intf servlet, STYLE_Name style_name)
           
 void addTranslationForEditing(E4TranslationsVec v, E4ServletImplementation_Intf servlet, E4Label trans)
           
protected  void buildStyleAttribute(E4StringBufferHtml buf)
          Appends the styles to the buffer (... style="..."...)
protected  void buildStyleClassReference(E4StringBufferHtml buf)
          Create the CLASS=.. element in the HTML output buffer.
 void collectScripts(E4ScriptsVec v, E4ServletImplementation_Intf servlet)
          Get a vector of used scripts from all subelements.
 void collectStylesForEditing(E4StylesHash v, E4ServletImplementation_Intf servlet)
          Build a list (Vector) with style definitions used so far during display of this page.
 void collectStylesForEditing(E4StylesHash v, E4ServletImplementation_Intf servlet, STYLE_Name style_name, boolean subclasses)
          Build a list (Vector) with style definitions used so far during display of this page.
static void collectStylesForEditing(E4StylesHash v, E4ServletImplementation_Intf servlet, STYLE_Name style_name, java.lang.Class clazz)
           
 void collectTranslationsForEditing(E4TranslationsVec v, E4ServletImplementation_Intf servlet)
          Build a list (Vector) with translation texts used so far during display of this page.
 void collectTranslationsForEditing(E4TranslationsVec v, E4ServletImplementation_Intf servlet, E4Label_Intf trans, boolean subclasses)
          Add a label and build a list (Vector) with translation texts used so far during display of this page.
 E4JavaScript createScript()
          Creates a E4JavaScript, given a generic name, and adds it to the scripts Vector.
 E4JavaScript createScript(java.lang.String jscript_name)
          Creates a E4JavaScript by the given name and adds it to the scripts Vector.
 java.lang.String debugToString(int n)
           
 E4HtmlElement_Intf findElement(java.lang.Class clazz)
          Find any element in the element vector by the given clazz.
 E4HtmlElement_Intf findElement(java.lang.Class clazz, boolean deeper)
          Find any element in the element vector by the given clazz.
 E4HtmlElement_Intf findElement(int id)
          Find an element in the element vector by the given id, but do not look in sub-elements.
 E4HtmlElement_Intf findElement(int id, boolean deeper)
          Find an element in the element vector by the given id.
 java.util.Enumeration getElements()
          Deprecated.  
 E4ElementsVec getElementsVec()
          The elements Vector.
 E4InputField_Intf getField(E4InputFieldName_Intf fieldname)
          Get the associated object for the specified field.
 int getId()
          Returns the unique identification id for this element.
 E4HtmlElement_Intf getLastElement()
          Get the last element of direct related sub elements.
 java.lang.String getStringContent()
           
 java.lang.String getStyle()
           
 STYLE_Name getSTYLE()
           
 java.lang.String getStyle(java.lang.String style_name)
           
 boolean hasScripts()
          Test, if scripts have been added or created.
 boolean hasSTYLE()
           
 boolean isContentClass()
          This function returns false always, except for the collecting class E4HtmlContent which is a special case.
static boolean isE4InputField_Intf(java.lang.Object obj)
          Check, if given object implements the E4InputField_Intf interface.
 void openTag(java.lang.String tag, E4StringBufferHtml buf)
          Create a StringBuffer to be used at HTML output, include any E4CSS class tag.
 void removeAll()
          Remove all elements
 void removeElementById(int id)
          Remove an element by it's ID
 void removeElements()
          Remove all elements.
 void removeElements(java.lang.Class clazz)
          Remove all elements after and including a specified class.
 void removeStyle(java.lang.String style)
           
 void setId(int id)
          Sets a unique identification id for this element.
 void setReadOnly(boolean displayonly)
          Run throught all child elements recursivly, and if those elements implement interface E4InputField_Intf then set them to read-only state.
 void setStyle(java.lang.String style, int value)
           
 void setStyle(java.lang.String style, java.lang.String value)
           
 void setSTYLE(STYLE_Name style)
           
 void setValue(E4CgiParams params)
          Run throught all child elements recursivly, and if those elements implement interface E4InputField_Intf then store the parameter.
 E4StyleAttributes Style()
          Get the attributes for that element.
protected  E4StyleAttributes Style(boolean create)
          Get the attributes for that element.
 void toHtml_hidden(E4StringBufferHtml buf, E4ServletImplementation_Intf servlet)
           
 void toHtml(E4StringBufferHtml buf, E4ServletImplementation_Intf servlet)
           
 boolean validate(E4CgiParams params, E4ServletImplementation_Intf servlet)
          Run throught all child elements recursivly, and if those elements implement interface E4InputField_Intf then store the parameter and execute the E4InputField_Intf.validate() function.
 
Methods inherited from class e4s.html.E4HtmlObject
_getSVNVersionString, 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
 

Field Detail

m_elements

protected E4ElementsVec m_elements
Vector of all subelements of the rs.html classes.


m_needed_scripts

protected E4ScriptsVec m_needed_scripts
Vector containing all Java scripts defined.

Constructor Detail

E4HtmlElementGeneral

public E4HtmlElementGeneral()

E4HtmlElementGeneral

public E4HtmlElementGeneral(E4HtmlElementGeneral e)

E4HtmlElementGeneral

public E4HtmlElementGeneral(E4ID parent_id)
Method Detail

hasScripts

public boolean hasScripts()
Test, if scripts have been added or created.

Returns:
true, if at least one E4JavaScript is existing in this current object, not checking sub-related objects.
See Also:
#addScript(), createScript(), E4JavaScript

getLastElement

public E4HtmlElement_Intf getLastElement()
Get the last element of direct related sub elements. This means, non recursivly.

Returns:
the latest element in the chain of sub-elements or null if no sub element(s) defined.

removeAll

public void removeAll()
Remove all elements


collectScripts

public void collectScripts(E4ScriptsVec v,
                           E4ServletImplementation_Intf servlet)
Get a vector of used scripts from all subelements.

See Also:
E4JavaScript

addScript

public void addScript(E4JavaScript_Intf jscript)
Add this E4JavaScript to the scripts Vector.

Parameters:
jscript - the script to add. Note, that a script with the same name can only be added once.
See Also:
createScript( String )

createScript

public E4JavaScript createScript(java.lang.String jscript_name)
Creates a E4JavaScript by the given name and adds it to the scripts Vector.

Parameters:
jscript_name - the name of the script to be created and added.
See Also:
#addScript( E4JavaScript ), createScript()

createScript

public E4JavaScript createScript()
Creates a E4JavaScript, given a generic name, and adds it to the scripts Vector.

See Also:
#addScript( E4JavaScript ), createScript( String )

addScript

public void addScript(E4HtmlElement_Intf element,
                      E4ServletImplementation_Intf servlet)
Add the E4JavaScript entries of the specified element to the current element. This normally happens automatically, as long as HTML elements are linked together using the E4HtmlElement.addElement(e4s.html.E4HtmlElement_Intf) function. But in some cases, this might not be the case but scripts are required in the above element.

Parameters:
element - element where the scripts shall be taken from
See Also:
#addScript(e4s.html.E4JavaScript), e4s.html.E4HtmlElement_Intf#collectScripts...

addScript

public void addScript(E4JavaScript_Intf jscript,
                      boolean force_replace)

toHtml

public void toHtml(E4StringBufferHtml buf,
                   E4ServletImplementation_Intf servlet)
            throws java.lang.Exception
Throws:
java.lang.Exception

toHtml_hidden

public void toHtml_hidden(E4StringBufferHtml buf,
                          E4ServletImplementation_Intf servlet)
                   throws java.lang.Exception
Throws:
java.lang.Exception

debugToString

public java.lang.String debugToString(int n)

getElements

public java.util.Enumeration getElements()
Deprecated. 

The Enumeration of the elements Vector

Returns:
represents the Enumeration for the elements Vector
See Also:
getElementsVec()

getElementsVec

public E4ElementsVec getElementsVec()
The elements Vector.

Returns:
represents the Enumeration for the elements Vector

removeElements

public void removeElements()
Remove all elements.


removeElementById

public void removeElementById(int id)
Remove an element by it's ID

Parameters:
id - the ID of the element.
See Also:
setId(int)

removeElements

public void removeElements(java.lang.Class clazz)
Remove all elements after and including a specified class. Example: if your DOM looks like <TABLE><TR><TD><TR><TD> then a call to removeElements(TD.class) would remove both <TD> entries.

Parameters:
clazz - the class to be removed
See Also:
removeElements()

findElement

public E4HtmlElement_Intf findElement(int id,
                                      boolean deeper)
Find an element in the element vector by the given id.

Parameters:
id - the unique id to look for. Note that most elements have a value of -1 if undefined, and that there could be multiple elements having the same id (in this case, the first one is returned).
deeper - also search in sub-elements
Returns:
the element found of null if not
See Also:
getId(), setId(int), findElement(int), #findElement(Class,int)

findElement

public E4HtmlElement_Intf findElement(int id)
Find an element in the element vector by the given id, but do not look in sub-elements.

Parameters:
id - the unique id to look for. Note that most elements have a value of -1 if undefined, and that there could be multiple elements having the same id (in this case, the first one is returned).
Returns:
the element found of null if not
See Also:
getId(), setId(int), findElement(int,boolean), findElement(Class)

findElement

public E4HtmlElement_Intf findElement(java.lang.Class clazz)
Find any element in the element vector by the given clazz.

Parameters:
clazz - the class of the element to look for
Returns:
the first element found of null if not
See Also:
findElement(int), findElement(Class,boolean)

findElement

public E4HtmlElement_Intf findElement(java.lang.Class clazz,
                                      boolean deeper)
                               throws java.lang.Exception
Find any element in the element vector by the given clazz.

Parameters:
clazz - the class of the element to look for
deeper - true: run throught the whole hirachy, false only the current level of child elements
Returns:
the first element found of null if not
Throws:
java.lang.Exception
See Also:
findElement(int,boolean), findElement(Class)

setId

public void setId(int id)
Sets a unique identification id for this element. This value is optional and can be used to identify a particular element by the id which must be unique within the element vector of the above object.

Parameters:
id - the unique identificatin id
See Also:
findElement(int), getId()

getId

public int getId()
Returns the unique identification id for this element.

Returns:
the unique identificatin id if defined, -1 if not defined
See Also:
findElement(int), setId(int)

isContentClass

public boolean isContentClass()
This function returns false always, except for the collecting class E4HtmlContent which is a special case. It is detected, if it is the end of the elements. If not, such a class is added, othervise only a string is appended. This avoids excessive creation of objects.


setSTYLE

public void setSTYLE(STYLE_Name style)

openTag

public void openTag(java.lang.String tag,
                    E4StringBufferHtml buf)
Create a StringBuffer to be used at HTML output, include any E4CSS class tag.

Parameters:
tag - the HTML tag, e.g. "BODY"
See Also:
setSTYLE(e4s.html.style.STYLE_Name), getSTYLE(), #buildStyleClassReference(StringBuffer), STYLE_Name, e4s.servlet.E4ServletImplementation_Intf#toHtml

buildStyleClassReference

protected void buildStyleClassReference(E4StringBufferHtml buf)
Create the CLASS=.. element in the HTML output buffer.

Parameters:
buf - the buffer to write in. This may not be null, it typically starts with the tag, e.g. "See Also:
setSTYLE(e4s.html.style.STYLE_Name), getSTYLE(), #createTag(String), STYLE_Name, e4s.servlet.E4ServletImplementation_Intf#toHtml

buildStyleAttribute

protected void buildStyleAttribute(E4StringBufferHtml buf)
Appends the styles to the buffer (... style="..."...)

Parameters:
buf - a valid output buffer

getSTYLE

public STYLE_Name getSTYLE()

hasSTYLE

public boolean hasSTYLE()

collectStylesForEditing

public void collectStylesForEditing(E4StylesHash v,
                                    E4ServletImplementation_Intf servlet)
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.

Parameters:
v - the Vector where the styles will be collected, may not be null
See Also:
E4ServletImplementation_Intf.sessionCanEditStyles(), #collectStylesForEditing(e4s.html.style.E4StylesHash, STYLE_Name, boolean)

collectStylesForEditing

public void collectStylesForEditing(E4StylesHash v,
                                    E4ServletImplementation_Intf servlet,
                                    STYLE_Name style_name,
                                    boolean subclasses)
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.

Parameters:
v - the Vector where the styles will be collected, may not be null
style_name - style to be added
subclasses - collect sublasses as well
See Also:
E4ServletImplementation_Intf.sessionCanEditStyles(), #collectStylesForEditing(e4s.html.style.E4StylesHash)

collectStylesForEditing

public static void collectStylesForEditing(E4StylesHash v,
                                           E4ServletImplementation_Intf servlet,
                                           STYLE_Name style_name,
                                           java.lang.Class clazz)

addStyleForEditing

public void addStyleForEditing(E4StylesHash v,
                               E4ServletImplementation_Intf servlet,
                               STYLE_Name style_name)

collectTranslationsForEditing

public void collectTranslationsForEditing(E4TranslationsVec v,
                                          E4ServletImplementation_Intf servlet)
Build a list (Vector) with translation texts used so far during display of this page. Run throught all subclasses elements and collect their texts as well. Note, that a text will only be added one time. The Vector contains elements of class E4Label.

Parameters:
v - the Vector where the styles will be collected, may not be null
servlet - the current servlet instance
See Also:
E4Label_Intf

collectTranslationsForEditing

public void collectTranslationsForEditing(E4TranslationsVec v,
                                          E4ServletImplementation_Intf servlet,
                                          E4Label_Intf trans,
                                          boolean subclasses)
Add a label and build a list (Vector) with translation texts used so far during display of this page. Run throught all subclasses elements and collect their texts as well. Note, that a text will only be added one time. The Vector contains elements of class E4Label.

Parameters:
v - the Vector where the styles will be collected, may not be null
trans - to be added
servlet - the current servlet instance
subclasses - collect sublasses as well
See Also:
E4ServletImplementation_Intf.sessionCanEditTranslations()

addTranslationForEditing

public void addTranslationForEditing(E4TranslationsVec v,
                                     E4ServletImplementation_Intf servlet,
                                     E4Label trans)

setValue

public void setValue(E4CgiParams params)
Run throught all child elements recursivly, and if those elements implement interface E4InputField_Intf then store the parameter.

Parameters:
params - the current cgi parameters
See Also:
E4InputField_Intf.setValue(e4s.html.E4CgiParams), #validate(e4s.html.E4CgiParams)

getField

public E4InputField_Intf getField(E4InputFieldName_Intf fieldname)
Get the associated object for the specified field.

Parameters:
fieldname - the name of the field
Returns:
the input field or null if not available

validate

public boolean validate(E4CgiParams params,
                        E4ServletImplementation_Intf servlet)
                 throws java.lang.Exception
Run throught all child elements recursivly, and if those elements implement interface E4InputField_Intf then store the parameter and execute the E4InputField_Intf.validate() function. In any case, you can use this function as well to set values out of the E4CgiParams to the E4InputField_Intf objects.

Parameters:
params - the current cgi parameters
Returns:
true, if all defined validations will return true. false, if at least one validation returns false. Note, that in any case all validations must be performed to set the fields error-messages.
Throws:
java.lang.Exception
See Also:
E4InputField_Intf.validate(), setValue(e4s.html.E4CgiParams), e4s.html.input.extended.E4InputField#validate(e4s.html.E4CgiParams)

setReadOnly

public void setReadOnly(boolean displayonly)
Run throught all child elements recursivly, and if those elements implement interface E4InputField_Intf then set them to read-only state.

Parameters:
displayonly - true sets the display-only mode
See Also:
E4InputField_Intf.setReadOnly()

isE4InputField_Intf

public static boolean isE4InputField_Intf(java.lang.Object obj)
Check, if given object implements the E4InputField_Intf interface.

Parameters:
obj - the Object to be checked
Returns:
true, if obj is not null and this interface is implemented

getStringContent

public java.lang.String getStringContent()

removeStyle

public void removeStyle(java.lang.String style)

setStyle

public void setStyle(java.lang.String style,
                     int value)

setStyle

public void setStyle(java.lang.String style,
                     java.lang.String value)

getStyle

public java.lang.String getStyle()

getStyle

public java.lang.String getStyle(java.lang.String style_name)

Style

protected E4StyleAttributes Style(boolean create)
Get the attributes for that element.

Parameters:
create - create style attributes only if true
Returns:
a hashtable similar object holding the attributes

Style

public E4StyleAttributes Style()
Get the attributes for that element.

Returns:
a hashtable similar object holding the attributes

www.element4solution.com