1 Reply Latest reply on Oct 31, 2007 11:40 AM by Pete Muir

    dataModel dataModelSelection first row

    hager hager Newbie

      hello,
      I'm using datamodel and dataModelSelection. I always have the first row selected!
      this is my code :

      bean.java:

      @DataModel(value = "listeChargesRegies")
       private List<ChargeAssignable> listeChargesRegies;
      
       @DataModelSelection(value = "listeChargesRegies")
       @Out(required = false)
       private ChargeAssignable selectedChargeRegie;
      ....
       public Float getNombreJoursFacturesChargeRegie() {
      
       nombreJoursFactures = new Float(0);
       List<Facture> listeFacture = this.factureList.getResultList();
       Facture facture = null;
       facture = FactureService.trouverFacturePourUnChargeAssignable(listeFacture, this.selectedChargeRegie.getId(), this.selectedChargeRegie.getDiscriminator());
       System.out.println("selectedRegie "+this.selectedChargeRegie.getDiscriminator()+"\t"+this.selectedChargeRegie.getId());
       if(facture != null)
       {
       nombreJoursFactures = facture.getNbJoursFactures();
       System.out.println("nombreJoursFactures facture "+nombreJoursFactures);
       }
       else
       {
       nombreJoursFactures = this.selectedChargeRegie.getChargeEffective();
       System.out.println("nombreJoursFactures facture "+nombreJoursFactures);
       }
       return nombreJoursFactures;
       }
       public void setNombreJoursFacturesChargeRegie(Float nombreJoursFactures)
       {
       this.nombreJoursFactures = nombreJoursFactures;
       this.factureHome.getInstance().setNbJoursFactures(this.nombreJoursFactures);
       }



      page.xhtml

      <h:dataTable
      value="#{listeChargesRegies}"
      var="chargeRegie" styleClass="table_s" columnClasses="table_s"
      headerClass="th_s" rowClasses="td1_s,td2_s">

      <h:column>
      <f:facet name="header">
      <h:outputText value="#{msgConditionsGenerales.nbJoursFactures}" />
      </f:facet>
      <h:outputText value="#{reportAvenant.nombreJoursFacturesChargeRegie}" />
      </h:column>
      </h:dataTable>


      when i run my application, I always have the first selectedRegie.What's wrong?? do we must have commandLink ?... because I'm using outputText
      please help me?