1.Using Font Awesome Icons
First, I have downloaded FontAwesome into this folder:
"Deployed Resources"/webapp/frontend/font-awesome
Second, I have created file "common.css" in the folder
"Deployed Resources"/webapp/css
Third, in the file common.css, I make a reference to the font awesome dependencies. (in yellow)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <!-- Remember to import custom-style, which is included in the Polymer package --> <link rel="import" href="../bower_components/polymer/lib/elements/custom-style.html"> <!-- Font Awesome --> /*<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous" >*/ <link href="../font-awesome/css/all.css" rel="stylesheet"> <!--load all styles --> <custom-style> <style> .edu-login-header{ width: 100%; border-width:5px; border-bottom-style: solid; border-color: DodgerBlue; /*box-shadow: 10px 10px 5px LightGray;*/ /*box-shadow: 0px 1px 3px Blue;*/ } |
You can see that a commented link to the URL of the font awesome web is also shown.
Fourth, you can refer to it as
1 2 3 4 5 6 7 8 | /** * "fas fa-key" * @param fontAwesomeIcon (example "fas fa-key") * @return */ public static Html getFontAwesome(String fontAwesomeIcon) { return new Html("<span class=\""+fontAwesomeIcon+"\"></span>" ); } |
You can add the generated Html element to a container like a VerticalLayout. for instance
1 2 | VerticalLayout vl= new VerticalLayout(); vl.add(getFontAwesome("fas fa-key"); |
2. Problems with java primitives with converters in binder. NOT SOLVED!!!!
There is a problem trying to uses converter with primitive typesfor instance, here is a class (MyBean) with a field ok that is boolean (the primitive type). The converter fails to convert from string to the primitive type boolean, as it converts from string to Boolean class. Problems with wrappers in Java!!
1 2 3 4 | binder .forField(okCkeckbox) .withConverter(new StringToBooleanConverter("must be boolean") .bind(MyBean::getOk, MyBean::setOk); |
To solve this I have tried (without any luck!!!) to create a "setter" method of the class to pass a Boolean parameter
1 2 3 | public void setOk(Boolean okValue) { this.ok=okValue.booleanValue(); } |
3. Problems with NULL bean fields values in a binder.
Try using "withNullRepresentation("") " in the binder (where "" indicates a void value for replacing nulls)1 2 3 4 5 | binder .forField(okCkeckbox) .withNullRepresentation("") .withConverter(yourConverter) .bind(MyBean::getOk, MyBean::setOk); |
Take into account that this is NOT valid for LocalDate class using a DatePicker ! Don't use "withNullRepresentation("") " when binding LocalDate to a SatePicker field!