public static interface FormItem.StateCustomizer
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCustomState(FormItemElementType elementType,
java.lang.String derivedState,
FormItem formItem)
Implement this method to retrieve a custom state suffix to append to the style name that is applied to some element of a formItem.
|
java.lang.String getCustomState(FormItemElementType elementType, java.lang.String derivedState, FormItem formItem)
FormItemBaseStyle
for more information on how state-based FormItem style names are derived.
If a FormItem has a StateCustomizer
, the framework will call its getCustomState()
method, passing in
the state suffix it has derived. Your getCustomState() implementation can make use of this derived state or ignore it. For example,
if you wanted two different types of focus styling depending on some factor unrelated to focus, you would probably make use of the
incoming "Focused" state and return something like "Focused1" or "Focused2". On the other hand, if you want your custom state to
just override whatever the system derived, you would ignore the incoming state. Finally, if you do not wish to provide a custom
style for this formItem element at this time - for example, you are only interested in providing a custom "textBox" style and this
call is for a "cell" element type - your getCustomStyle() method should just return the state it was passed.
StateCustomizers are advanced usage, and you should only use them if you have specialized styling requirements. If you do use a StateCustomizer, note that its getCustomState() method will be called very frequently, from rendering code: if your custom logic does significant processing, it could introduce a system-wide performance problem.
elementType
- The element type to return a custom state forderivedState
- The state suffix the system derivedformItem
- The FormItem we are deriving state for