SlideShare une entreprise Scribd logo
1  sur  76
Apache Wicket


  Java User Group - Tours
    Mercredi 11 Mars 2009
Romain Lucas

                              •   Polytech'Tours

                              •   Orange Business Services — online multimedia
                                  • Wicket
                              •   SRMvision
                                  • Wicket


 r.lucas@srmvision.com
http://twitter.com/rlucas37




                                    2
Cedric Gatay

                                  •   Polytech'Tours

                                  •   Orange Business Services — online multimedia
                                      • Struts
                                  •   SRMvision
                                      • Wicket


    c.gatay@srmvision.com
http://twitter.com/Cedric_Gatay




                                        3
Ce soir...

Wicket ?
Principes
Prise en main
Pour aller plus loin...




                          4
Wicket ?

• Open Source
• Java et xHTML uniquement
• orienté composant
• développement d’une application «à la Swing»
• objet au maximum




                             5
Historique
                                                                                         wicket.apache.org                                                                                 Wicket 1.3.3
                                                                                         15 octobre 2006                                                                                   7 avril 2008

Wicket 1.0                                                                                 Wicket 1.2.3                                                                                          Wicket 1.4-m1
7 juin 2005                                                                                31 octobre 2006                                                                                       2 mai 2008

              Wicket 1.0.2                                                                          Wicket 1.2.4                                                                Wicket 1.3.1         Wicket 1.4-m2
              22 août 2005                                                                          24 décembre 2006                                                            5 février 2008       2 juin 2008

      Wicket 1.0.1       Wicket 1.1                                    Wicket 1.2.1                            Wicket 1.2.5                                                             Wicket 1.2.7        Wicket 1.4-m3         Wicket 1.4-rc1
      14 juillet 2005    30 octobre 2005                               24 juillet 2006                         5 février 2007                                                           23 mars 2008        14 juillet 2008       13 novembre 2008

               Wicket 1.0.3               Wicket 1.1.1       Wicket 1.2      Wicket 1.2.2             Wicket 1.3            Wicket 1.2.6                                              Wicket 1.3.2        Wicket 1.3.4        Wicket 1.3.5          Wicket 1.4-rc2
               29 août 2005               25 janvier 2006    24 mai 2006     27 août 2006             2 janvier 2007        22 avril 2007                                             13 mars 2008        27 juin 2008        15 octobre 2008       9 février 2009




     1 septembre 2005         1 janvier 2006        1 mai 2006      1 septembre 2006          1 janvier 2007           1 mai 2007           1 septembre 2007   1 janvier 2008           1 mai 2008         1 septembre 2008        1 janvier 2009          1 mai 2009




                                                                                                                                    6
Pourquoi ?
                                     •   RIFE         •   Cocoon




• nombreux frameworks existant
                                     •   Spring MVC       Millstone
                                                      •

                                     •   Canyamo          OXF
                                                      •


 • fichiers XML de config            •   Maverick
                                                      •   Struts


                                     •   JPublish         SOFIA
                                                      •
 • beaucoup de taglibs               •   JATO
                                                      •   Tapestry



 • peu de réutilisabilité            •   Folium
                                                      •   WebWork


                                     •   Echo             ...
                                                      •




                                7
Les apports

• du Java et du xHTML uniquement
• pas de XML de configuration
• programmation exclusivement objet
• communauté active



                         8
Du Java ...


• les composants sont des objets
• spécialisation par héritage / composition
• utilisation de new



                           9
Du xHTML...


• le langage connu des designers
• pas de code
• seulement un namespace xHTML



                         10
Du xHTML...


<h1>Hello World !</h1>




          11
Du xHTML...


<h1 wicket:id="msg">Hello World !</h1>




                 12
Du xHTML & Java

<h1 wicket:id="msg">Hello World !</h1>
                  et
add(new Label("msg", "Hello World !"));




                   13
Du xHTML & Java

     <h1 wicket:id="msg">Ici</h1>
                  et
add(new Label("msg", "Hello World !"));




                   14
Du xHTML & Java

  <h1 wicket:id="msg"> Ici </h1>
                   et
add(new Label("msg", "Hello World !"));


     <h1>Hello World !</h1>


                   15
Principes
• Application
• Session
• RequestCycle
• Components
• Behaviors
• Models




                     16
Application

• seul fichier XML web.xml :
 <filter>
    <filter-name>wicket</filter-name>
    <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
    <init-param>
      <param-name>applicationClassName</param-name>
      <param-value>com.srmvision.MonAppli</param-value>
    </init-param>
 </filter>


• configuration dans MonAppli.java

                                   17
Principes
• Application
• Session
• RequestCycle
• Components
• Behaviors
• Models




                     18
Session


• encapsule HttpSession
• stockage transparent
     • attributs de l’objet session




                                      19
Principes
• Application
• Session
• RequestCycle
• Components
• Behaviors
• Models




                     20
RequestCycle


Décode la   Identifie la   Effectue le            Nettoie
                                         Répond
 requête       cible       traitement             Stocke


    • représente une requête



                               21
Principes
• Application
• Session
• RequestCycle
• Components
• Behaviors
• Models




                     22
Component


• une superclasse : wicket.Component
• permet le rendu associé au xHTML
• peut réagir à des événements



                         23
Component

• mapping :
    • wicket:id lie POJO et xHTML
    • seule contrainte : respecter la hiérarchie

• imbrication de composants



                                      24
Component

• quelques composants :
 • Label                       • Textfield
 • Link                        • DatePicker
 • Panel                       • DropDownChoice
 • Form




                          25
Component



• création facile
 public class CounterLinkPanel extends Panel{ ... }




                         26
Principes
• Application
• Session
• RequestCycle
• Components
• Behaviors
• Models




                     27
Behaviors

• décorateur de component
• agit sur le xHTML
 • manipulation Markup des component
 • manipulation Javascript
 • manipulation en-tête xHTML (fichier css / js...)




                                   28
Principes
• Application
• Session
• RequestCycle
• Components
• Behaviors
• Models




                     29
Models

 reçoit                set            set


                                            Personne
          TextField          IModel
                                             p.nom
rendu                  get            get




                      30
Models

• encapsule les données
• Serializable pour stockage en session
• relation Composant / Métier
 • PropertyModel : notation OGNL (Object Graph Notation Language)




                               31
Models

new Label("labelNom", personne.getNom());




                   32
Models

       new Label("labelNom", personne.getNom());

new Label("labelNom",new PropertyModel(personne,"nom"));




                           33
Models

       new Label("labelNom", personne.getNom());

new Label("labelNom",new PropertyModel(personne,"nom"));




        ➡ prévient les NullPointerException



                           34
Models

new TextField("textNom", new PropertyModel(personne, "nom"));




                  ➡ dynamique
                  ➡ dépendant du nom



                             35
Prise en main


      36
Comment ?

• http://wicket.apache.org
• maven 2
 • mvn   archetype:generate

 • mvn   jetty:run




                              37
Structure


• Java et HTML côte à côte
• point d’entrée de l’application




                                38
Par la pratique...


• Page
• Panel
• Link



                  39
Page
<body>
 <h1>Header</h1> <hr />

 <span>[...]</span>

 <hr /> <h1>Footer</h1>

</body>




                           40
Page
<body>

 <h1 wicket:id="head" /> <hr />

 <wicket:child />

 <hr /> <h1 wicket:id="foot" />

</body>




                                   41
Page
<body>

 <h1 wicket:id="head" /> <hr />

 <wicket:child />

 <hr /> <h1 wicket:id="foot" />

</body>




                                   42
Page

<wicket:extend>

 <span wicket:id="content" />

</wicket:extend>




                                 43
Page

public class BasePage extends WebPage{

    public BasePage(){

        add(new Label("head", "Header"));

        add(new Label("foot", "Footer"));

    }

}




                                            44
Page

public class MaPage extends BasePage{

    public MaPage(){

        super();

        add(new MonPanel("content"));

    }

}




                                         45
Par la pratique...


• Page
• Panel
• Link



                  46
Panel


• composant complexe
• réutilisable
• tag spécifique



                       47
Panel

<wicket:panel>
 <span wicket:id="labelTitre" />

 <span wicket:id="labelInfo" />

</wicket:panel>




                             48
Panel
public class PanelInfo extends Panel{
    public PanelInfo(String id,String titre,String info){
        super(id);
        add(new Label("labelTitre",titre));
        add(new Label("labelInfo",info));
    }
}




                               49
Panel


<html>
  <span wicket:id="monPanel" />

</html>




                           50
Panel
public class UtilisationPanel extends WebPage{

    public UtilisationPanel(){

        add(new PanelInfo("monPanel","Nom","Romain"));

    }

}




                             51
Par la pratique...


• Page
• Panel
• Link



                  52
Link

Link increment = new Link("lien") {

	 @Override
	 public void onClick() {
	 	 setResponsePage(HomePage.class);
	 }
};




                         53
Link

Link increment = new Link("lien") {

	 @Override
	 public void onClick() {
	 	 setResponsePage(new HomePage("Hello World!"));
	 }
};




                         54
Pour aller plus loin...


           55
Tests unitaires


• tester les composants
• lancer les tests sans lancer de serveur
• test des requêtes Ajax



                           56
Tests unitaires
@Test

public void labelContainsHelloWorld(){

    WicketTester tester = new WicketTester();

    tester.startPage(HelloWorld.class);

    tester.assertLabel("message", "Hello World!");

}




                             57
Configuration
• via un paramètre système
 1. Development :

   • facilite le développement
 2. Deployment :

   • meilleures performances




                                 58
Mode développement

• console de debug Ajax
• pas de compression Javascript
• pas de cache
• messages d’erreurs explicites



                          59
Mode déploiement

• mise en cache des ressources
• suppression des wicket:id
• compression Javascript
• pages d’erreurs neutres



                            60
Démonstration


      61
62
63
64
65
66
67
68
Communauté


• membre Apache
• mailing list : 60 messages / jour
• irc.freenode.net / ##wicket



                            69
Projets annexes

• Wicket stuff
• Databinder
• WickeXt
• et bien d’autres...



                        70
Bientôt...

• Wicket 1.4 :
 • Java 5 minimum
 • utilisation des generics
 • gestion des Portlet 2.0




                              71
Conclusion


• séparation stricte présentation et métier
• réutilisabilité et qualité du code
• excellente communauté



                             72
Littérature




     73
Questions ?
Merci


  75
Merci


  75

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Apache Wicket - Tours JUG Mars 2009

Notes de l'éditeur