CurrencyField
CurrencyField
is a subtype of a TextField designed for currency value input. CurrencyField
is used by default in screens generated by Studio for the attributes annotated with the @CurrencyValue
annotation. It has a currency symbol inside the field and is aligned to the right by default.
Component’s XML-name: currencyField
.
Basics
Basically, CurrencyField
repeats the functionality of TextField. You can manually set a datatype for the field, except that only the following numeric datatypes are supported:
-
decimal
-
int
-
long
-
double
-
float
CurrencyField
can be bound to a data container using the dataContainer
and property
attributes:
@JmixEntity
@Table(name = "UIEX1_PRODUCT")
@Entity(name = "UIEX1_Product")
public class Product {
@JmixGeneratedValue
@Column(name = "ID", nullable = false)
@Id
private UUID id;
@Column(name = "PRICE", nullable = false)
@CurrencyValue(currency = "USD")
protected BigDecimal price;
// ...
}
<data>
<instance id="productDc"
class="ui.ex1.entity.Product"
fetchPlan="_base"/>
</data>
<layout>
<currencyField id="priceField"
currencyLabelPosition="LEFT"
dataContainer="productDc"
property="price"/>
</layout>
Attributes
This component has three special attributes:
-
currency
- defines text that will be the content of the currency label.
-
currencyLabelPosition
- defines the position of the currency label inside the field. There are the following possible values:-
RIGHT
- to the right from the text input component. The default value. -
LEFT
- to the left from the text input component.
-
-
showCurrencyLabel
- defines whether the currency label should be displayed.
<currencyField id="currencyField"
currency="€"
currencyLabelPosition="LEFT"
showCurrencyLabel="true"/>
Events and Handlers
To generate a handler stub in Jmix Studio, select the component in the screen descriptor XML or in the Component Hierarchy panel and use the Handlers tab of the Component Inspector panel. Alternatively, you can use the Generate Handler button in the top panel of the screen controller. |
ValueChangeEvent
See ValueChangeEvent.
Validator
See Validator.
All XML Attributes
You can view and edit attributes applicable to the component using the Component Inspector panel of the Studio’s Screen Designer. |
align - box.expandRatio - buffered - caption - captionAsHtml - colspan - contextHelpText - contextHelpTextHtmlEnabled - conversionErrorMessage - css - currency - currencyLabelPosition - dataContainer - datatype - description - descriptionAsHtml - editable - enable - height - htmlSanitizerEnabled - icon - id - property - required - requiredMessage - responsive - rowspan - showCurrencyLabel - stylename - tabIndex - visible - width