Hi Jet, is your CSS styled defined in custom-form-layout.html or a global style sheet? If it’s the latter you should be ok (assuming of course, that the global style sheet is imported elsewhere).
Also you may want to put src/ or frontend:// in the htmlimport to make sure Vaadin is looking in the right place:
From HtmlImport.class:
Note that you should (almost) always use URLs starting with frontend:// so that the framework can resolve the files to either VAADIN/frontend/es5 or VAADIN/frontend/es6 depending on if the browser supports ES6 classes (most browers) or not (IE11 and Safari <= 9). Polymer elements rely on importing dependencies using relative paths ../../other-element/other-element.html, which will not work if they are installed in different locations.
HTML imports are added to the page after any @JavaScript dependencies added at the same time.
Example: @HtmlImport("frontend://paper-slider/paper-slider.html") on the class com.example.MyConnector would load the file http://host.com/VAADIN/frontend/es[56]
/paper-slider/paper-slider.html before the init() method of the client side connector is invoked.
Martin Israelsen:
Hi Jet, is your CSS styled defined in custom-form-layout.html or a global style sheet? If it’s the latter you should be ok (assuming of course, that the global style sheet is imported elsewhere).
Also you may want to put src/ or frontend:// in the htmlimport to make sure Vaadin is looking in the right place:
From HtmlImport.class:
Note that you should (almost) always use URLs starting with frontend:// so that the framework can resolve the files to either VAADIN/frontend/es5 or VAADIN/frontend/es6 depending on if the browser supports ES6 classes (most browers) or not (IE11 and Safari <= 9). Polymer elements rely on importing dependencies using relative paths ../../other-element/other-element.html, which will not work if they are installed in different locations.
HTML imports are added to the page after any @JavaScript dependencies added at the same time.
Example: @HtmlImport("frontend://paper-slider/paper-slider.html") on the class com.example.MyConnector would load the file http://host.com/VAADIN/frontend/es[56]
/paper-slider/paper-slider.html before the init() method of the client side connector is invoked.
Hi Martin, What do you mean by defined in my custom-form-layout.html?
Hi Martin, What do you mean by defined in my custom-form-layout.html?
Hi Jeff, I was referring to the content of custom-form-layout.html. Is that you have in the second source code?
Hi Martin, yes… But I finally get to understand it after reading this https://github.com/vaadin/vaadin-themable-mixin. It seems that each vaadin component have different approach since I was able to find a work around for the Vaadin Grid previously. I have no idea about this local CSS and Shadow DOM.
Jet, the vaadin-form-item element doesn’t have a label part defined. So you cannot use [part~="label"] . That would work for a vaadin-text-field theme (theme-for=“vaadin-text-field”) but not for vaadin-form-item. Since you are using the FormLayout.addFormItem(Component, String) method, the label is put inside a label which means you can easily use something like this:
Any label element would change though, but you can fix that by adding a custom CSS class name if needed. In that case, you should use the FormLayout.addFormItem(Component, Component) method:
TextField firstName = new TextField();
Label firstNameLabel = new Label("First name");
FormLayout form = new FormLayout();
form.addFormItem(firstName, firstNameLabel);
Keep in mind that you should use something like @HtmlImport("frontend://styles/some-styles-file.html") in your Java class if your HTML file is in the src/main/webapp/frontend/styles/ directory.
Vaadin 14 has two modes: Compability mode and Npm mode.
Compability mode supports Polymer 2 and Html imports. It’s mainly meant for people who are migrating their app from earlier versions like Vaadin 13 which also used Polymer 2 and Html imports. If you have a custom Polymer 2 component, you might want to use Compatibility mode until you get the chance to migrate it to Polymer 3. You can read more about compatibility mode here: https://vaadin.com/docs/v14/flow/v14-migration/v14-migration-guide.html#compatibility-mode
Npm mode is the new default and it’s using Polymer 3 as the client side component library. In Npm mode, Html imports are no longer supported; you import web components or Polymer templates as @JsModule instead.
My Vaadin 14 app works perfectly fine on chrome. On Safari, it does not load and is giving Typeerror(screenshot attached).
And ofcourse, the page does not load css and is not pretty. Any guidance here would be much appreciated.