com.sapportals.htmlb

Class InputField

java.lang.Object
  extended bycom.sapportals.htmlb.Component
      extended bycom.sapportals.htmlb.EventValidationComponent
          extended bycom.sapportals.htmlb.InputField
All Implemented Interfaces:
IEventValidationComponent, IUserDataComponent, LabeledComponent

public class InputField
extends EventValidationComponent
implements IUserDataComponent, LabeledComponent

A field where the user can enter data.

Copyright 2004 SAP AG


Field Summary
static String UI_ID
           
 
Constructor Summary
InputField()
          Create a new InputField use setId to set the id of the component afterwards
InputField(String name)
          Create a new InputField with a given ID
 
Method Summary
 ArrayList getAllValidators()
          returns all validator defined for this component
 DataBCD getBCD()
          get the DataBCD container from this InputField.
 DataDate getDate()
          get the DataDate container from this InputField.
 InputFieldDesign getDesign()
          get the design to be used for the InputField
protected  String getEncodedIdForForm(Form theForm)
          internal method to get additional data for encoding fields
 int getFirstDayOfWeek()
           
 HorizontalTextAlignment getHAlign()
          gets the alignment to be used for rendering this InputField.
 DataInteger getInteger()
          get the DataInteger container from this InputField.
 Component getLabel()
           
 int getMaxlength()
          gets the maximum length for the allowed input in characters Note: some user agents may ignore this setting.
 int getMinlength()
          gets the maximum length for the allowed input in characters Note: some user agents may ignore this setting.
 boolean getParkInSession()
           
 int getSize()
          gets the size of the InputField.
 DataString getString()
          get the DataString container from this InputField.
 ForcedTextDirection getTextDirection()
          Gets the text direction for the component
 DataTime getTime()
          get the DataTime container from this InputField.
 String getTooltip()
          gets the Tooltip for this TextView.
 DataType getType()
          gets the current DataType of this InputField.
 String getUI()
          get a identification String for the renderer for this component.
 Object getValue()
          get the value associated with this InputField
 AbstractDataType getValueAsDataType()
          get the value the user entered as a AbstractDataType
 boolean getValueEncode()
           
 ValueHelpContext getValueHelpContext()
          returns the valueHelpContext
 String getWidth()
          get the width of the input field
protected  void initFromPageContext(IPageContext pc, String baseId)
          internal use only.
protected  void initFromShortId(IPageContext pc, String id)
          internal use only.
 boolean isEnabled()
          return if this button is currently disabled
 boolean isInvalid()
          Deprecated. checks if this component should represent an invalid value. It is up to the rendering how invalid InputFields should be represented. The default is to use a red border instead of a gray one.
 boolean isLabeled()
          checks if a label has been assigned to this component.
 boolean isPassword()
          Determines whether this component is a password field.
 boolean isRequired()
          gets the required flag of the InputField.
 boolean isRequiresValidation()
          returns if the inputfield requires validation
 boolean isShowHelp()
          check if some kind of help should be displayed for the InputField
 boolean isShowValueHelp()
          check if this input filed has an associated value help application or not
 boolean isValid()
          checks if this component should represent an invalid value.
 boolean isVisible()
          Determines whether this component is visible.
 void setBCD(Object bcd)
           
 void setDate(Object date)
           
 void setDesign(InputFieldDesign design)
          set the design to be used for the InputField
 void setEnabled(boolean enabled)
          enable/disable the inputfield
 void setFirstDayOfWeek(int firstDayOfWeek)
           
 void setHAlign(HorizontalTextAlignment align)
          set the aligment to be used for rendering this InputField.
 void setInteger(Object integer)
           
 void setInvalid(boolean invalid)
          Deprecated.  
 void setLabel(Component label)
           
 void setLabeled(boolean isLabeled)
          notify the component that a label has been assigned to it.
 void setMaxlength(int maxlength)
          sets the maximum length for the allowed input in characters Note: some user agents may ignore this setting.
 void setMinlength(int minlength)
          sets the maximum length for the allowed input in characters Note: some user agents may ignore this setting.
 void setParkInSession(boolean parkInSession)
           
 void setPassword(boolean password)
          sets this component to a password field.
 void setRequired(boolean required)
          sets the required flag of the InputField.
 void setRequiresValidation(boolean requiresValidation)
          determines if the inputfield requires validation
 void setShowHelp(boolean showHelp)
          sets if some kind of help should be displayed for the InputField
 void setShowValueHelp(boolean showValueHelp)
          determines if the input field has a value help application associated with it or not
 void setSize(int size)
          sets the size of the InputField.
 void setString(Object value)
          sets a String value for this InputField.
 void setTextDirection(ForcedTextDirection textDirection)
          Sets the text direction for the component
 void setTime(Object time)
           
 void setTooltip(String tooltip)
          sets the Tooltip for this TextView.
 void setType(DataType type)
          sets the DataType for this InputField.
 void setValid(boolean valid)
           
 void setValue(Object value)
          set the value for this InputField
 void setValueEncode(boolean encode)
           
 void setValueHelpContext(ValueHelpContext valueHelpContext)
          sets the value help context
 void setVisible(boolean visible)
          sets this component to visible or invisible.
 void setWidth(String width)
          set the width of the input field
 
Methods inherited from class com.sapportals.htmlb.EventValidationComponent
getClientEvent, getClientEventMap, getErrorText, getServerEvent, getServerEventMap, getValidator, isDisabled, renderJavascriptInterface, setClientEvent, setDisabled, setErrorText, setServerEvent, setValidator
 
Methods inherited from class com.sapportals.htmlb.Component
getId, getParent, initializeFromId, isJsObjectNeeded, preRender, render, renderAsString, requiresForm, setId, setJsObjectNeeded, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UI_ID

public static final String UI_ID
See Also:
Constant Field Values
Constructor Detail

InputField

public InputField()
Create a new InputField use setId to set the id of the component afterwards


InputField

public InputField(String name)
Create a new InputField with a given ID

Parameters:
name - the ID for the InputField
Method Detail

getUI

public String getUI()
get a identification String for the renderer for this component.

Specified by:
getUI in class Component
Returns:
"InputField"

getEncodedIdForForm

protected String getEncodedIdForForm(Form theForm)
internal method to get additional data for encoding fields

Overrides:
getEncodedIdForForm in class Component
Returns:
a String that uniquely identifies the InputField's datatype

initFromShortId

protected void initFromShortId(IPageContext pc,
                               String id)
Description copied from class: Component
internal use only. Set up the class for the component. If a Component added some special information to the getEncodedIdForForm() this method should be used to regain the additionally encoded information.

Overrides:
initFromShortId in class Component
Parameters:
id - the Id as it was returned by getEncodedIdForForm()

initFromPageContext

protected void initFromPageContext(IPageContext pc,
                                   String baseId)
Description copied from class: Component
internal use only. Components should override this method to analyse the parameters from the request object (via IPageContext) and set their internal data structures accordingly.

Overrides:
initFromPageContext in class Component
Parameters:
pc - the context, including the parameters
baseId - the prefix used for the component. (The result of a former RenderUtil.getIdForForm(rc, c);)

getValue

public Object getValue()
get the value associated with this InputField

Returns:
the value of this InputField

setValue

public void setValue(Object value)
set the value for this InputField

Parameters:
value - the value

setType

public void setType(DataType type)
sets the DataType for this InputField. This method will try to preserve any existing data.

Parameters:
type - the desired DataType for this InputField

getType

public DataType getType()
gets the current DataType of this InputField. May return null if no type (or value) has been set, yet.

Returns:
the DataType or null

setString

public void setString(Object value)
sets a String value for this InputField. This automatically sets the DataType of the InputField to DataString. If value is not of type String the default conversion using toString is used.

Parameters:
value - the value for this InputField

getString

public DataString getString()
get the DataString container from this InputField. If no value for the InputField has been set this will create a DataString instance and thus set the DataType of this InputField.

If the DataType of the InputField has already been set to something other than DataString this will throw an IllegalStateException exception

Returns:
a DataString
Throws:
IllegalStateException - if the InputField has a different type than DataString

setDate

public void setDate(Object date)

getDate

public DataDate getDate()
get the DataDate container from this InputField. If no value for the InputField has been set this will create a DataDate instance and thus set the DataType of this InputField.

If the DataType of the InputField has already been set to something other than DataDate this will throw an IllegalStateException exception

Returns:
a DataDate
Throws:
IllegalStateException - if the InputField has a different type than DataDate

setTime

public void setTime(Object time)

getTime

public DataTime getTime()
get the DataTime container from this InputField. If no value for the InputField has been set this will create a DataTime instance and thus set the DataType of this InputField.

If the DataType of the InputField has already been set to something other than DataTime this will throw an IllegalStateException exception

Returns:
a DataTime
Throws:
IllegalStateException - if the InputField has a different type than DataTime

setBCD

public void setBCD(Object bcd)

getBCD

public DataBCD getBCD()
get the DataBCD container from this InputField. If no value for the InputField has been set this will create a DataBCD instance and thus set the DataType of this InputField.

If the DataType of the InputField has already been set to something other than DataBCD this will throw an IllegalStateException exception

Returns:
a DataBCD
Throws:
IllegalStateException - if the InputField has a different type than DataBCD

setInteger

public void setInteger(Object integer)

getInteger

public DataInteger getInteger()
get the DataInteger container from this InputField. If no value for the InputField has been set this will create a DataInteger instance and thus set the DataType of this InputField.

If the DataInteger of the InputField has already been set to something other than DataInteger this will throw an IllegalStateException exception

Returns:
a DataInteger
Throws:
IllegalStateException - if the InputField has a different type than DataInteger

getValueAsDataType

public AbstractDataType getValueAsDataType()
get the value the user entered as a AbstractDataType

Specified by:
getValueAsDataType in interface IUserDataComponent
Returns:
the content of the InputField

getAllValidators

public ArrayList getAllValidators()
returns all validator defined for this component

Specified by:
getAllValidators in interface IEventValidationComponent
Overrides:
getAllValidators in class EventValidationComponent

getTooltip

public String getTooltip()
gets the Tooltip for this TextView. Tooltips can not contain HTML coding.

Returns:
the tooltip text

setTooltip

public void setTooltip(String tooltip)
sets the Tooltip for this TextView. Tooltips can not contain HTML coding.

Parameters:
tooltip - the tooltip text

isVisible

public boolean isVisible()
Determines whether this component is visible.

Returns:
true if the InputField is visible

setVisible

public void setVisible(boolean visible)
sets this component to visible or invisible. Invisible fields are rendered as hidden input fields into the generated page.

Parameters:
visible - true if the InputField should be visible

isPassword

public boolean isPassword()
Determines whether this component is a password field.

Returns:
true if the InputField is a password field

setPassword

public void setPassword(boolean password)
sets this component to a password field. Password fields do not show user input but show asterisks for each letter. The input will be transmitted as raw data, though. I.e. using password fields is not really secure.

Parameters:
password - true if the InputField should be a password field

isValid

public boolean isValid()
checks if this component should represent an invalid value. It is up to the rendering how invalid InputFields should be represented. The default is to use a red border instead of a gray one.

Returns:
true if the InputField contains an invalid value

setValid

public void setValid(boolean valid)

isInvalid

public boolean isInvalid()
Deprecated. checks if this component should represent an invalid value. It is up to the rendering how invalid InputFields should be represented. The default is to use a red border instead of a gray one.

Returns:
true if the InputField contains an invalid value

setInvalid

public void setInvalid(boolean invalid)
Deprecated.  

Parameters:
invalid - true if the InputField contains an invalid value

isRequired

public boolean isRequired()
gets the required flag of the InputField.

Returns:
true if the InputField is required
See Also:
TextView.isRequired()

setRequired

public void setRequired(boolean required)
sets the required flag of the InputField. This is simply a hint to the renderer how this InputField should be rendered. Please make sure to set the required flag for a label to the same value. The indication that an InputField is required might be shown on the label, e.g. using a red asterisk.

Parameters:
required - true if the InputField contains an invalid value
See Also:
TextView.setRequired(boolean)

getSize

public int getSize()
gets the size of the InputField. The size is measured in characters. Optical user agents try to fit the actual width and height to the size of the used font. Usually, user agents ignore this value if you set a width explicitly.

Returns:
the size of the InputField in characters

setSize

public void setSize(int size)
sets the size of the InputField. The size is measured in characters. Optical user agents try to fit the actual width and height to the size of the used font. Usually, user agents ignore this value if you set a width explicitly.

Parameters:
size - the size of the InputField in characters
See Also:
setWidth(String)

getMaxlength

public int getMaxlength()
gets the maximum length for the allowed input in characters Note: some user agents may ignore this setting. Furthermore if you use date or time fields you have to keep the locale specific formatting in mind.

Returns:
the maximum length for the input

setMaxlength

public void setMaxlength(int maxlength)
sets the maximum length for the allowed input in characters Note: some user agents may ignore this setting. Furthermore if you use date or time fields you have to keep the locale specific formatting in mind.

Parameters:
maxlength - the maximum length for the input

getMinlength

public int getMinlength()
gets the maximum length for the allowed input in characters Note: some user agents may ignore this setting. Furthermore if you use date or time fields you have to keep the locale specific formatting in mind.

Returns:
the maximum length for the input

setMinlength

public void setMinlength(int minlength)
sets the maximum length for the allowed input in characters Note: some user agents may ignore this setting. Furthermore if you use date or time fields you have to keep the locale specific formatting in mind.


isShowHelp

public boolean isShowHelp()
check if some kind of help should be displayed for the InputField

Returns:
true if help should be displayed

setShowHelp

public void setShowHelp(boolean showHelp)
sets if some kind of help should be displayed for the InputField

Parameters:
showHelp - true if help should be displayed

getFirstDayOfWeek

public int getFirstDayOfWeek()
Returns:
the first day of the week.

setFirstDayOfWeek

public void setFirstDayOfWeek(int firstDayOfWeek)
Parameters:
firstDayOfWeek - the first day of the week. Monday is 1, Sunday is either 0 or 7.

getDesign

public InputFieldDesign getDesign()
get the design to be used for the InputField

Returns:
the design

setDesign

public void setDesign(InputFieldDesign design)
set the design to be used for the InputField

Parameters:
design - the design

getWidth

public String getWidth()
get the width of the input field

Returns:
the width of the input field

setWidth

public void setWidth(String width)
set the width of the input field

Parameters:
width - the width of the input field

setLabeled

public void setLabeled(boolean isLabeled)
Description copied from interface: LabeledComponent
notify the component that a label has been assigned to it.

Specified by:
setLabeled in interface LabeledComponent

isLabeled

public boolean isLabeled()
Description copied from interface: LabeledComponent
checks if a label has been assigned to this component.

Specified by:
isLabeled in interface LabeledComponent

getValueEncode

public boolean getValueEncode()

setValueEncode

public void setValueEncode(boolean encode)

isShowValueHelp

public boolean isShowValueHelp()
check if this input filed has an associated value help application or not


setShowValueHelp

public void setShowValueHelp(boolean showValueHelp)
determines if the input field has a value help application associated with it or not


isRequiresValidation

public boolean isRequiresValidation()
returns if the inputfield requires validation

Specified by:
isRequiresValidation in interface IEventValidationComponent
Overrides:
isRequiresValidation in class EventValidationComponent

setRequiresValidation

public void setRequiresValidation(boolean requiresValidation)
determines if the inputfield requires validation

Overrides:
setRequiresValidation in class EventValidationComponent

getValueHelpContext

public ValueHelpContext getValueHelpContext()
returns the valueHelpContext


setValueHelpContext

public void setValueHelpContext(ValueHelpContext valueHelpContext)
sets the value help context


setParkInSession

public void setParkInSession(boolean parkInSession)

getParkInSession

public boolean getParkInSession()

getLabel

public Component getLabel()

setLabel

public void setLabel(Component label)

getHAlign

public HorizontalTextAlignment getHAlign()
gets the alignment to be used for rendering this InputField.

Returns:
the aligment for this InputField.

setHAlign

public void setHAlign(HorizontalTextAlignment align)
set the aligment to be used for rendering this InputField.

Parameters:
align - the design for this InputField.

getTextDirection

public ForcedTextDirection getTextDirection()
Gets the text direction for the component

Returns:
com.sapportals.htmlb.enum.ForcedTextDirection

setTextDirection

public void setTextDirection(ForcedTextDirection textDirection)
Sets the text direction for the component

Parameters:
textDirection - com.sapportals.htmlb.enum.ForcedTextDirection

setEnabled

public void setEnabled(boolean enabled)
enable/disable the inputfield

Specified by:
setEnabled in interface IEventValidationComponent
Overrides:
setEnabled in class EventValidationComponent
Parameters:
enabled -

isEnabled

public boolean isEnabled()
Description copied from class: EventValidationComponent
return if this button is currently disabled

Specified by:
isEnabled in interface IEventValidationComponent
Overrides:
isEnabled in class EventValidationComponent
Returns:
if the inputfield is enabled


Copyright 2006 SAP AG Complete Copyright Notice