I find very frustrating that everytime I take a look at the docs to learn any new concept or simply find some example or reference, no matter if it is a very simple concept or a more tricky one, I always stumble over the same stone, having to find a lot of things by trial & error instead of having them written down in the ·$)"%·$% manual.
For instance, today I’m trying to learn how to embed custom javascript in my own components.
First of all, I went to the CustomLayout reference, as although I never used it before I knew it was there and probably would fit to my purposes because I need to manipulate a concrete tag.
Well, nowhere in https://vaadin.com/docs/-/part/framework/layout/layout-customlayout.html could I find an example on how to load the .html file that is supposed to hold the layout. They say that “a template is a HTML file located under layouts folder under a theme folder under the /VAADIN/themes/ folder, for example, /VAADIN/themes/themename/layouts/mylayout.html”, and then that “A template can also be provided dynamically from an InputStream, as explained below”.
Well, there’s NO SINGLE PLACE ANYWHERE I CAN FIND explaining how are you supposed to initialize your layout with that file. There is an example below telling how to initialize the object… ¡with a new ByteArrayInputStream() with some inline HTML! And another one using a new FileInputStream(file). BUT NO SINGLE PLACE DOING SOMETHING LIKE new CustomLayout(“mylayout”) or “mylayout.html” or “layouts/mylayout” or “layouts/mylayout.html”. Go to the sampler (http://demo.vaadin.com/sampler/#ui/layout/custom-layout) and there, in the “Source” tab, they say that the custom HTML belongs to examplecustomlayout.html, but, AGAIN, YOU CAN’T FIND ANYWHERE HOW THEY LOADED THAT FILE: again, in the source code excerpt, they “load” “someething” with a sample = new CustomLayout(inputStream) (what an obsession with inputStream!), but they even don’t bother to write that “inputStream” is. Finally, you end trying many combinations in order to find if you can put an string with an html file name in the constructor (something that, to this moment, I still haven’t accomplished yet).
Then you go to the Javascript integration section (https://vaadin.com/docs/-/part/framework/gwt/gwt-javascript.html) and you decide that the approach of extending AbstractJavaScriptComponent seems to be the right one for you. They say that in the @JavaScript annotation you put the js files you want to use, and it is clear when it is an external one (you put the full url), but when it comes to place YOUR OWN js files (for instance, ({“mylibrary.js”})), again IT ISN’T STATED ANYWHERE WHERE YOU ARE SUPPOSED TO PLACE THOSE FILES. Should it be in the same folder where the corresponding java file is? Should it be in /VAADIN? in /WEB-INF? in some /js child folder of any of those prior two directories? WHY is it not stated anywhere? You do some googling in order to try to save some trial-and-erroring and you seem to find a reference in the Vaadin blog (https://vaadin.com/wiki?p_p_id=36&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=row-1&p_p_col_pos=2&p_p_col_count=4&_36_struts_action=%2Fwiki%2Fview&p_r_p_185834411_nodeName=vaadin.com+wiki&p_r_p_185834411_title=Integrating+a+JavaScript+component). But, again… amazingle… they don’t say that there neither! Oh wait; maybe there’s some source code of the example available. Look, they say something about “a repository with the code at https://github.com/aanno/More-Vaadin, directory Blog_2012-08-13” in the 1st comment (what a strange place to inform that the source code is available!); let’s take a look… Wait! The repository exists, but… THERE’S NO SUCH DIRECTORY and the example source code cannot be found anywhere. There are even some users in the comments complaining that they cannot be found. I will post a comment asking for them… Oh no! “The Vaadin Wiki is temporarily in read only mode due to large recent spam attacks”! Haven’t this message been on display for ages?
Well, we have one last chance before some even more trialanderroring. I will place my .js file wherever my gonades tell me and I will take a look at the source code to see if there is some path info added to the specified name. OH WAIT. “http://localhost:8080/app/APP/PUBLISHED/myFile.js”??? “/APP/PUBLISHED”??? Where in the filesystem am I supposed to find such a path???
It’s been an hour of trial & error and all I see in my Vaadin app is a message saying “Could not initialize JavaScriptConnector because no JavaScript init function was found. Make sure one of these functions are defined: com_my_fq_dn_myFile”, and yeah, that function exists in my file, but my file it’s still not found. Mix that with a silly upper/lowercase letter mistake and you’ll inter into infinite loop for ages.
Why? WHY these absurdities and inconsistences? Sum the hour I’ve already spent these rants and you’ll find why development with Vaadin is SOOOOOOO slow and frustrating. You have to resort to the forum to see if some frustrated user like has alread pulled his hair trying to find the answer, and usually what you find are posts from several years ago with such silly bugs that still hasn’t been fixed.
Instead of bombing with marketing email, discount offers, friendship requests, customer service agents while browsing the site and spam emails to addresses never been used to contact the Vaadin staff (yes, my boss even received a direct marketing email and we still haven’t figured out how they got the address because he wasn’t in the CC list), it would offer a far better image if these frustrating issues where addressed.