Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
I have problem with subj layout. This is error in my browser, when I`m start my project:
"Layout file layouts/customlayout.html is missing. Components will be drawn for debug purposes."
Path to my .html file \WebContent\VAADIN\themes\reindeer\layouts\customlayout.html
<html> <table width="100%" height="100%"> <tr height="100%"> <td> <table align="center"> <tr> <td align="right">User name:</td> <td><div location="user"></div></td> </tr></table> </html>
Window mainWindow = new Window("MyApplication"); Panel panel = new Panel(); panel.setSizeUndefined(); CustomLayout layout = new CustomLayout("customlayout"); layout.addStyleName("customlayoutstyle"); panel.setContent(layout); TextField user = new TextField(); layout.addComponent(user, "user"); mainWindow.setTheme("reindeer"); mainWindow.addComponent(layout); mainWindow.addComponent(panel); setMainWindow(mainWindow);
Vaadin ver.6.4.8, AppServer: GlassFish Server 3.0.1
What is wrong? And how I can fix this problem?
You should use a custom theme with a different name than "reindeer" and add the custom layout html to that theme. If you use "reindeer" chances are that you serve the theme from the JAR through the servlet where there is no "customlayout.html"
Thanks for answer.
You should use a custom theme with a different name than "reindeer" and add the custom layout html to that theme.
I`m use usual <mytheme> (folder <mytheme> in \WebContent\VAADIN\themes with subfolder layouts where lay my customlayouts.html). . Using theme "reindeer" is my experiment.
You should also remove
You are trying to add the layout to two places at once, which typically should throw an exception but currently goes by undetected because of #6232
Ok! I`m fix my init() method:
Window mainWindow = new Window("MyApplication"); CustomLayout layout = new CustomLayout("customlayout"); TextField user = new TextField(); layout.addComponent(user, "user"); setTheme("my"); mainWindow.addComponent(layout); setMainWindow(mainWindow);
Path to my customlayout.html "\WebContent\VAADIN\themes\my\layouts"
Is it true? Also this is not worked: "Layouts file is missing".
I am having the exact same issue. I get a message: "CustomLayout not found: layouts/mylayout.html"
The css under my theme directory is getting picked up though.
I am using Vaadin 6.4.9.
Is there a workaround or is this a bug?
I am having the same issue, everything else in the my theme is working fine except the layouts. What could be the possible reason.
I am using the 6.5.0.
Try to set the theme before to create your CustomLayout:
setTheme("my"); Window mainWindow = new Window("MyApplication"); CustomLayout layout = new CustomLayout("customlayout"); TextField user = new TextField(); layout.addComponent(user, "user"); mainWindow.addComponent(layout); setMainWindow(mainWindow);
To setTheme("mytheme") before accessing custom layout is obvious thing. I am already doing it this way, even no progress ... :(
Though i can access my html file from browser with direct url i.e.
any suggestions ?
I also have that same issue after following the instructions in the Vaadin book at http://vaadin.com/book/-/page/layout.customlayout.html.
The HTML file is available with the full URL, but not rendered by Vaadin.
Looking at the com.vaadin.terminal.gwt.server.AbstractCommunicationManager, the following code on line 1084 shows that there's something to be implemented... (Vaadin 6.5.4)
... // FIXME: Handle exception logger.severe("CustomLayout not found: " + resource); ...
This prevents us from using the CustomLayout... Any help is greatly appreciated.
I don't quite know what the "Handle exception" refers to, but it should not be a problem, it probably refers to more proper reporting in error situation. CustomLayouts works OK as you can see in the Sampler and in the live Book examples.
You probably have some path or name problem. Remember that you should not normally give any path to the CustomLayout constructor, just the template name, without the ".html" suffix.
I can access the html file through the browser without any issues. Might the issue be related to the fact that I use a Maven project layout rather than a standard VAADIN directory structure?
My myLayout.html file is located at ./target/client-1.0-SNAPSHOT/WEB-INF/classes/VAADIN/themes/mytheme/layouts/myLayout.html.
The styles.css file located at ./target/client-1.0-SNAPSHOT/WEB-INF/classes/VAADIN/themes/mytheme/styles.css works fine.
Is there any hard-coded path to WebContent or similar?! Can't think of any other issue right now...
Yes, it could have something to do with the project structure or something. The VAADIN directory shouldn't be in the classes directory, as it's not loaded by the class loader, but in the root directory of the WAR. That should also be the case in Maven.
Actually, you shouldn't be able to access any files under the WEB-INF with browser, as the directory is a special one that is blocked from viewing.
You can see this Maven project, which has a templates located here. When I compile it to a WAR, the WAR will have the template file in "VAADIN/themes/sampler/layouts/examplecustomlayout.html" under its root directory.
In your case, it should be compiled to ./target/client-1.0-SNAPSHOT/VAADIN/themes/mytheme/layouts/myLayout.html.
The "WebContent" in Eclipse is simply the root directory of the packaged WAR.
There we go! Refactored my project structure according to the link you posted and it works now. Also, the HTML is no longer accessible, as you pointed out.
Use this folder structure.. (I am using it in eclipse)
[Your Project name]/[WebContent]/VAADIN/themes/sampler/layouts/[your layout without .html extension]
The Code :
CustomLayout custom = new CustomLayout("../../sampler/layouts/examplecustomlayout");
Hope this helps you. It worked for me. but it is not displaying the whole layout though..!! :rolleyes:
check this out for more ideas : https://vaadin.com/book/-/page/layout.customlayout.html
I created a ticket on trac for this issue: CustomLayout - cannot load html template from a jar
There's another possible workaround. You can load the layout from the classpath
InputStream layoutFile = getClass().getResourceAsStream("/VAADIN/themes/<yourtheme>/layouts/StandardMainLayout.html"); layout = new CustomLayout(layoutFile);
! Take care of the leading slash !
thx Tino, hlpd me really out.
For Maven user who hv no WebContent Folder use the src/main/resources and use Tinos hint -> that should do it.
This thread is 1 year old, is there a better way to do so by now?
For Maven, src/main/webapp corresponds to WebContent in Eclipse.
The ticket mentioned above should be fixed at some point, but is only an issue if the custom layouts come from a separate sub-project than the project using them and are packaged separately.
Since I migrated to Vaadin 7, I also have problems with CustomLayouts. I'm not sure it's exactly the problem described here, but it seems related to it.
I use a CustomLayout with the template name "host", and put the corresponding HTML file in VAADIN/themes/<mytheme>/layouts/host.html.
Worked well as long as this file was loadable by my custom layout class, but it broke when I removed the theme from my application project and packaged it into a separated bundle (with the error message mentionned in the first post).
What I don't understand is that the client-side application doesn't even try to load this file (I was expecting to see a failed request to this file in firebug, with a 404 error or something).
Anyway I checked and this host.html file accessible through a web browser.
Am I wrong to believe that when using a template name, the HTML file is directly loaded by the client?
If I am wrong, does that mean theme resources cannot be removed from the application (and for example, served statically)?