IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

GWT et Vaadin Java Discussion :

comment réaliser la succession des pages


Sujet :

GWT et Vaadin Java

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut comment réaliser la succession des pages
    bojour ts le monde ,
    je veux réaliser une succession des pages comme la page de recherche google:
    prec2345678 suiv
    mais je sais pas comment commencé svp si vous avez des indication ou des tutotiaux qui montrent de tel exemple
    merc

  2. #2
    Membre éprouvé Avatar de Caroline76
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 94
    Par défaut
    Tu crees un panel pour le contenu et un panel pour les liens (prec 1 2...), et tu actualises le panel de contenu lors de l'appui sur les liens.

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    merci pour la réponse mais j'ai fais comme ca comme j'actualise a chaque fois c'est juste le commencement:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    	  public void onModuleLoad() {
    		  RootPanel rootPanel = RootPanel.get();
    	    // Make a new list box, adding a few items to it.
     
    	    ListBox lb = new ListBox();
    	    lb.addItem("1");lb.addItem("2");lb.addItem("3");lb.addItem("4");lb.addItem("5");
     
    	    // Make enough room for all five items (setting this value to 1 turns it
    	    // into a drop-down list).
    	    lb.setVisibleItemCount(5);
    	    // Add it to the root panel.
    	    RootPanel.get().add(lb);
    	  }
    	}

  4. #4
    Membre éprouvé Avatar de Caroline76
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 94
    Par défaut
    Tu pourrais te relire, j'ai du mal a comprendre tes phrases.

    Mais pourquoi ne crees-tu pas deux panels que tu ajoutes au panel principal ?
    Et je ne comprends pas a quoi sert ta listbox, elle ne correspond pas au cas decrit dans ton premier message.

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    mais quand je crée les deux panels,je mets quoi pour me donner cette suite de page :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    public class ListBoxExample implements EntryPoint {
         private VerticalPanel verticalPanelContenu;
         private VerticalPanel verticalPanellien;
    	  public void onModuleLoad() {
    		  RootPanel rootPanel = RootPanel.get();
     
    	    verticalPanelContenu = new VerticalPanel();
    		//initWidget(verticalPanel);
    		verticalPanellien =new VerticalPanel();

  6. #6
    Membre éprouvé Avatar de Caroline76
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 94
    Par défaut
    Bon...

    Tu crees un panel "contentPanel" dans lequel tu attaches ton composant permettant de visualiser la liste des donnees (une Grid, un Panel vertical avec tes donnees, ou ce que tu veux).

    Tu crees un panel "controPanell" dans lequel tu mets tes Hyperlinks, Buttons ou je ne sais quoi te permettant de naviguer dans ta liste.

    A ces liens ou boutons, tu associes un ClickListener qui, une fois active, envoie la page a afficher au composant charge de montrer les donnees.

    Lorsque ce composant recoit la page, il s'initialise (vide la grille ou le panel) et charge les elements correspondant a la page.

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    voila ce que j'ai pu faire, j'ai pas pu tout intégrer :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
       public void onModuleLoad() {
    		  RootPanel rootPanel = RootPanel.get();
    	    verticalPanel = new VerticalPanel();
    	     listepage=new VerticalPanel();
    		verticalPanel.add(listepage);
     
    	     Panel contentPane = null;
    		 contentPane.add(verticalPanel); 
     
    		 button = new Button();

  8. #8
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    bonjour
    si quelqu'un aurait l'idée de comment faire une succession des numéros (ou création d'une liste) avec gwt
    là j'ai commencé mais il y a plusieurs erreurs.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
     public void onModuleLoad() {
     		RootPanel rootPanel = RootPanel.get();
     
        	 posContainer = new AbsolutePanel();
        	 posContainer.setSize("100%", "100%");
        	// setWidget(posContainer); 
     
     
                  verticalPanel = new VerticalPanel();
     
    	 	/*  Panel contentPane = null;
    		  contentPane.add(verticalPanel);*/
     
    		  Panel panel = null;
    		  panel.add(verticalPanel);
     
    		  FlowPanel listFlowPanel = new FlowPanel ();
    		  listFlowPanel.setSize("770px", "220px");
    		  VerticalPanel listPanel = new VerticalPanel();
    		  listPanel.setHeight("10%");
    	      listPanel.setWidth("10%"); 
    	      posContainer.add(listFlowPanel, 10,31);  
    		  panel.setVisible(true);

  9. #9
    Membre éprouvé Avatar de Caroline76
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 94
    Par défaut
    Tu veux afficher une suite de nombres cliquables ?
    Dans ce cas determines la taille de cette suite et crees les elements.
    Par exemple:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    HorizontalPanel navPanel= new HorizontalPanel();
    int max = 10;
     
    for (int i=1; i<=max; i++) {
      navPanel.add(new Button("" + i);
    }
    Tu remplaces les boutons par des hyperliens ou ce que tu veux dans ton app.

  10. #10
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    voila carolina j'ai crée que les bouton (premier bouton dernier bouton) et le clickListner et le refresh,mais je veux ascocié des numéros a l'intérieure, puisk il me donne ca à l'affichage:
    << < > >> ici le bouton refesh

    voila le code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
     public AdvancedTable() {
     
    		   final DockPanel contentDockPanel = new DockPanel();
    			initWidget(contentDockPanel);
    			contentDockPanel.setSize("100%", "100%");
    			grid = new Grid();
     
    			navigationPanel = new HorizontalPanel();
    			contentDockPanel.add(navigationPanel, DockPanel.SOUTH);
    			navigationPanel.setSize("100%", "26px");
    			contentDockPanel.setCellVerticalAlignment(navigationPanel,
    			HasVerticalAlignment.ALIGN_BOTTOM);
     
    			final Button buttonRefresh = new Button();
    			navigationPanel.add(buttonRefresh);
    			navigationPanel.setCellVerticalAlignment(buttonRefresh, 
    				HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonRefresh.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonRefreshClicked();
    				}
    			});
    			buttonRefresh.setText("Refresh");
     
    			statusLabel = new Label();
    			navigationPanel.add(statusLabel);
     
     
    			buttonFirstPage = new Button();
    			navigationPanel.add(buttonFirstPage);
    			navigationPanel.setCellVerticalAlignment(buttonFirstPage, 
    			HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonFirstPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonFirstPageClicked();
    				}
    			});
    			navigationPanel.setCellHorizontalAlignment(
    			buttonFirstPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonFirstPage.setText("<<");
     
    			buttonPrevPage = new Button();
    			navigationPanel.add(buttonPrevPage);
    			navigationPanel.setCellVerticalAlignment(buttonPrevPage, 
    		    HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonPrevPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonPrevPageClicked();
    				}
    			});
    			navigationPanel.setCellHorizontalAlignment(
    			buttonPrevPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonPrevPage.setText("<");
     
    			buttonNextPage = new Button();
    			navigationPanel.add(buttonNextPage);
    			navigationPanel.setCellVerticalAlignment(buttonNextPage, 
    			HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonNextPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonNextPageClicked();
    				}
    			});
    			navigationPanel.setCellHorizontalAlignment(
    			buttonNextPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonNextPage.setText(">");
     
    			buttonLastPage = new Button();
    			navigationPanel.add(buttonLastPage);
    			navigationPanel.setCellVerticalAlignment(buttonLastPage,
    			HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonLastPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonLastPageClicked();
    				}
    			});
    			navigationPanel.setCellHorizontalAlignment(
    			buttonLastPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonLastPage.setText(">>");
    		}
     
     
    }
    merci

  11. #11
    Membre éprouvé Avatar de Caroline76
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 94
    Par défaut
    Je te conseille de stocker quelque part ta page. Le mieux est d'avoir ces deux variables:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    int currentPage;
    int lastPage;
    Dans tes listeners, tu mets a jour ta currentPage (1 pour premiere page, lastPage pour derniere page, -- et ++ pour page precedente et suivante, aucune modification pour refresh), puis tu appelles une methode qui, a l'aide de currentPage, met a jour les donnees (c'est ta Grid peut-etre ?).

    Par exemple:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    buttonPrevPage = new Button("<");
    buttonPrevPage.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        currentPage--;
        if (currentPage < 1) currentPage = 1;
        updateData();
      }
    });
     
    //...
     
    private void updateData() {
      // remplir la Grid en fonction de currentPage
    }

  12. #12
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    voila c'est fait, mais il se se passe rien
    je voudrais voir l'incrémentation des numéros en tapant sur le suiv ou prec, mais ca se passe pas ,comment je fais svp ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
       public AdvancedTable() {
     
    		   final DockPanel contentDockPanel = new DockPanel();
    			initWidget(contentDockPanel);
    			contentDockPanel.setSize("100%", "100%");
    			grid = new Grid();
     
    			navigationPanel = new HorizontalPanel();
    			contentDockPanel.add(navigationPanel, DockPanel.SOUTH);
    			navigationPanel.setSize("100%", "26px");
    			contentDockPanel.setCellVerticalAlignment(navigationPanel,
    			HasVerticalAlignment.ALIGN_BOTTOM);
     
    			final Button buttonRefresh = new Button();
    			navigationPanel.add(buttonRefresh);
    			navigationPanel.setCellVerticalAlignment(buttonRefresh, 
    				HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonRefresh.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonRefreshClicked();
    				}
    			});
    			buttonRefresh.setText("Refresh");
     
    			statusLabel = new Label();
    			navigationPanel.add(statusLabel);
     
     
    			buttonFirstPage = new Button();
    			navigationPanel.add(buttonFirstPage);
    			navigationPanel.setCellVerticalAlignment(buttonFirstPage, 
    			HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonFirstPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					 if (currentPage ==1) ;
    					 //   updateData();
     
    				}
    			});
    			navigationPanel.setCellHorizontalAlignment(
    			buttonFirstPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonFirstPage.setText("<<");
     
    			buttonPrevPage = new Button();
    			navigationPanel.add(buttonPrevPage);
    			navigationPanel.setCellVerticalAlignment(buttonPrevPage, 
    		    HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonPrevPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonPrevPageClicked();
    					 currentPage--;
    					    if (currentPage < 1) currentPage = 1;
    					   // updateData();
    				}
     
     
    			});
    			navigationPanel.setCellHorizontalAlignment(
    			buttonPrevPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonPrevPage.setText("<");
     
    			buttonNextPage = new Button();
    			navigationPanel.add(buttonNextPage);
    			navigationPanel.setCellVerticalAlignment(buttonNextPage, 
    			HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonNextPage.addClickListener(new ClickListener() {
    				private int totalRowsCount;
    				//private int pageSize;
    				private int currentPageIndex;
     
    				public void onClick(Widget sender) {
     
    					int pagesCount = calcPagesCount();
    					if (currentPageIndex < pagesCount-1) 
    						currentPageIndex++;
    					  //updateData();
    				}
    			});
     
     
     
    			navigationPanel.setCellHorizontalAlignment(
    			buttonNextPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonNextPage.setText(">");
     
    			buttonLastPage = new Button();
    			navigationPanel.add(buttonLastPage);
    			navigationPanel.setCellVerticalAlignment(buttonLastPage,
    			HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonLastPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonLastPageClicked();
    				}
    			});
    			navigationPanel.setCellHorizontalAlignment(
    			buttonLastPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonLastPage.setText(">>");
     
     
    			/*  private void updateData() {
    			// TODO Auto-generated method stub
     
    		}*/
     
     
    }
    	   public int calcPagesCount (){
    			int pagesCount = 
    				(this.totalRowsCount + pageSize - 1) / this.pageSize;
    			return pagesCount;
    		}	 
     
    }

  13. #13
    Membre éprouvé Avatar de Caroline76
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 94
    Par défaut
    C'est normal qu'il ne se passe rien.
    Regardes ton code, lors d'un clic tu mets a jour la variable, mais tu ne l'affiches pas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    buttonPrevPage = new Button();
    navigationPanel.add(buttonPrevPage);
    //...
    buttonPrevPage.addClickListener(new ClickListener() {
    public void onClick(Widget sender) {
    //AdvancedTable.this.buttonPrevPageClicked();
    currentPage--;
    if (currentPage < 1) currentPage = 1;
    // updateData();
    }
     
     
    });
    Utilise un Label ou ce que tu veux pour afficher a l'ecran le numero de la page, et mets-le a jour dans updateData():
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    Label pageDisplay = new Label("");
     
    controlPanel.add(pageDisplay);
     
    buttonPrevPage = new Button("<");
    buttonPrevPage.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        currentPage--;
        if (currentPage < 1) currentPage = 1;
        updateData();
      }
    });
     
    //...
     
    private void updateData() {
      // meetre a jour l'affichage du numero de page
      pageDisplay.setText(currentPage + "/" + lastPage);
      // remplir la Grid en fonction de currentPage
    }

  14. #14
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    voila j'ai créer un petit label pour mettre les numéros mais comment je fais pour qu'il soit comme ca: < << 5 6 7 8 > >> , et moi sa me donne que : << < > >>
    svp aidez moi à faire ca :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    	Label numéroPageLabel =new Label();
    			FlexTable flexTbale= new FlexTable();
    			numéroPageLabel = new Label("5 6 7 8");
     
    			 flexTable.setWidget(1, 0, numéroPageLabel);
    j'ai rajouté ce code ,et maintenant il m'affiche: < << > >> , y'a du vide au milieu j'ai pas fait ClickListner
    maintenant comment je rajoute les numéros svp ?
    merci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    buttonNumeroCenter =new Button();
    			navigationPanel.add(buttonNumeroCenter);
    			navigationPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);

  15. #15
    Membre éprouvé Avatar de Caroline76
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 94
    Par défaut
    EDIT: Posts croises

    Si tu veux que ton label soit entre tes boutons, il suffit de le placer entre tes boutons :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Label pageDisplay = new Label(currentPage + "/" + lastPage);
    //...
    navigationPanel.add(buttonFirstPage);
    navigationPanel.add(buttonPrevPage);
    navigationPanel.add(pageDisplay);
    navigationPanel.add(buttonNextPage);
    navigationPanel.add(buttonLastPage);
    Pour mettre le label a jour, j'ai deja donne le code (update dans le listener).

  16. #16
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    Il ne se passe rien
    je sais pas pourquoi mais essaye le code chez toi et tu vas voir
    je sais pas ça me donne rien ,voila le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    package com.mycompany.project.client;
     
     
     
    import com.google.gwt.user.client.ui.Button;
    import com.google.gwt.user.client.ui.ButtonBase;
    import com.google.gwt.user.client.ui.ClickListener;
    import com.google.gwt.user.client.ui.Composite;
    import com.google.gwt.user.client.ui.DockPanel;
    import com.google.gwt.user.client.ui.FlexTable;
    import com.google.gwt.user.client.ui.Grid;
     
    import com.google.gwt.user.client.ui.HasHorizontalAlignment;
    import com.google.gwt.user.client.ui.HasVerticalAlignment;
    import com.google.gwt.user.client.ui.HorizontalPanel;
    import com.google.gwt.user.client.ui.Label;
     
    import com.google.gwt.user.client.ui.Widget;
     
    public class AdvancedTable extends Composite {
     
    	private HorizontalPanel navigationPanel;
    	private final Grid grid;
    	private final Label statusLabel;
    	private final Button buttonFirstPage;
    	private final Button buttonPrevPage;
    	private final Button buttonNextPage;
    	private final Button buttonLastPage;
    	private int totalRowsCount;
    	int currentPage;
    	int lastPage;
    	private int pageSize;
    	private Button buttonNumeroCenter;
     
    	   public AdvancedTable() {
     
    		   final DockPanel contentDockPanel = new DockPanel();
    			initWidget(contentDockPanel);
    			//contentDockPanel.setSize("100%", "100%");
    			grid = new Grid();
     
    			Label numéroPageLabel =new Label();
    			FlexTable flexTbale= new FlexTable();
    			numéroPageLabel = new Label("40");
     
    			// flexTable.setWidget(1, 0, numéroPageLabel);
     
     
    			navigationPanel = new HorizontalPanel();
    			contentDockPanel.add(navigationPanel, DockPanel.SOUTH);
    			navigationPanel.setSize("100%", "12px");
    			contentDockPanel.setCellVerticalAlignment(navigationPanel,
    			HasVerticalAlignment.ALIGN_BOTTOM);
     
    			final Button buttonRefresh = new Button();
    			navigationPanel.add(buttonRefresh);
    			navigationPanel.setCellVerticalAlignment(buttonRefresh, 
    				HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonRefresh.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonRefreshClicked();
    				}
    			});
    			buttonRefresh.setText("Refresh");
     
    			statusLabel = new Label();
    			navigationPanel.add(statusLabel);
     
    			Label pageDisplay = new Label(currentPage + "/" + lastPage);
    			buttonFirstPage = new Button();
    			navigationPanel.add(buttonFirstPage);
    			navigationPanel.setCellVerticalAlignment(buttonFirstPage,HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonFirstPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					 if (currentPage ==1) ;
    					 //   updateData();
     
    				}
    			});
    			navigationPanel.setCellHorizontalAlignment(buttonFirstPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonFirstPage.setText("<<");
     
     
    			buttonPrevPage = new Button();
    			navigationPanel.add(buttonPrevPage);
    			navigationPanel.setCellVerticalAlignment(buttonPrevPage, 
    		    HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonPrevPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonPrevPageClicked();
    					 currentPage--;
    					    if (currentPage < 1) currentPage = 1;
    					   // updateData();
    				}
     
     
    			});
    			navigationPanel.setCellHorizontalAlignment(
    			buttonPrevPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonPrevPage.setText("<");
     
     
    			navigationPanel.add(pageDisplay);
    			buttonNumeroCenter =new Button();
    			navigationPanel.add(buttonNumeroCenter);
    			navigationPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
     
     
    			buttonNextPage = new Button();
    			navigationPanel.add(buttonNextPage);
    			navigationPanel.setCellVerticalAlignment(buttonNextPage, 
    			HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonNextPage.addClickListener(new ClickListener() {
    				private int totalRowsCount;
    				//private int pageSize;
    				private int currentPageIndex;
     
    				public void onClick(Widget sender) {
     
    					int pagesCount = calcPagesCount();
    					if (currentPageIndex < pagesCount-1) 
    						currentPageIndex++;
    					  updateData();
    				}
    			});
     
     
     
    			navigationPanel.setCellHorizontalAlignment(
    			buttonNextPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonNextPage.setText(">");
     
    			buttonLastPage = new Button();
    			navigationPanel.add(buttonLastPage);
    			navigationPanel.setCellVerticalAlignment(buttonLastPage,
    			HasVerticalAlignment.ALIGN_BOTTOM);
    			buttonLastPage.addClickListener(new ClickListener() {
    				public void onClick(Widget sender) {
    					//AdvancedTable.this.buttonLastPageClicked();
    				}
    			});
    			navigationPanel.setCellHorizontalAlignment(
    			buttonLastPage, HasHorizontalAlignment.ALIGN_RIGHT);
    			buttonLastPage.setText(">>");
     
     
    			/*  private void updateData() {
    			// TODO Auto-generated method stub
     
    		}*/
     
     
    }
    	   public int calcPagesCount (){
    			int pagesCount = 
    				(this.totalRowsCount + pageSize - 1) / this.pageSize;
    			return pagesCount;
    		}	 
     
     
     
    		private void updateData() {
    			//showStatus("Loading...", STATUS_WAIT);
    			     ButtonBase  pageDisplay = null;
    				 pageDisplay.setText(currentPage + "/" + lastPage);
    				return ;
    		}
     
    }

  17. #17
    Membre éprouvé Avatar de Caroline76
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 94
    Par défaut
    Tu pourrais indenter ton code et utiliser les balises adequates, ca faciliterait la lecture.
    C'est normal que ca ne marche pas, regardes ce que tu fais:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ButtonBase pageDisplay = null;
    pageDisplay.setText(currentPage + "/" + lastPage);
    Effaces "ButtonBase page display = null;"

  18. #18
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    il connais pas displayPage , si j'enleve l'initialization ,il mais une erreur sur displayPage

  19. #19
    Membre éprouvé Avatar de Caroline76
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    94
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 94
    Par défaut
    C'est normal que pageDisplay n'est pas connu, il faut le definir en dehors du constructeur:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    public class AdvancedTable extends Composite {
      private HorizontalPanel navigationPanel;
      private final Grid grid;
      // ...
      private Label pageDisplay;
    Mais la, ce n'est plus du GWT mais un probleme de Java. Tu devrais apprendre Java avant d'essayer de faire du GWT.

  20. #20
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2008
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 113
    Par défaut
    bonjour

    je l'avais déja créé ,mais ce qui reste c'est quand je clicque sur les boutons (< >) il faut qu'il se dirige vers une autre page,
    j 'ai fais Window.open,mais le problème c'est il faut la déclarer dans chaque ClickListner
    merci

Discussions similaires

  1. Réponses: 0
    Dernier message: 15/06/2014, 03h45
  2. Réponses: 13
    Dernier message: 07/05/2010, 17h49
  3. Réponses: 4
    Dernier message: 12/03/2009, 14h27
  4. Réponses: 0
    Dernier message: 29/04/2008, 07h56
  5. Comment séparer le contenu des pages de leur structure?
    Par djodjo dans le forum Général Conception Web
    Réponses: 7
    Dernier message: 06/05/2005, 14h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo