Wisdom, an awesome java web framework
Not long ago, an other friend of mine told me about Wisdom and finally, yesterday, I decided to give it a try. And the first few minutes of use, I had this strange feeling that I had found My Framework!
The use I made of this tool (since yesterday, remember) is probably not orthodox, but I hope it will make you want to go deeper.
I know, my English is creepy, but i try to improve it :).
Above all, the installation
You need Java 7+ (Java 8 is also supported
\o/) and a recent version of Maven (3.2.1+). And there is nothing to install because the
mvn command of Wisdom build process will download everything (remember, I’m a lazy man ;))
So, create a project
I’m working with OSX and Linux, but you can find more details here (even for Windows developers): http://www.wisdom-framework.org/reference/0.6.1/index.html# _your_first_wisdom_project.
Type this command in a terminal to create a new project:
mvn org.wisdom-framework:wisdom-maven-plugin:0.6.1:create \ -DgroupId=bob \ -DartifactId=bob \ -Dversion=1.0-SNAPSHOT \ -Dpackage=org.k33g.bob
remark: you have to replace
org.k33g.bob with your own data.
The command geberate a directory (
bob for me) and project, and now you can open it with your preferred IDE.
And launch this to run your application:
cd bob mvn wisdom:run
Wisdom load all what he needs and then you can open your browser to: http://localhost:9000.
The structure of the project is like that:
We change only the value of the
- Remark : when you call http://localhost:9000/welcome,
This is the first magic trick!!! Hor reload!, thanks to the watch mode, Wisdom picks up all your code changes immediately! Nice!
Create our own controller and the associated template
I just want a simple html home page. So, create a simple controller
- Remark : when you call http://localhost:9000,
Note this, we’ve declared a
Template object :
index, then we’ve to create a template :
- Remark 1: Wisdom uses Thymeleaf Template Engine.
- Remark 3: We’ll see how not to use WebJars, but later.
When you’ve saved your two files, you can just verify that all is OK: just refresh http://localhost:9000. Easy, no!?
Create a Json service
Create a new controller
You have to save your java file, and now go to http://localhost:9000/humans with your browser, and you’ll get this:
So, you can modify
I’ve only added a list
Playing with Wisdom and Polymer
I’m a big fan of Polymer, but I need all “core elements” and I’ve not found the necessary webjar for them. First, stop your application, we have to modify
pom.xml file, and it requires relaunching the watch mode.
you can delete jQuery webjar dependency too:
And you can restart your project (
Remark: you need Bower then npm then Nodejs.
Inside this directory:
src/main/resources/assets/, create 2 files :
bower.json with these contents:
And type this command:
bower install. It will create a sub-directory
bower_components with all necessary dependencies to play with Polymer (include jQuery).
Inside this directory:
src/main/resources/assets/, create a new sub-directory :
components with a new file
humans-list.html with this code:
And go to
index.thl.html again, and modify it like this:
<ul></ul> and replace it with
change jQuery reference and add polymer platform reference
add reference to our new WebComponent
remove jQuery ajax call
Refresh your page:
I think I’ve found THE Best Candidate to serve my Single Page Applications :)Tweet