Groovy: Efficiency Oriented ProgrammingLecture 10Master Proteomics & Bioinformatics - University of GenevaAlexandre Massel...
Agenda‣ SVN & google code hosting‣ More on GSP‣ Including third parties libraries‣ Ajax‣ Runtime environment‣ Domains
SCM‣ Code evolve in time
SCM‣ Code evolve in time‣ Source code is shared
SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning
SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning‣ Many solutions exis...
SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning‣ Many solutions exis...
SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning‣ Many solutions exis...
SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning‣ Many solutions exis...
make an google account
Create ProjectProject name: geop-demoProject summary: A demo project for GEOP courseProject description: geop demo codeVer...
Google proposes command line commandsWe’ll see how to integrate svn into eclipse
Command-line accessIf you plan to make changes, use this command to check out the code as yourself using HTTPS:# Project m...
Google code offers for “free”‣ SVN repository
Google code offers for “free”‣ SVN repository‣ Managing contributors to a project
Google code offers for “free”‣ SVN repository‣ Managing contributors to a project‣ Wiki
Google code offers for “free”‣ SVN repository‣ Managing contributors to a project‣ Wiki‣ Ticketing system
Google code offers for “free”‣ SVN repository‣ Managing contributors to a project‣ Wiki‣ Ticketing system‣ Bug reporting
Google code offers for “free”‣ SVN repository‣ Managing contributors to a project‣ Wiki‣ Ticketing system‣ Bug reporting‣ ...
Google code hosting           ⇒your code is open source
SVN: eclipse or command line
Installing svn in Eclipse‣ Help > dashboard > extension  - Subversion (subclipse)
Installing svn in Eclipse‣ Help > dashboard > extension  - Subversion (subclipse)‣ Or command line: installed by default o...
Eclipse: connecting to the SVN repository‣ menu Window  - > open perspective  - > SVN repository exploring
Eclipse: connecting to the SVN repository‣ menu Window  - > open perspective  - > SVN repository exploring‣ view SVN repos...
Sharing an existing project to your google code account
Sharing an existing project to your google code account‣ Perspective java
Sharing an existing project to your google code account‣ Perspective java‣ project right-click  - > team  - > share projec...
‣ username & password from google page‣ save password check box
Commit the project‣ At this stage, the project is only created on the remote server  - check with SVN repository exploring...
Commit the project‣ At this stage, the project is only created on the remote server  - check with SVN repository exploring...
Commit the project‣ At this stage, the project is only created on the remote server  - check with SVN repository exploring...
All eclipse functionalitiescan be replaced by shell commands
SVN command line: share project‣ Import original project demo.svn to the repository‣ cd workspace directory svn import -m ...
SVN command line: share project                 (cont’d) cd demo.svn‣ Add target/ directory to svn:ignore svn propset svn:...
Browse your project
From google code source page                               25
SVN for a daily use
SVN for a daily use        minutely
SVN: flow use‣ Checkout out or share an existing project to contribute
SVN: flow use‣ Checkout out or share an existing project to contribute‣ Commit changes to the repository
SVN: flow use‣ Checkout out or share an existing project to contribute‣ Commit changes to the repository‣ Update changes f...
SVN: flow use‣ Checkout out or share an existing project to contribute‣ Commit changes to the repository‣ Update changes f...
SVN: flow use                                    (cont’d)‣ Command linesvn statussvn updatesvn commit -m “my message to de...
Commit/update often
SVN is more‣ History
SVN is more‣ History‣ See contribution from others
SVN is more‣ History‣ See contribution from others‣ Tag / branch versions
SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution
SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution‣ Continuous integration / t...
SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution‣ Continuous integration / t...
SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution‣ Continuous integration / t...
SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution‣ Continuous integration / t...
Back to grails... and proteins isoforms
Problem: uniprot AC ➙ isoform list       in a web application
Grails: including a third parties libraries‣ Library is available as a jar (export ➙ .jar)
Grails: including a third parties libraries‣ Library is available as a jar (export ➙ .jar)‣ Copy jar in lib/
Grails: including a third parties libraries‣ Library is available as a jar (export ➙ .jar)‣ Copy jar in lib/‣ For eclipse ...
Get is forms for ac (00:44:01.975)Q70Z44List>Q70Z44-1MQKHSPGPPALALLSQSLLTTGNGDTLIINCPGFGQHRVDPAAFQAVFDRKAIGPVTNYSVATHVNISF...
Isoforms_v1 -> v5 same controller        different views (gsp) for different rendering interaction
Isoforms_v1 -> v5 same controller        different views (gsp) for different rendering interaction
Isoforms_vXController                  ⇒views/isoforms_vX/ direcgtory with gsp’s
IsoformController_v?.groovy def list = {  def ac=params.ac   def xml=new XmlSlurper()             .parseText("http://pir.u...
v1
isoforms_v1/list.gsp<html>  <body>    <h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2>    <...
Problem: direct access to /list only
v2
v2
isoforms_v2: add index.gsp<html>  <body>    <h1>Isoform list application</h1>    <h2>Get is forms for ac (${String.format(...
Problem: <g:form> is duplicated (DRY!)
isoform_v3: use template‣ _form.gsp<h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2><g:form ...
isoform_v3: use template‣ _form.gsp<h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2><g:form ...
isoform_v3: use template‣ _form.gsp<h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2><g:form ...
Problem: all the page is reloaded totally
v4
Ajax: asynchronous load                          web browserQ70Z44           submit                        server         ...
Ajax: asynchronous load                          web browserQ70Z44           submit                        server         ...
Ajax: asynchronous load                                            web browserQ70Z44                         submit       ...
isoform_v4/index.gsp<html>  <head>    <g:javascript library="prototype" />  </head>  <body>    <h2>Get is forms for ac (${...
isoform_v4/list.gsp<h3>List</h3><g:each in="${proteins}" var="prot">  <pre>${prot}   </pre></g:each>
Twitter 1
People post messages and follow others
database (domain)+ controller (actions)   + views (web)
Domain: Person & Message
Domain: bean definition + database storage
Person domain‣ Create the database entry + bean class       grails create-domain-class Person project > right-click > grai...
Person domain‣ Create the database entry + bean class       grails create-domain-class Person project > right-click > grai...
Person.groovy‣ Created class package eop.lec10.twitter class Person {     static constraints = {     } }
Person.groovy
Person.groovy‣ Enriched with fields package eop.lec10.twitter class Person {     String username     String firstName     ...
run-app ⇒ database + table created
Web access: need controller + views
Scaffolding is pure magic
PersonController.groovycreate-controller Person
PersonController.groovycreate-controller Person‣ grails-app/controller/PersonController.groovy:package eop.lec10.twittercl...
PersonController.groovy create-controller Person‣ grails-app/controller/PersonController.groovy: package eop.lec10.twitter...
PersonController.groovy create-controller Person‣ grails-app/controller/PersonController.groovy: package eop.lec10.twitter...
http://localhost:8080/eop.lec10.twitter/person‣ Default url is redirected on the list page
http://localhost:8080/eop.lec10.twitter/person‣ Default url is redirected on the list page
http://localhost:8080/eop.lec10.twitter/person‣ Entering a new Person lucky luke
http://localhost:8080/eop.lec10.twitter/person‣ Entering a new Person lucky luke
http://localhost:8080/eop.lec10.twitter/person‣ Entering a new Person lucky luke
http://localhost:8080/eop.lec10.twitter/person
http://localhost:8080/eop.lec10.twitter/person‣ Back to list  - view all  - edit  - delete  - sort
Domain constraints
Person.groovyclass Person {    String username    String firstName    String lastName    String email    Date dateCreated ...
groovy & grails - lecture 10
groovy & grails - lecture 10
groovy & grails - lecture 10
groovy & grails - lecture 10
groovy & grails - lecture 10
groovy & grails - lecture 10
groovy & grails - lecture 10
groovy & grails - lecture 10
Upcoming SlideShare
Loading in...5
×

groovy & grails - lecture 10

450

Published on

SVN & google code hosting
More on GSP
Including third parties libraries
Ajax
Runtime environment
Domains

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
450
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • for non-Cuban...\n
  • for non-Cuban...\n
  • for non-Cuban...\n
  • for non-Cuban...\n
  • for non-Cuban...\n
  • for non-Cuban...\n
  • \n
  • we could use other SCM, but svn is more evolved than cvs, widely used, offered by google code, integrated in eclipse or on command line\n
  • \n
  • \n
  • \n
  • \n
  • no trunk/\nacceptpermently\n
  • no trunk/\nacceptpermently\n
  • no trunk/\nacceptpermently\n
  • no trunk/\nacceptpermently\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • as soon as test work, for example\nseveral time a day\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • eop 6-solutions -&gt; jar with build.xml\n
  • eop 6-solutions -&gt; jar with build.xml\n
  • eop 6-solutions -&gt; jar with build.xml\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • _ in file name, but not in template tag attribute\n
  • _ in file name, but not in template tag attribute\n
  • _ in file name, but not in template tag attribute\n
  • Although the form part does not change\nLimited here for the volume, but can be much more heavy\n
  • \n
  • Asynchronous javascript and xml\n
  • Asynchronous javascript and xml\n
  • Asynchronous javascript and xml\n
  • Asynchronous javascript and xml\n
  • Asynchronous javascript and xml\n
  • \n
  • \n
  • \n
  • test=test\ndevelopment=run-app\nproduction=packaged and deployed\n
  • We can change, if you have access to the web during development\n
  • \n
  • \n
  • \n
  • \n
  • def uniprotXmlService in controller will point directly to this bean\n
  • to change from proteins problems...\n
  • problem is simple yet illustrates plenty of aspects of a web application\ngrails: twitter in 40 minutes springsource webinar\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • more fields with whatever classes are possible are possible\n
  • but not very useful\nindeed, you can make SQL call\n(memory DB by default, but we&amp;#x2019;ll see how to put on file, postgres, mySql...)\n
  • list, add, delete, update...\n
  • \n
  • we&amp;#x2019;ll see how to generate explicitly all of them later in order to be modified\n
  • we&amp;#x2019;ll see how to generate explicitly all of them later in order to be modified\n
  • we&amp;#x2019;ll see how to generate explicitly all of them later in order to be modified\n
  • we&amp;#x2019;ll see how to generate explicitly all of them later in order to be modified\n
  • \n
  • \n
  • \n
  • \n
  • unique username with given characters\nemail valid\nnon empty first name\n
  • more fields with whatever classes are possible are possible\n
  • Next time: foreign key (Person &lt;-&gt; Person &lt;-&gt; Message)\nCriteria\ndatabase persistence\n
  • groovy & grails - lecture 10

    1. 1. Groovy: Efficiency Oriented ProgrammingLecture 10Master Proteomics & Bioinformatics - University of GenevaAlexandre Masselot - summer 2011
    2. 2. Agenda‣ SVN & google code hosting‣ More on GSP‣ Including third parties libraries‣ Ajax‣ Runtime environment‣ Domains
    3. 3. SCM‣ Code evolve in time
    4. 4. SCM‣ Code evolve in time‣ Source code is shared
    5. 5. SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning
    6. 6. SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning‣ Many solutions exist: CVS, SVN, GIT, SourceSafe...
    7. 7. SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning‣ Many solutions exist: CVS, SVN, GIT, SourceSafe...‣ SVN is a client/server solution
    8. 8. SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning‣ Many solutions exist: CVS, SVN, GIT, SourceSafe...‣ SVN is a client/server solution‣ Server can be in-house
    9. 9. SCM‣ Code evolve in time‣ Source code is shared‣ Source Code Management system host code + versioning‣ Many solutions exist: CVS, SVN, GIT, SourceSafe...‣ SVN is a client/server solution‣ Server can be in-house‣ Free solution for open source http://code.google.com/hosting/
    10. 10. make an google account
    11. 11. Create ProjectProject name: geop-demoProject summary: A demo project for GEOP courseProject description: geop demo codeVersion control system: SubversionSource code license:  New BSD LicenseUse a separate content license:license...Project labels:Create project...Project name must start with a lowercase letter, followed by lowercase letters, digits, and dashes, with nospaces. This will be part of your projects URL and cannot be changed later.Project summary will be shown whenever the projects name is displayed.Project description is the main content of your projects home page. You may use wiki markup.Version control system selects the type of your projects repository. Learn more.Licenses determine how others may build upon your work. Code and documentation may be distributed underseparate licenses.Project labels help classify your project so others can easily find it or browse projects by label.
    12. 12. Google proposes command line commandsWe’ll see how to integrate svn into eclipse
    13. 13. Command-line accessIf you plan to make changes, use this command to check out the code as yourself using HTTPS:# Project members authenticate over HTTPS to allow committing changes.svn checkout https://geop-demo.googlecode.com/svn/trunk/ geop-demo --username alexandre.masselotWhen prompted, enter your generated googlecode.com password.Use this command to anonymously check out the latest project source code:# Non-members may check out a read-only working copy anonymously over HTTP.svn checkout http://geop-demo.googlecode.com/svn/trunk/ geop-demo-read-onlyGUI and IDE accessThis projects Subversion repository may be accessed using many different client programs and plug-ins. See your clientsdocumentation for more information.
    14. 14. Google code offers for “free”‣ SVN repository
    15. 15. Google code offers for “free”‣ SVN repository‣ Managing contributors to a project
    16. 16. Google code offers for “free”‣ SVN repository‣ Managing contributors to a project‣ Wiki
    17. 17. Google code offers for “free”‣ SVN repository‣ Managing contributors to a project‣ Wiki‣ Ticketing system
    18. 18. Google code offers for “free”‣ SVN repository‣ Managing contributors to a project‣ Wiki‣ Ticketing system‣ Bug reporting
    19. 19. Google code offers for “free”‣ SVN repository‣ Managing contributors to a project‣ Wiki‣ Ticketing system‣ Bug reporting‣ Visibility
    20. 20. Google code hosting ⇒your code is open source
    21. 21. SVN: eclipse or command line
    22. 22. Installing svn in Eclipse‣ Help > dashboard > extension - Subversion (subclipse)
    23. 23. Installing svn in Eclipse‣ Help > dashboard > extension - Subversion (subclipse)‣ Or command line: installed by default or - sudo apt-get install subversion
    24. 24. Eclipse: connecting to the SVN repository‣ menu Window - > open perspective - > SVN repository exploring
    25. 25. Eclipse: connecting to the SVN repository‣ menu Window - > open perspective - > SVN repository exploring‣ view SVN repositories - > right click - > new repository location - https://geop-demo.googlecode.com/svn
    26. 26. Sharing an existing project to your google code account
    27. 27. Sharing an existing project to your google code account‣ Perspective java
    28. 28. Sharing an existing project to your google code account‣ Perspective java‣ project right-click - > team - > share project - use specifier folder name trunk/your.project.name
    29. 29. ‣ username & password from google page‣ save password check box
    30. 30. Commit the project‣ At this stage, the project is only created on the remote server - check with SVN repository exploring perspective - or browse source code from google page
    31. 31. Commit the project‣ At this stage, the project is only created on the remote server - check with SVN repository exploring perspective - or browse source code from google page‣ Mark generated file & folder to be ignored from svn - e.g. target/
    32. 32. Commit the project‣ At this stage, the project is only created on the remote server - check with SVN repository exploring perspective - or browse source code from google page‣ Mark generated file & folder to be ignored from svn - e.g. target/‣ Right-click > team > add to svn:ignore
    33. 33. All eclipse functionalitiescan be replaced by shell commands
    34. 34. SVN command line: share project‣ Import original project demo.svn to the repository‣ cd workspace directory svn import -m “initial import” --non-recursive demo.svn https://geop-demo.googlecode.com/svn/trunk/demo.svn‣ Directory itself is not imported, so checkout (with force) svn checkout --force https://geop-demo.googlecode.com/svn/ trunk/demo.svn
    35. 35. SVN command line: share project (cont’d) cd demo.svn‣ Add target/ directory to svn:ignore svn propset svn:ignore target .‣ Add other directories to svn svn add $(ls | grep -v target)‣ Commit files svn commit -m "adding all initial files"‣ Back to eclipse, F5 (refresh in package explorer view)
    36. 36. Browse your project
    37. 37. From google code source page 25
    38. 38. SVN for a daily use
    39. 39. SVN for a daily use minutely
    40. 40. SVN: flow use‣ Checkout out or share an existing project to contribute
    41. 41. SVN: flow use‣ Checkout out or share an existing project to contribute‣ Commit changes to the repository
    42. 42. SVN: flow use‣ Checkout out or share an existing project to contribute‣ Commit changes to the repository‣ Update changes from repository
    43. 43. SVN: flow use‣ Checkout out or share an existing project to contribute‣ Commit changes to the repository‣ Update changes from repository‣ Eclipse: - select project - > right-click - > team - > Synchronize with repository - commit/update/manage conflict
    44. 44. SVN: flow use (cont’d)‣ Command linesvn statussvn updatesvn commit -m “my message to describe changes”
    45. 45. Commit/update often
    46. 46. SVN is more‣ History
    47. 47. SVN is more‣ History‣ See contribution from others
    48. 48. SVN is more‣ History‣ See contribution from others‣ Tag / branch versions
    49. 49. SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution
    50. 50. SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution‣ Continuous integration / testing on dedicated server
    51. 51. SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution‣ Continuous integration / testing on dedicated server‣ File locking :(
    52. 52. SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution‣ Continuous integration / testing on dedicated server‣ File locking :(‣ Integration with tickets
    53. 53. SVN is more‣ History‣ See contribution from others‣ Tag / branch versions‣ Conflict resolution‣ Continuous integration / testing on dedicated server‣ File locking :(‣ Integration with tickets‣ Windows integration: http://tortoisesvn.tigris.org/
    54. 54. Back to grails... and proteins isoforms
    55. 55. Problem: uniprot AC ➙ isoform list in a web application
    56. 56. Grails: including a third parties libraries‣ Library is available as a jar (export ➙ .jar)
    57. 57. Grails: including a third parties libraries‣ Library is available as a jar (export ➙ .jar)‣ Copy jar in lib/
    58. 58. Grails: including a third parties libraries‣ Library is available as a jar (export ➙ .jar)‣ Copy jar in lib/‣ For eclipse completion - right-click - build path - add to build path
    59. 59. Get is forms for ac (00:44:01.975)Q70Z44List>Q70Z44-1MQKHSPGPPALALLSQSLLTTGNGDTLIINCPGFGQHRVDPAAFQAVFDRKAIGPVTNYSVATHVNISFTLSAIWNCYSRIHTFNCHHARPWHNQFVQWNPDECGGIKKSGMATENLWLSDVFIEESVDQTPAGLMASMSIVKATSNTISQCGWSASANWTPSISPSMDRARAWRRMSRSFQIHHRTSFRTRREWVLLGIQKRTIKVTVATNQYEQAIFHVAIRRRCRPSPYVVNFLVPSGILIAIDALSFYLPLESGNCAPFKMTVLLGYSVFLLMMNDLLPATSTSSHASLVAPLALMQTPLPAGVYFALCLSLMVGSLLETIFITHLLHVATTQPLPLPRWLHSLLLHCTGQGRCCPTAPQKGNKGPGLTPTHLPGVKEPEVSAGQMPGPGEAELTGGSEWTRAQREHEAQKQHSVELWVQFSHAMDALLFRLYLLFMASSIITVICLWNT>Q70Z44-2MASMSIVKATSNTISQCGWSASANWTPSISPSMDRAERSPSALSPTQVAIRRRCRPSPYVVNFLVPSGILIAIDALSFYLPLESGNCAPFKMTVLLGYSVFLLMMNDLLPATSTSSHASLVRPHPSRDQKRGVYFALCLSLMVGSLLETIFITHLLHVATTQPLPLPRWLHSLLLHCTGQGRCCPTAPQKGNKGPGLTPTHLPGVKEPEVSAGQMPGPGEAELTGGSEWTRAQREHEAQKQHSVELWVQFSHAMDALLFRLYLLFMASSIITVICLWNT
    60. 60. Isoforms_v1 -> v5 same controller different views (gsp) for different rendering interaction
    61. 61. Isoforms_v1 -> v5 same controller different views (gsp) for different rendering interaction
    62. 62. Isoforms_vXController ⇒views/isoforms_vX/ direcgtory with gsp’s
    63. 63. IsoformController_v?.groovy def list = { def ac=params.ac def xml=new XmlSlurper() .parseText("http://pir.uniprot.org/uniprot/${ac}.xml".toURL().text).entry UniprotEntrySplicer splicer=[entryXml:xml] def proteins=splicer.buildAllIsoforms().values() asList [proteins: proteins] }
    64. 64. v1
    65. 65. isoforms_v1/list.gsp<html> <body> <h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2> <g:form action="list"> <g:textField name="ac" value="${params.ac}" /> <g:submitButton name="submit" /> </g:form> <h3>List</h3> <g:each in="${proteins}" var="prot"> <pre> ${prot} </pre> </g:each> </body></html>
    66. 66. Problem: direct access to /list only
    67. 67. v2
    68. 68. v2
    69. 69. isoforms_v2: add index.gsp<html> <body> <h1>Isoform list application</h1> <h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2> <g:form action="list"> <g:textField name="ac" value="${params.ac}" /> <g:submitButton name="submit" /> </g:form> </body></html>
    70. 70. Problem: <g:form> is duplicated (DRY!)
    71. 71. isoform_v3: use template‣ _form.gsp<h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2><g:form action="list"> <g:textField name="ac" value="${params.ac}" /> <g:submitButton name="submit" /></g:form>
    72. 72. isoform_v3: use template‣ _form.gsp<h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2><g:form action="list"> <g:textField name="ac" value="${params.ac}" /> <g:submitButton name="submit" /></g:form>‣ In index.gsp and list.gsp <g:render template="form" />
    73. 73. isoform_v3: use template‣ _form.gsp<h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2><g:form action="list"> <g:textField name="ac" value="${params.ac}" /> <g:submitButton name="submit" /></g:form>‣ In index.gsp and list.gsp <g:render template="form" />
    74. 74. Problem: all the page is reloaded totally
    75. 75. v4
    76. 76. Ajax: asynchronous load web browserQ70Z44 submit server isoform/list 47
    77. 77. Ajax: asynchronous load web browserQ70Z44 submit server isoform/list 47
    78. 78. Ajax: asynchronous load web browserQ70Z44 submit serverList isoform/list>Q70Z44-1MQKHSPGPPALALLSQSLLTTGNGDTLIINCPGFGQHRVDPAAFQAVFDRKAIGPVTNYSVATHVNISFTLSAIWNCYSRIHTFNCHHARPWHNQFVQWNPDECGGIKKSGMATENLWLSDVFIEESVDQTPAGLMASMSIVKATSNTISQCGWSASANWTPSISPSMDRARAWRRMSRSFQIHHRTSFRTRREWVLLGIQKRTIKVTVATNQYEQAIFHVAIRRRCRPSPYVVNFLVPSGILIAIDALSFYLPLESGNCAPFKMTVLLGYSVFLLMMNDLLPATSTSSHASLVAPLALMQTPLPAGVYFALCLSLMVGSLLETIFITHLLHVATTQPLPLPRWLHSLLLHCTGQGRCCPTAPQKGNKGPGLTPTHLPGVKEPEVSAGQMPGPGEAELTGGSEWTRAQREHEAQKQHSVELWVQFSHAMDALLFRLYLLFMASSIITVICLWNT>Q70Z44-2MASMSIVKATSNTISQCGWSASANWTPSISPSMDRAERSPSALSPTQVAIRRRCRPSPYVVNFLVPSGILIAIDALSFYLPLESGNCAPFKMTVLLGYSVFLLMMNDLLPATSTSSHASLVRPHPSRDQKRGVYFALCLSLMVGSLLETIFITHLLHVATTQPLPLPRWLHSLLLHCTGQGRCCPTAPQKGNKGPGLTPTHLPGVKEPEVSAGQMPGPGEAELTGGSEWTRAQREHEAQKQHSVELWVQFSHAMDALLFRLYLLFMASSIITVICLWNT 47
    79. 79. isoform_v4/index.gsp<html> <head> <g:javascript library="prototype" /> </head> <body> <h2>Get is forms for ac (${String.format(%tH:%<tM:%<tS.%<tL, new Date())})</h2> <!-- g:formRemote stands for an ajax form --> <g:formRemote name="listForm" url="[action:list]"update="isoforms-list"> <g:textField name="ac" value="${params.ac}" /> <g:submitButton name="submit" /> </g:formRemote> <!-- the target element of the form --> <div id="isoforms-list"/> </body></html>
    80. 80. isoform_v4/list.gsp<h3>List</h3><g:each in="${proteins}" var="prot"> <pre>${prot} </pre></g:each>
    81. 81. Twitter 1
    82. 82. People post messages and follow others
    83. 83. database (domain)+ controller (actions) + views (web)
    84. 84. Domain: Person & Message
    85. 85. Domain: bean definition + database storage
    86. 86. Person domain‣ Create the database entry + bean class grails create-domain-class Person project > right-click > grails > create-domain-class Person
    87. 87. Person domain‣ Create the database entry + bean class grails create-domain-class Person project > right-click > grails > create-domain-class Person‣ Files created: ./grails-app/domain/eop/lec10/twitter/Person.groovy ./test/unit/eop/lec10/twitter/PersonTests.groovy
    88. 88. Person.groovy‣ Created class package eop.lec10.twitter class Person { static constraints = { } }
    89. 89. Person.groovy
    90. 90. Person.groovy‣ Enriched with fields package eop.lec10.twitter class Person { String username String firstName String lastName String email Date dateCreated static constraints = { } }
    91. 91. run-app ⇒ database + table created
    92. 92. Web access: need controller + views
    93. 93. Scaffolding is pure magic
    94. 94. PersonController.groovycreate-controller Person
    95. 95. PersonController.groovycreate-controller Person‣ grails-app/controller/PersonController.groovy:package eop.lec10.twitterclass PersonController { def scaffold = true}
    96. 96. PersonController.groovy create-controller Person‣ grails-app/controller/PersonController.groovy: package eop.lec10.twitter class PersonController { def scaffold = true }‣ scaffold generate all default action & view implicitely
    97. 97. PersonController.groovy create-controller Person‣ grails-app/controller/PersonController.groovy: package eop.lec10.twitter class PersonController { def scaffold = true }‣ scaffold generate all default action & view implicitely
    98. 98. http://localhost:8080/eop.lec10.twitter/person‣ Default url is redirected on the list page
    99. 99. http://localhost:8080/eop.lec10.twitter/person‣ Default url is redirected on the list page
    100. 100. http://localhost:8080/eop.lec10.twitter/person‣ Entering a new Person lucky luke
    101. 101. http://localhost:8080/eop.lec10.twitter/person‣ Entering a new Person lucky luke
    102. 102. http://localhost:8080/eop.lec10.twitter/person‣ Entering a new Person lucky luke
    103. 103. http://localhost:8080/eop.lec10.twitter/person
    104. 104. http://localhost:8080/eop.lec10.twitter/person‣ Back to list - view all - edit - delete - sort
    105. 105. Domain constraints
    106. 106. Person.groovyclass Person { String username String firstName String lastName String email Date dateCreated //firstName is compulsory //email field has an email format //username cannot be null, is unique and is between 6and 20 characters static constraints = { firstName(blank:false) email(email:true, blank:false) username(blank:false, unique:true, matches:/w{6,20}/) }}
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×