27. 1 find the server (DNS)
2 pass the local resource requested
28. 1 find the server (DNS)
2 pass the local resource requested
3 server loads the resource to be served
29. 1 find the server (DNS)
2 pass the local resource requested
3 server loads the resource to be served
4 resource sent back to the browser (client)
30. 1 find the server (DNS)
2 pass the local resource requested
3 server loads the resource to be served
4 resource sent back to the browser (client)
5 browser interprets the response
31. 1 find the server (DNS)
2 pass the local resource requested
3 server loads the resource to be served
4 resource sent back to the browser (client)
5 browser interprets the response
6 browser loads additional resources (+ requests)
32. 1 find the server (DNS)
2 pass the local resource requested
3 server loads the resource to be served
4 resource sent back to the browser (client)
5 browser interprets the response
6 browser loads additional resources (+ requests)
7 browser displays results
56. A web transaction
‣ Url request
- http://host:8080/entry/show?ac=P12345&format=fasta
57. A web transaction
‣ Url request
- http://host:8080/entry/show?ac=P12345&format=fasta
‣ Action
- build the model
58. A web transaction
‣ Url request
- http://host:8080/entry/show?ac=P12345&format=fasta
‣ Action
- build the model
‣ View generation
- html contents creation
59. A web transaction
‣ Url request
- http://host:8080/entry/show?ac=P12345&format=fasta
‣ Action
- build the model
‣ View generation
- html contents creation
‣ Rendering
60. A web transaction
‣ Url request [browser]
- http://host:8080/entry/show?ac=P12345&format=fasta
‣ Action [server]
- build the model
‣ View generation [server]
- html contents creation
‣ Rendering [browser]
63. Grails with STS eclipse
‣ Help > dashboard > extensions > Grails
64. Grails with STS eclipse
‣ Help > dashboard > extensions > Grails
‣ Download Grails
- http://grails.org/Download
65. Grails with STS eclipse
‣ Help > dashboard > extensions > Grails
‣ Download Grails
- http://grails.org/Download
‣ Uncompress in local directory
- e.g. ~/local/grails-1.3.7
66. Grails with STS eclipse
‣ Help > dashboard > extensions > Grails
‣ Download Grails
- http://grails.org/Download
‣ Uncompress in local directory
- e.g. ~/local/grails-1.3.7
‣ Configure Grails in STS preferences
- possible to host multiple versions
67. Grails with STS eclipse
‣ Help > dashboard > extensions > Grails
‣ Download Grails
- http://grails.org/Download
‣ Uncompress in local directory
- e.g. ~/local/grails-1.3.7
‣ Configure Grails in STS preferences
- possible to host multiple versions
‣ Reference
- http://grails.org/doc/latest/
68. Grails with STS eclipse (cont’d)
‣ Configure shortcut for grails command prompt
69. Grails with STS eclipse (cont’d)
‣ Configure shortcut for grails command prompt
‣ Preference > keys
> open grails command prompt
- <ctrl> <alt> G
- (maybe need to deactivate another shortcut)
70. Grails with STS eclipse (cont’d)
‣ Configure shortcut for grails command prompt
‣ Preference > keys
> open grails command prompt
- <ctrl> <alt> G
- (maybe need to deactivate another shortcut)
‣ Calling grails command on selected project
76. Launching the application
‣ Launch the server, either:
- Run As > Grails Command (run-app)
- <ctrl> <alt> G run-app↵
- command line (in the project folder): run-app
77. Launching the application
‣ Launch the server, either:
- Run As > Grails Command (run-app)
- <ctrl> <alt> G run-app↵
- command line (in the project folder): run-app
‣ Check console for messages
78. Launching the application
‣ Launch the server, either:
- Run As > Grails Command (run-app)
- <ctrl> <alt> G run-app↵
- command line (in the project folder): run-app
‣ Check console for messages
‣ With your browser:
- http://localhost:8080/eop.lec9.demo
85. New files and directories:
./grails-app/controllers/foo/HelloController.groovy
./test/unit/foo/HelloControllerTests.groovy
./grails-app/views/hello/
92. Invoking the controller
http://localhost:8080/eop.lec9.demo/hello
http://localhost:8080/eop.lec9.demo/hello/index
‣ No rendering is defined yet:
HTTP Status 404 - /eop.lec9.demo/WEB-INF/grails-app/views/hello/index.jsp
type Status report
message /eop.lec9.demo/WEB-INF/grails-app/views/hello/index.jsp
description The requested resource (/eop.lec9.demo/WEB-INF/grails-app/views/hello/index.jsp) is not available.
Apache Tomcat/6.0-snapshot
93. Invoking the controller
http://localhost:8080/eop.lec9.demo/hello
http://localhost:8080/eop.lec9.demo/hello/index
‣ No rendering is defined yet:
HTTP Status 404 - /eop.lec9.demo/WEB-INF/grails-app/views/hello/index.jsp
type Status report
message /eop.lec9.demo/WEB-INF/grails-app/views/hello/index.jsp
description The requested resource (/eop.lec9.demo/WEB-INF/grails-app/views/hello/index.jsp) is not available.
Apache Tomcat/6.0-snapshot
problem:
we must define the view
97. Another simple action
‣ Action = closure
class HelloController {
...
def withDate = {
def now = new Date()
render "Hello World at $now"
}
}
98. Another simple action
‣ Action = closure
class HelloController {
...
def withDate = {
def now = new Date()
render "Hello World at $now"
}
}
‣ http://localhost:8080/eop.lec9.demo/hello/withDate
Hello World at Mon May 03 02:38:03 CEST 2010
103. GSP by default
‣ One controller = one directory in grails-app/views
- foo.HelloController.groovy ➙ grails-app/views/hello/
104. GSP by default
‣ One controller = one directory in grails-app/views
- foo.HelloController.groovy ➙ grails-app/views/hello/
‣ One action = one .gsp file
- def index = {...} ➙ grails-app/views/hello/index.gsp
105. GSP by default
‣ One controller = one directory in grails-app/views
- foo.HelloController.groovy ➙ grails-app/views/hello/
‣ One action = one .gsp file
- def index = {...} ➙ grails-app/views/hello/index.gsp
‣ .gsp file:
- pure html
- dedicated tags
- model variables can be passed
106. A static gsp example
(content is always the same)
108. hello/index.gsp
<html>
<head>
<title>Hello world index page</title>
</head>
<body>
<h1>Welcome to hello world</h1>
<ul>
<li><a href="/eop.lec9.demo/hello/directText">
simple text hello</a></li>
<li><a href="/eop.lec9.demo/hello/withDate">
text with date</a></li>
</ul>
</body>
</html>
109. Absolute path are not good practice
use grails tag instead
<g:link controller=”...” action=”...”>
114. Passing data to the .gsp
‣ A new action returning map of values
def when = {
def now = new Date()
return [myTime:now]
}
115. Passing data to the .gsp
‣ A new action returning map of values
def when = {
def now = new Date()
return [myTime:now]
}
‣when.gsp
<body>
<h1>Current time is ${myTime}</h1>
We are <b>${myTime.seconds}</b> seconds past the
minute
<hr/>
<g:link controller="hello" action="index">
back home</g:link>
</body>
120. Passing arguments
‣http://.../hello/ago?nbdays=4
‣ Controller access parameters through map params
def ago = {
def now = new Date()
def d = now - (params.nbdays as Integer)
[currentTime:now, pastTime:d]
}
‣ago.gsp
Current time is ${currentTime}.
<br/>
It was ${pastTime}, ${params.nbdays} days ago
128. Passing arguments (cont’d)
‣ Within a user entered <form>
<g:form controller="hello" action="ago">
<!-- default value is the one
received from params.nbdays -->
<g:textField name="nbdays"
value="${params.nbdays}" />
<g:submitButton name="submit" value="new date"/>
</g:form>
129. Passing arguments (cont’d)
‣ Within a user entered <form>
<g:form controller="hello" action="ago">
<!-- default value is the one
received from params.nbdays -->
<g:textField name="nbdays"
value="${params.nbdays}" />
<g:submitButton name="submit" value="new date"/>
</g:form>
‣ The form is included here in the ago.gsp
130. Passing arguments (cont’d)
‣ Within a user entered <form>
<g:form controller="hello" action="ago">
<!-- default value is the one
received from params.nbdays -->
<g:textField name="nbdays"
value="${params.nbdays}" />
<g:submitButton name="submit" value="new date"/>
</g:form>
‣ The form is included here in the ago.gsp
‣ Could be in another gsp file (with a static default value)
new round starting web application\nGoal: to build a twitter like application\ntoday is an introduction to web application\n
\n
\n
\n
\n
\n
Pervert use of task to remember what you want to remember\n!!Moderate use of FIXME\n\n
Pervert use of task to remember what you want to remember\n!!Moderate use of FIXME\n\n
Pervert use of task to remember what you want to remember\n!!Moderate use of FIXME\n\n
ctrl F7\nof lower left button to open a view\nclose you projects\nview is just one box, a perspective (upper right corner) is a arrangement of views\nTasks on server: trac, mantis <-> tickets (bug, features etc.)\n
ctrl F7\nof lower left button to open a view\nclose you projects\nview is just one box, a perspective (upper right corner) is a arrangement of views\nTasks on server: trac, mantis <-> tickets (bug, features etc.)\n
ctrl F7\nof lower left button to open a view\nclose you projects\nview is just one box, a perspective (upper right corner) is a arrangement of views\nTasks on server: trac, mantis <-> tickets (bug, features etc.)\n
Example: your parse SwissProt from text format for getting AC and sequence, then, your are asked to read for splicing info => you text parsing get more and more complex\nJumping to xml parsing is an investment (you loose one day coming back to the same point), but you&#x2019;ll move faster further on.\n
Example: your parse SwissProt from text format for getting AC and sequence, then, your are asked to read for splicing info => you text parsing get more and more complex\nJumping to xml parsing is an investment (you loose one day coming back to the same point), but you&#x2019;ll move faster further on.\n
Example: your parse SwissProt from text format for getting AC and sequence, then, your are asked to read for splicing info => you text parsing get more and more complex\nJumping to xml parsing is an investment (you loose one day coming back to the same point), but you&#x2019;ll move faster further on.\n
html javascript css form\nanchor query argument\nGET/POST\nimages\nservlet CGI\najax flash\napache / tomcat\n\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Application is not a weekly TP just enforced by a series of test\nThe application must go public, to be used by the (lab) customer\nFind the easiest way to deploy you app\n
Install groovy, copy jars\nCall the scripts => teach your user\nWindows is catastrophic for command line\nHowever, script can be the solution for high volumes (biologist can learn...)\n
Griffon (swing based)\nStill need to install software on customer machine\nSoftware update to take into account (JNLP is a solution)\nFull access to the user&#x2019;s machine\nStandalone solution\n
GUI: Graphical User Interface\nEveryone has a browser\nnetwork is fast\nExample: gmail, google map etc.\nJavascript/Ajax turn the browser into a user friendly experience\nFlash: little limits compared to a native GUI (not on the iPhone/iPad family...). Can grant acces to the host computer resources\nEasy to deploy (everyone&#x2019;s connected)\nEasy updates\nCan install a server on the customer machines\n
\n
\n
\n
\n
\n
All the web application architecture is ready\nConfiguration at it simplest level (convention over configuration)\ndomain (database stored beans)\nplugin oriented to enrich the app\nSTS integration\n
High changing pace in the versions, keep up to date...\n
High changing pace in the versions, keep up to date...\n
High changing pace in the versions, keep up to date...\n
High changing pace in the versions, keep up to date...\n
High changing pace in the versions, keep up to date...\n
Version field is set automatically\n
a very common command call, so better configure it as a simple shortcut\n
a very common command call, so better configure it as a simple shortcut\n
a very common command call, so better configure it as a simple shortcut\n
equivalent to command line\nexport GRAILS_HOME=/path/to/installed/grails-x.y.z\nexport PATH=$PATH:$GRAILS_HOME/bin\ngrails create-app eop.lec9.demo\n
+ some optional directories\ntoday : only controller & view\n&#x201C;we&#x2019;ll see that later&#x201D; will be the most commonly used word today...\n\n
+ some optional directories\ntoday : only controller & view\n&#x201C;we&#x2019;ll see that later&#x201D; will be the most commonly used word today...\n\n
Port 80 by default http://localhost\nPort <1024 traditionally reserved to root\nModifying the code (to some extent) does not require to re-start the server (wait 2 seconds)\nIt is not possible to launch twice the application (port conflict). Must kill before relaunching if ever\n
Port 80 by default http://localhost\nPort <1024 traditionally reserved to root\nModifying the code (to some extent) does not require to re-start the server (wait 2 seconds)\nIt is not possible to launch twice the application (port conflict). Must kill before relaunching if ever\n
Port 80 by default http://localhost\nPort <1024 traditionally reserved to root\nModifying the code (to some extent) does not require to re-start the server (wait 2 seconds)\nIt is not possible to launch twice the application (port conflict). Must kill before relaunching if ever\n
Versions are displayed (grails, your application)\nList of plugins used by default (we&#x2019;ll add some more later)\n
\n
<ctrl><alt>G create-controller foo.hello \nDo not forget to refresh eclipse after each command line action (F5) or right-button > refresh\n\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Test is ready, but we&#x2019;re not yet there!\n
\n
Convention is the naming of file, instead of description in configuration files + class inheritance\n
Convention is the naming of file, instead of description in configuration files + class inheritance\n
Convention is the naming of file, instead of description in configuration files + class inheritance\n
Convention is the naming of file, instead of description in configuration files + class inheritance\n
index is by default (we&#x2019;ll see the configuration later)\n
index is by default (we&#x2019;ll see the configuration later)\n
No need to relaunch the application when you add action or controllers\n\n
No need to relaunch the application when you add action or controllers\n\n
\n
\n
\n
Before going to more complex action (we have not talked about parameters). let&#x2019;s make a tour on view\nText is maybe not always enough\nWhat do you know of html?\n\n
\n
This is a little bit too simplistic, as we can have in practice one GSP for multiple actions, or an action can be redirected towards one or another view depending on the context\n
\n
\n
\n
\n
\n
\n
actions directText & withDate do not have .gsp as they render directly text\n
actions directText & withDate do not have .gsp as they render directly text\n
\n
${...} extrapolate groovy expression (just as in a println statement)\nNote the link back to home page\nOf course, it is possible to pass more than one variable in the returned map\n
${...} extrapolate groovy expression (just as in a println statement)\nNote the link back to home page\nOf course, it is possible to pass more than one variable in the returned map\n
\n
\n
Parameters are passed as map of string\nNote that we can still access params within the gsp\n
Parameters are passed as map of string\nNote that we can still access params within the gsp\n
Parameters are passed as map of string\nNote that we can still access params within the gsp\n
\n
\n
\n
\n
\n
\n
\n
\n
One of the most commons software architecture design pattern\nShare responsibility among each components\nModel is far more than just some data exchanged between the controller and the view (we see that later)\n\n