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

JSF Java Discussion :

Deux rich calendars


Sujet :

JSF Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    114
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 114
    Par défaut Deux rich calendars
    Bonjour,

    Voila j'ai 2 richcalendars pour récupérer une date de début et de fin pour exécuter par la suite une requête. Mon problème c'est qu'après avoir choisi une valeur sur chaque calendrier et soumis la requête, mon premier richcalendar récupère la valeur du deuxième.
    J'utilise JSF 2.0, RF4 et JBOSS6.

    Mon xhtml :
    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
     
    .....
     
    <h:panelGroup rendered="true" layout="block" style="font-weight:bold;margin:3 3">
    	<rich:calendar value="#{refItemController.calDebut.selectedDate}"
    		id="calDebut" locale="#{refItemController.calDebut.locale}"
    		popup="#{refItemController.calDebut.popup}"
    		datePattern="#{refItemController.calDebut.pattern}"
    		showApplyButton="#{refItemController.calDebut.apply}" cellWidth="24px" cellHeight="22px"
    		boundaryDatesMode="scroll"
    		enableManualInput="#{refItemController.calDebut.manuel}"
    		style="width:200px" disabled="false">Du
                    		</rich:calendar>
    </h:panelGroup>
    <h:panelGroup rendered="true" layout="block" style="font-weight:bold;margin:3 3">
    	<rich:calendar value="#{refItemController.calFin.selectedDate}"
    		id="calFin" locale="#{refItemController.calFin.locale}"
    		popup="#{refItemController.calFin.popup}"
    		datePattern="#{refItemController.calFin.pattern}"
    		showApplyButton="#{refItemController.calFin.apply}" cellWidth="24px" cellHeight="22px"
    		boundaryDatesMode="scroll"
    		enableManualInput="#{refItemController.calFin.manuel}"
    		style="width:200px" disabled="false">Au
                    		</rich:calendar>
    </h:panelGroup>
    <h:panelGroup rendered="true" layout="block" style="padding:5 5;margin:5 5;text-align: center" width="100%">
    	<a4j:commandButton value="Afficher les montants"
    		action="#{refItemController.changeAffiche(refItemController.afficheNot)}"
    		reRender="montantsBT" />
    </h:panelGroup>
    <a4j:outputPanel  event="onchanged" id="montantsBT">
     
    	<h:panelGrid rendered="#{refItemController.afficheNot}"
    		columns="2" columnClasses="colbertMttLab, colbertMtt"
    		width="100%">
    		<h:outputText value="Montant matériel :" />
    		<h:outputText
    			value="#{refItemController.bt.totalBt(refItemController.btList,1)}" />
    		<h:outputText value="Montant m.o. :" />
    		<h:outputText
    			value="#{refItemController.bt.totalBt(refItemController.btList,2)}" />
    		<h:outputText value="Montant achat :" />
    		<h:outputText
    			value="#{refItemController.bt.totalBt(refItemController.btList,3)}" />
    		<h:outputText value="Montant stock :" />
    		<h:outputText
    			value="#{refItemController.bt.totalBt(refItemController.btList,4)}" />
    	</h:panelGrid>
    </a4j:outputPanel>
     
    ....
    Mon managed bean :
    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
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
     
    package com.galhauban.patrimoine.batiment;
     
     
    import java.io.Serializable;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.List;
     
    import javax.ejb.EJB;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.SessionScoped;
    import javax.inject.Named;
     
    import org.richfaces.component.UITree;
    import org.richfaces.event.TreeSelectionChangeEvent;
     
    import com.galhauban.patrimoine.composants.CalendarBean;
    import com.galhauban.patrimoine.interfaces.ColbertBtEntity;
    import com.galhauban.patrimoine.interfaces.ColbertInterventionTotal;
    import com.galhauban.patrimoine.interfaces.IColbertBt;
     
     
     
     
    //@Named("refItemController")
    @ManagedBean(name="refItemController")
    @SessionScoped
    public class RefItemController implements Serializable {
     
    	private static final long serialVersionUID = 1L;
    	@EJB
    	private RefItemLocal items;
    	private List<RefItemEntity> liste =new ArrayList<RefItemEntity>();
    	@EJB
    	private IBatiment batis;
    	private List<BatimentEntity> listeBatis =new ArrayList<BatimentEntity>();
     
    	private Noeud myTree = new Noeud();
    	private Noeud currentSelection = null;
     
    	private boolean remarquesBool = false;
    	private String remarques;
     
    	private List<BatimentStructureEntity> listeStructure = new ArrayList<BatimentStructureEntity>(); 
     
    	private List<BatimentCarnetEntity> listeCarnet = new ArrayList<BatimentCarnetEntity>();
     
    	@EJB
    	private IColbertBt bt;
    	private List<ColbertBtEntity> btList = new ArrayList<ColbertBtEntity>();
    	//Déclaration d'un tablo pour réceptionner les objets montants
    	private List<ColbertInterventionTotal> totaux = new ArrayList<ColbertInterventionTotal>();
     
    	@EJB
    	private CalendarBean calDebut;
    	@EJB
    	private CalendarBean calFin;
     
    	private boolean afficheNot = false;
     
     
     
    	public RefItemController(){};
     
    	//Affiche l'arborescence 
    	public String doSearch() {
    		try {
    	        liste = items.refItemList();
    	        System.out.println("Liste taille : " + liste.size());
    	        listeBatis = batis.listBatiment();
    	        addNoeud(findRoot(liste),liste,listeBatis);
    	        return "referentiel.found";
    		}
    		catch (Exception ex){
    			System.out.println("pb : " + ex.getMessage());
    			ex.printStackTrace();
    			return null;
    		}
    	}
     
    	//Ajoute un noeud
    	public void addNoeud (ArrayList<Noeud> tablo, List<RefItemEntity> listeRef, List<BatimentEntity> listeBat){
     
    		ArrayList<Noeud> tabli = new ArrayList<Noeud>();
    		for (Noeud noeud : tablo)
    		{
    			for (RefItemEntity objet : listeRef){
    				if(objet.getPere() == noeud.getId())
    				{
    	        		Noeud fils = new Noeud();
    	        		fils.setType("arbo");
    	        		fils.setId(objet.getId());
    	        		fils.setName(objet.getNom());
    	        		noeud.addChild(String.valueOf(fils.getId()), fils);
    	        		tabli.add(fils);
    	        		System.out.println("Fils : " + fils.getName());
     
    	        		//boucle permettant d'ajouter les éventuels batiments au fils
    	        		for(BatimentEntity bat : listeBat){
    	        			if (bat.getIdref() == fils.getId()){
    	        				Noeud filsBat = new Noeud();
    		        			filsBat.setType("bati");
    		        			filsBat.setId(bat.getId());
    		        			filsBat.setId_achatmode(bat.getIdacm());
    		        			filsBat.setId_batimenttype(bat.getIdbty());
    		        			filsBat.setId_ensemble(bat.getIdens());
    		        			filsBat.setId_quartier(bat.getIdqua());
    		        			filsBat.setName(bat.getNom());
    		        			filsBat.setRefexterne(bat.getRefexterne());
    		        			filsBat.setNumero(bat.getNumero());
    		        			filsBat.setBis(bat.getBis());
    		        			filsBat.setRue(bat.getRue());
    		        			filsBat.setCodepostal(bat.getCodepostal());
    		        			filsBat.setCommune(bat.getCommune());
    		        			filsBat.setRemarques(bat.getRemarques());
    		        			fils.addChild(String.valueOf(filsBat.getId()), filsBat);
    		        			System.out.println("----" + bat.getNom());
    		        			//listeBatis.remove(listeBatis.indexOf(bat));
    	        			}
     
    	        		}
    				}
    	    	}
     
    			if (tabli.size() != 0) {
    				//System.out.println("*** Taille du tablo : " + tabli.size());
    				addNoeud(tabli,listeRef,listeBat);
    			}
    			else System.out.println("*** Fin ****");
    		}
    	}
     
    	//Permet de recupérer l'élèment racine
    	//L'élèment racine possède une valeur null au niveau de la colonne pere
    	public ArrayList<Noeud> findRoot(List<RefItemEntity> liste ) {
    		ArrayList<Noeud> tablo = new ArrayList<Noeud>() ;
    		for (RefItemEntity objet : liste) {
             	if (objet.getPere() == null) {
             		Noeud root = new Noeud();
            		root.setName(objet.getNom());
            		root.setId(objet.getId());
            		root.setType("arbo");
            		myTree.addChild(String.valueOf(root.getId()), root);
            		tablo.add(root);
            		System.out.println("**************************** root : " + root.getId());
            		liste.remove(liste.indexOf(objet));
            		break;
            	}
        	}
    		return tablo;
    	}
     
    	public void selectionChanged(TreeSelectionChangeEvent selectionChangeEvent) {
            // considering only single selection
    		System.out.println("*** selectionchanged");
            List<Object> selection = new ArrayList<Object>(selectionChangeEvent.getNewSelection());
            Object currentSelectionKey = selection.get(0);
            UITree tree = (UITree) selectionChangeEvent.getSource();
            System.out.println("*** selection : " + selection.get(0)+ " - taille : " +selection.size());
            Object storedKey = tree.getRowKey();
            tree.setRowKey(currentSelectionKey);
            currentSelection = (Noeud) tree.getRowData();
            tree.setRowKey(storedKey);
        }
     
    	public boolean changeBool(boolean bool){
    		setRemarquesBool(!bool);
    		return(bool);
    	}
     
    	public boolean changeAffiche(boolean bool){
    		setAfficheNot(!bool);
    		return(bool);
    	}
     
    	public void majBatiment(){
    		String remini = currentSelection.getRemarques();
    		String rem = batis.BatimentMaj(currentSelection.getId(),remini +"<br/>"+ remarques).getRemarques();
    		setRemarques(null);
    		currentSelection.setRemarques(rem);
    	}
     
     
    	/*************************************************************************************
             *                                              GETTERS AND SETTERS
             *************************************************************************************/
     
    	public List<RefItemEntity> getListe() {
    		return liste;
    	}
     
    	public void setListe(List<RefItemEntity> liste) {
    		this.liste = liste;
    	}
     
    	public RefItemLocal getItems() {
    		return items;
    	}
     
    	public void setItems(RefItemLocal items) {
    		this.items = items;
    	}
     
    	public Noeud getMyTree() {
    		return myTree;
    	}
     
    	public void setMyTree(Noeud myTree) {
    		this.myTree = myTree;
    	}
     
    	public Noeud getCurrentSelection() {
    		return currentSelection;
    	}
     
    	public void setCurrentSelection(Noeud currentSelection) {
    		this.currentSelection = currentSelection;
    	}
     
    	public IBatiment getBatis() {
    		return batis;
    	}
     
    	public void setBatis(IBatiment batis) {
    		this.batis = batis;
    	}
     
    	public List<BatimentEntity> getListeBatis() {
    		return listeBatis;
    	}
     
    	public void setListeBatis(List<BatimentEntity> listeBatis) {
    		this.listeBatis = listeBatis;
    	}
     
    	public boolean isRemarquesBool() {
    		return remarquesBool;
    	}
     
    	public void setRemarquesBool(boolean remarquesBool) {
    		this.remarquesBool = remarquesBool;
    	}
     
    	public String getRemarques() {
    		return remarques;
    	}
     
    	public void setRemarques(String remarques) {
    		this.remarques = remarques;
    	}
     
    	public List<BatimentStructureEntity> getListeStructure() {
    		listeStructure = batis.listStructure();
    		return listeStructure;
    	}
     
    	public void setListeStructure(List<BatimentStructureEntity> listeStructure) {
    		this.listeStructure = listeStructure;
    	}
     
    	public List<BatimentCarnetEntity> getListeCarnet() {
    		listeCarnet = batis.findCarnet(currentSelection.getId());
    		return listeCarnet;
    	}
     
    	public void setListeCarnet(List<BatimentCarnetEntity> listeCarnet) {
    		this.listeCarnet = listeCarnet;
    	}
     
    	public IColbertBt getBt() {
    		return bt;
    	}
     
    	public void setBt(IColbertBt bt) {
    		this.bt = bt;
    	}
     
    	public List<ColbertBtEntity> getBtList() throws ParseException {
    		System.out.println("DATE DEBUT  : "+calDebut.getSelectedDate()+" - FIN : "+calFin.getSelectedDate());
    		btList=bt.coutBt(currentSelection.getRefexterne(), calDebut.getSelectedDate(), calFin.getSelectedDate());
    		System.out.println("NB BTS  : "+btList.size());
    		return btList;
    	}
     
    	public void setBtList(List<ColbertBtEntity> btList) {
    		this.btList = btList;
    	}
     
    	public boolean isAfficheNot() {
    		return afficheNot;
    	}
     
    	public void setAfficheNot(boolean afficheNot) {
    		this.afficheNot = afficheNot;
    	}
     
    	public CalendarBean getCalDebut() {
    		System.out.println("calDebut  : "+calDebut.getSelectedDate());
    		return calDebut;
    	}
     
    	public void setCalDebut(CalendarBean calDebut) {
    		this.calDebut = calDebut;
    	}
     
    	public CalendarBean getCalFin() {
    		System.out.println("calFin  : "+calFin.getSelectedDate());
    		return calFin;
    	}
     
    	public void setCalFin(CalendarBean calFin) {
    		this.calFin = calFin;
    	}
     
    }
    Mon bean :
    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
     
    package com.galhauban.patrimoine.composants;
     
    import java.util.Date;
    import java.util.Locale;
     
    import javax.ejb.LocalBean;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
     
    /**
     * Session Bean implementation class CalendarBean
     */
    @Stateless
    @LocalBean
    public class CalendarBean implements ICalendarBean {
     
    	private boolean popup;  
        private String pattern;  
        private Date selectedDate;  
        private Locale locale;
        private boolean apply;
        private boolean manuel;
     
     
        public CalendarBean() {
        	System.out.println("*****************CALENDAR BEAN ");
            this.popup = true;
            this.locale = locale.FRENCH;
            this.pattern = "dd/MM/yyyy";
            this.apply = false;
            this.manuel = true;
        }
     
     
    	public boolean isPopup() {
    		return popup;
    	}
     
     
    	public void setPopup(boolean popup) {
    		this.popup = popup;
    	}
     
     
    	public String getPattern() {
    		return pattern;
    	}
     
     
    	public void setPattern(String pattern) {
    		this.pattern = pattern;
    	}
     
     
    	public Date getSelectedDate() {
    		return selectedDate;
    	}
     
     
    	public void setSelectedDate(Date selectedDate) {
    		this.selectedDate = selectedDate;
    	}
     
     
    	public Locale getLocale() {
    		return locale;
    	}
     
     
    	public void setLocale(Locale locale) {
    		this.locale = locale;
    	}
     
     
    	public boolean isApply() {
    		return apply;
    	}
     
     
    	public void setApply(boolean apply) {
    		this.apply = apply;
    	}
     
     
    	public boolean isManuel() {
    		return manuel;
    	}
     
     
    	public void setManuel(boolean manuel) {
    		this.manuel = manuel;
    	}
     
    }
    Si vous avez des idées, merci par avance.
    Couse1

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    114
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 114
    Par défaut
    Pb résolu de mon calendarbean j'en ai fait un simple POJO

    Couse1

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème avec Rich:Calendar
    Par iviath dans le forum JSF
    Réponses: 1
    Dernier message: 02/01/2009, 18h59
  2. Réponses: 4
    Dernier message: 13/11/2008, 17h44
  3. richfaces : <rich:calendar>
    Par bazzouz dans le forum JSF
    Réponses: 2
    Dernier message: 19/10/2008, 02h26
  4. <rich:calendar et datePattern
    Par Jacobian dans le forum JSF
    Réponses: 1
    Dernier message: 08/10/2008, 14h12
  5. demande d'un converter pour le tag rich:calendar
    Par CristinaB dans le forum JSF
    Réponses: 2
    Dernier message: 15/02/2008, 15h17

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