Using the FontAwesome enumeration

Hi,

How would one use the FontAwesome enumeration? I would like to provide an icon selector to my users but I seem to be unable to.

As a start, I tried to add a default icon value using the enumeration com.vaadin.server.FontAwesome. Through the IDE I’ve added an appropriate import but during compilation I get the errors below:

:app-global:compileJavaC:\Users\...\entity\Chapter.java:8: error: package com.vaadin.server does not exist
import com.vaadin.server.FontAwesome;
^
C:\Users\...\entity\Chapter.java:26: error: package FontAwesome does not exist
protected String chapterIcon = FontAwesome.LIST_ALT.name();
^

Is there any recommended approach to using the enumeration for FontAwesome?

Hi,

FontAwesome like any other Vaadin class is available only from the web module. So you can’t use it within entity class. If you want to define the default value for the entity attribute you can set it either in the entity class (just a constant string, without using the FontAwesome enumeration) or in the initNewItem method of the entity editor controller (using the FontAwesome enumeration if the screen in the web module)

1 Like

Hi,

Thanks, I should have thought of that. Now, to apply it on the UI (in the web module), do I need to create a custom component that has the options set to this enum or is it possible to configure this in the screen xml directly?

As the FontAwesome enum doesn’t implement com.haulmont.chile.core.datatypes.impl.EnumClass you have to define options in the screen controller (for instance, for the LookupField component using setOptionsList or setOptionsMap).

1 Like