javalinvue-example icon indicating copy to clipboard operation
javalinvue-example copied to clipboard

Feedback (pros, cons, comments)

Open tipsy opened this issue 5 years ago β€’ 42 comments

tipsy avatar Jul 31 '19 18:07 tipsy

Cons ... No transpiling (can’t use the latest JS features without code breaking in old browsers)

I wonder if you could use the maven-frontend-plugin (or something similar) to do this.

rgmz avatar Aug 09 '19 17:08 rgmz

I'm not sure. Since the JavaScript isn't exported as modules, I imagine it will have some trouble πŸ€”

tipsy avatar Aug 09 '19 21:08 tipsy

This looks terrific! I'm a part of a small team of full-stack devs. We love Vue.js on the front end and a JVM stack on the back-end. We've been feeling pain for a while in having this split across two systems. We've been looking into Java template engines (last experience was with jsps and Thymeleaf) but this could well be a winner!

In the article you still use a JSON API to fetch data for the render. Can I ask why? It seems like rendering with javalin shared data would work fine. Have you tried this for data other than auth and run into trouble?

stepbeekio avatar Feb 12 '20 12:02 stepbeekio

It's would work fine, but most of the apps I have are dynamic and will update data when you add/edit/delete. It's simpler to just have 1 way of loading data.

By the way, since I wrote this article I have started using the approach on two large projects at work without issue. It's making us very productive :)

tipsy avatar Feb 12 '20 17:02 tipsy

Im testing this approach now too for our next applications based on micro services. Im in my early testing phase, but its looking good for now. I will keep you updated. Thank you very much @tipsy

cwildfoerster avatar Mar 25 '20 14:03 cwildfoerster

Nice! Looking forward to see how it works for you.

tipsy avatar Mar 25 '20 14:03 tipsy

I just. experimented with the vue-router, doesn't require much work... but if you want to get the state... thats another issue ;-) I guess i will push the router approach a little further back

cwildfoerster avatar Mar 25 '20 16:03 cwildfoerster

For me the best part about the server side routing is that it renders the correct component on load, and that access management works the same as for the API.

tipsy avatar Mar 25 '20 17:03 tipsy

Yes, thats what i noticed too that i would have to duplicate the access restriction. What do you think about only including views into the componentRegistration that the user has access to, according to the access manager?

cwildfoerster avatar Mar 25 '20 18:03 cwildfoerster

I don't think that's required, the HTML itself shouldn't be sensitive. It would reduce the payload though, which is good :thinking:

tipsy avatar Mar 25 '20 19:03 tipsy

I have a fairly big angular project (100 components) that im planning on doing a rewrite, i really like what i saw on the tutorial. in your opinion is it suitable to use the approach for a big project?

unaor avatar Jun 16 '20 04:06 unaor

What browsers do you have to support?

tipsy avatar Jun 16 '20 06:06 tipsy

currently all the way down to IE8 but im trying to see whether it will be just chrome, firefox and edge

unaor avatar Jun 16 '20 12:06 unaor

Yeah, this would be a bad idea for IE8, but it works really well for modern browsers. 100 components sounds fine, I guess it depends a bit on how big they are. My current project has 49 components, which results in a payload of 29kb (in other words, not an issue).

tipsy avatar Jun 16 '20 13:06 tipsy

Thank you for writing this @tipsy, it has been a most enlightening read. Not only did you save me quite a bit of time, but convinced me Javalin deserves more than the cursory look I had given it.

After all these years it still impresses me how small libraries with just the right choices can often provide more value than huge behemoths. Thank you!

vlaate avatar Jun 17 '20 14:06 vlaate

I'm glad you like it! I guess Javalin is the result of doing "just enough" for a lot of years. It's gained some weight lately with the extra modules, but they very much optional :)

tipsy avatar Jun 17 '20 15:06 tipsy

Hello, is there a reason all .vue templates are always sent to the client (even login protected ones)? Isn't that kind of counter-productive?

1fexd avatar Jun 21 '20 15:06 1fexd

@gringofe If the templates were split based on roles it wouldn't be possible to cache the bundle anymore (you would have to rebuild everything for every request). Sensitive data shouldn't be put into static HTML/JavaScript files, you would have the same issue if you put sensitive data in your app.js in a "normal" JavaScript app.

It might be counter-intuitive though, we could include it as a config option?

tipsy avatar Jun 21 '20 15:06 tipsy

I don't think creating a config is necessary, I was just wondering if it's normal for all the files to be sent, since I am not doing a lot of frontend webdevelopment. btw, thank you for creating Javalin, it has been a pleasure working with it so far.

1fexd avatar Jun 21 '20 18:06 1fexd

I was just wondering if it's normal for all the files to be sent, since I am not doing a lot of frontend webdevelopment. btw, thank you for creating Javalin, it has been a pleasure working with it so far.

Happy to hear it!

tipsy avatar Jun 21 '20 19:06 tipsy

... for unit testing a web pack config could be created and you just run it as a separate process.

I'd be very interested to hear more about this if you manage to set it up.

tipsy avatar Jun 22 '20 13:06 tipsy

Hi, Thank you for this. I love the approach.

It's probably my lack of understanding how webjars work, but I have been unable to get it to work with any Vue or Vuetify components. For a simple example, in layout.html, I substitute

    <v-main id="main-vue" v-cloak> @routeComponent <v-main> 

for

    <main id="main-vue" v-cloak> @routeComponent <main> 

and get a javascript exception:

Cannot read property "bar" of undefined Found in ----> <VMain> <Root>

If I leave layout.html alone, I get similar errors trying to use any other Vue or Vuetify component in the template hierarchy. It would be great if the example went a little deeper and showed the use of Vue components rather than just HTML markup like

lwhite1 avatar Jan 08 '21 15:01 lwhite1

Hi @lwhite1, glad you like it!

There really isn't more to it than what is shown in the docs/example. Once you add a WebJar to your project you need to rebuild (using Maven/Gradle/your-tool-of-choice), then you need to include the static files from these WebJars in your <head> (you can include them other places too, but using <head> makes everything easier.

You can look at https://github.com/tipsy/kotlin-admin-template for a more complete example.

tipsy avatar Jan 09 '21 06:01 tipsy

Yes, you're right. It works ok, except that Vuetify doesn't see the icons and fonts it needs. Since it's material design, it's looking for Google's Roboto font and Google icons. The vuetify webjar doesn't seem to recognize them when they're brought in as standard links, or as webjars. I will see if I can follow the kotlin template code, (i'm using java) since that looks a little different. In any case, it's not a Javelin issue.

lwhite1 avatar Jan 09 '21 21:01 lwhite1

You probably just have to find the correct version if the mdi font. I can find it for you tomorrow!

tipsy avatar Jan 10 '21 04:01 tipsy

Got it using your template example. All set. Thanks much

On Sat, Jan 9, 2021 at 11:05 PM David [email protected] wrote:

You probably just have to find the correct version if the mdi font. I can find it for you tomorrow!

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tipsy/javalinvue-example/issues/1#issuecomment-757411111, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2FPASMYALRLFHB3ZDMHN3SZERQBANCNFSM4IIJPAHA .

lwhite1 avatar Jan 10 '21 04:01 lwhite1

Since im going to be adding some stuff about Vue3, i'd also like to put it forward that there is some kind of reloading for vue files now, just not for routes, so maybe put that as a pro now since its been fixed?

TareqK avatar Apr 10 '21 16:04 TareqK

How does the reloading work? πŸ€”

tipsy avatar Apr 10 '21 16:04 tipsy

Basically, if you use the rootDirectory in EXTERNAL mode, and Javalin is running in Dev mode(ie, requests from localhost or through a custom env variable), it always re-scans the files each request, kind of like it does in unit tests. I Use this often when developing apps(and since I usually dockerize, its no sweat off my back). I even do the same for static files(non-webjar), since i dont use inline files often and rely on those for style. Actually, when working purely on the front end, the only time i need to rebuild and run the server is when I add a web jar, and otherwise, i just refresh the page. I can add this to the docs, might make sense to throw this in the bottom around the "tips and tricks" section.

TareqK avatar Apr 10 '21 17:04 TareqK

The plugin has always supported that (I would die without it πŸ˜…), but hot-reload refers to updating the app without refreshing the page (so you won't have to recreate your state).

I will create a much richer docs page for the JavalinVue plugin soon, I will include that tip there :)

tipsy avatar Apr 10 '21 20:04 tipsy