Take the Hello world for example, the content of view/index.html is:
When we click the first link, we are taken to the url http://localhost/hello/world, and the page says “hello world”.
What would Argo have done behind this?
Controller
Let’s turn to HelloController.java :
@Path annotation relates the url with the function hello(). And writer().write() writes the greeting “hello world”.
Is that how Argo works? Let’s go to the next example.
Post Example
Take the third url form.html for example, we filled the form, and post to the url post.html.
According to the @Path annotation, the java function is:
It get params from url params and forms, and add the name, value pair of them to the Model of beat object. And then returns a view post for displaying.
We followed to check post.html. The content is :
$company displays the value of the variable company. Exactly what is shown in the page the url that jumps to.
Velocity
From the document, we know that view is written by Velocity.
Now, we know that we can bind a url to a function, get parameters from url params or form, pass variables from back-end to the from-end by the member of Model in beat object, and display it in the front-end page by Velocity.
You may have heard of Model View Controler Pattern, which separate the business logic with front-end ui. Yes, this is exactly pattern that Argo follows.