MField

Description

A MField is an input field widget. As a MonoiDataComponent, it supports data binding with a context.

MField adapts its behavior according to the given data type (for instance Integer,Currency, Hour, Email, Date and so on).

It is possible to link a data formatter to it in order to display the value in a specific way.

Parameters of MField can be given to the constructor or configured with the setters (before calling build()).

For the font, the string parameter must conform to the following rules. There are 3 semicolon (;) separating parameters : style, type and height.

  • style : possible values are BOLD, NORMAL and ITALIC or a combination of the 3 separated by | caracter. Ex: style=BOLD|ITALIC
  • type : possible values are Arial, Courier new, Tahoma, ...
  • height : an integer representing the number of pixels for the height of the characters.
  • Full example : "style=NORMAL;type=Tahoma;height=9"

An example

 1    //An example of field with String type
 2    MField nameField = new MField(container, "Name :", "person.name", 15, true);
 3    nameField.setWidth(50);
 4
 5    //An example of field with Date type
 6    MField dateField = new MField(container, "Birth date : ", "person.birthDate", DataType.DATE);
 7
 8    //a special formatter for the dateField (note than a default one would have been activated anyway)
 9    DateFormatter formatter = new DateFormatter(dateField);
10    formatter.setDateFormat("dd/MM");
11    dateField.setFormatter(formatter);
12
13    //An example of field with Hour type
14    MField timeField = new MField(container, "Time : ", "person.hour", DataType.HOUR);
15
16    //An example of field with Email type
17    MField emailField = new MField(container, "Email : ", "person.email", DataType.EMAIL);
18
19    //a new column
20    container.newColumn();
21
22    //An example of field with Integer type
23    MField ageField = new MField(container, "Age :", "age", DataType.INTEGER);
24
25    //An example of field with Double type
26    MField weightField = new MField(container, "Weight :", "person.weight", DataType.DOUBLE);
27    weightField.setMessage("Enter weight in kg");
28
29    //An example of field with Currency type
30    MField salaryField = new MField(container, "Salary :", "salary", DataType.CURRENCY);
31    salaryField.setMessage("Month salary in €");

API

  • Constructors
MField(MonoiContainer container, String label, String dataPath) Constructs a new instance of this class given its container, label, data's path
MField(MonoiContainer container, String label, String dataPath,boolean required) Constructs a new instance of this class given its container, label, data's path ,requirement of data
MField(MonoiContainer container, String label, String dataPath,IDataType type) Constructs a new instance of this class given its container, label, data's path ,data's type
MField(MonoiContainer container, String label, String dataPath,IDataType type, boolean required) Constructs a new instance of this class given its container, label, data's path ,data's type,requirement of data
MField(MonoiContainer container, String label, String dataPath,IDataType type, boolean required, String labelFontInfo) Constructs a new instance of this class given its container, label, data's path ,data's type,requirement of data, font's information
MField(MonoiContainer container, String label, String dataPath,IDataType type, Integer widthInChars) Constructs a new instance of this class given its container, label, data's path ,data's type,width of chars
MField(MonoiContainer container, String label, String dataPath,IDataType type, Integer widthInChars, boolean required) Constructs a new instance of this class given its container, label, data's path,data's type, width of chars,requirement of data
MField(MonoiContainer container, String label, String dataPath,IDataType type, String labelFontInfo) Constructs a new instance of this class given its container, label, data's path ,data's type, font's information
MField(MonoiContainer container, String label, String dataPath,Integer widthInChars) Constructs a new instance of this class given its container, label, data's path width of chars
MField(MonoiContainer container, String label, String dataPath,Integer widthInChars, boolean required) Constructs a new instance of this class given its container, label, data's path,width of chars ,requirement of data
MField(MonoiContainer container, String label, String dataPath,String labelFontInfo) Constructs a new instance of this class given its container, label, data's path , font's information
  • Methods
void addInputDelegate (IInputDelegate inputDelegate) Adds an inputDelegate
void clear() Clears Mfield's value
MFieldActionSet getActions() Gets the action's set of MField
String getDisplayPath() Gets the displayPath
IMonoiFormatter getFormatter() Gets a formatter
int getInputMaxLength() Gets the max length of input
IFieldControl getControl() Gets the field's control
Control getInternalControl() Gets the internal control
Alignment getLabelAlign() Gets the label's alignment
Image getLabelImage() Gets the label's image
Alignment getLabelPosition() Gets the label's position
String getLabelText() Gets the label's text
int getLabelWidth() Gets the label's width
int getStyle() Gets the field's style
String getText() Gets the field's text
TextSuggestion getTextSuggestion() Gets a text of suggestion
String getTooltipText() Gets a text of tooltip
Object getValue() Gets the field's value
String getValueDisplayPath() Gets value's displayPath
boolean getVisibility() True if visibility
Integer getWidth() Gets the field's width with pixel
Integer getWidthInChar() Gets the field's width with char
boolean isAlwaysDisabled() True if alwaysDesable
boolean isDefaultLabelSize() True if defaultlabelSize
boolean isEditable() True if editable
boolean isEnabled() True if enable
boolean isFormated() True if formated
boolean isMultiLine() True if multiline setted
boolean isRequired() True if requirement of not null
boolean isValid() True if input's data is valide
boolean isVisible() True if visible
void setAlwaysDisable(boolean alwaysDesable) Sets alwaysDisable
void setButtonText(String buttonText) Sets the button's text
void setDataType(IDataType defaultDataType) Sets the data's type
void setDefaultLabelSize (boolean defaultLabelSize) Sets the default's labelSize
void setDisplayPath(String displayPath) Sets the displayPath
void setEditable(boolean isEditable) Sets Editable
void setEnabled(boolean enabled) Sets Enabled
void setFormatter (IMonoiFormatter formatter) Sets a formatter
Void setInputDelegate (IInputDelegate mgr) Sets a inputDelegate
void setInputMaxLength(final int inputMaxLength) Sets the max length of input
void setLabelAlign(Alignment align) Sets the labelAlignment
void setLabelFont(String fontInfo) Sets the label's font
void setLabelWidth(int labelWidth) Sets label's width
void setMessage(String helpMessage) Set a message as a text of tool tip
void setMultiLine(boolean multiLine) Sets MultiLine
void setRangeLength(final int minLength, final int maxLength) Sets the range of length
void setRequired(boolean isNotEmpty) Sets the requirement of not null
void setTextSuggestion (TextSuggestion textSuggestion) Sets the suggestion's text
void setTypeDescriptor (IFieldTypeDescriptor type) Sets a type's descriptor
void setValue(Object value) Sets a value to show
void setVisibility(boolean visibility) Sets visibility
void setVisible(boolean visible) Sets a component to be visible
void setWidth(int width) Sets the width of field
void setWidthInChar(Integer widthInChar) Sets the width of field with char
String toString() Gets the Component's value of String
  • See also superclasses :
    • MonoiComponent and MonoiDataComponent

MField.jpg (22 kB) Frédéric ESNAULT, 02/27/2012 11:59 am