[ http://issues.apache.org/jira/browse/MYFACES-729?page=all ]
     
Bruno Aranda closed MYFACES-729:
--------------------------------

    Fix Version: Nightly
     Resolution: Fixed

Closing per reporter request

> x:dataTabel not displaying the correct values
> ---------------------------------------------
>
>          Key: MYFACES-729
>          URL: http://issues.apache.org/jira/browse/MYFACES-729
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.1.1
>  Environment: Tomcat 5.5.2, JDK 1.5
>     Reporter: Luis
>      Fix For: Nightly

>
> I have a simple JSP with an x:dataTable component on it.  The dataTable gets 
> its value from a LinkedList.  Every time I add a value to the list (ex. class 
> with an open & end date), the values of my previous elements are changed 
> after the refresh.  The action of adding or deleting an element is 
> subtracting 1 to the existing elements (dates) in the list.  This used to 
> work fine in 1.0.9 or before
> ___________________
> JSP 
> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
>       pageEncoding="ISO-8859-1" errorPage="/jsp/ErrorPage.jsp"%>
> <%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/extensions"; prefix="x"%>
> <HTML>
> <!--
> /*
>  * 
>  * 
>  * 
>  * 
>  * 
>  * 
>  * 
>  */
> -->
> <!--
> managed beans used:
> -->
> <BODY>
> <f:view>
>       <h:form id="testForm">
>               <h:panelGrid columns="2" border="0" cellpadding="0" 
> cellspacing="0"
>                       columnClasses="ColumnTop" style="width: 250px">
>                       <h:panelGroup>
>                               <h:inputText size="5" styleClass="DataField" 
> id="daysToFill"
>                                       value="#{test.daySet}"
>                                       maxlength="2">
>                                       <f:validateLongRange minimum="1" 
> maximum="99" />
>                               </h:inputText>
>                               <h:commandButton
>                                       action="#{test.actionAddDay}"
>                                       alt="Add Period" value="Add" 
> image="images/add_button.gif" type="submit"/>
>                       </h:panelGroup>
>                       <h:panelGroup></h:panelGroup>
>                       <h:panelGroup>
>                               <h:panelGrid border="0" cellpadding="0" 
> cellspacing="0"
>                                       columnClasses="DataField">
>                                       <x:dataTable id="daysToFillTable" 
> width="100%" cellpadding="4"
>                                               value="#{test.daysToFillList}"
>                                               var="item" 
> headerClass="tablesHeader" footerClass="tablesFooter"
>                                               
> rowClasses="tablesEvenRow,tablesOddRow" rows="100"
>                                               rowIndexVar="index">
>                                               <h:column>
>                                                       <h:outputText 
> value="#{index+1}" styleClass="DataHead" />
>                                               </h:column>
>                                               <h:column>
>                                                       <h:commandButton
>                                                               
> action="#{test.actionDeleteDay}"
>                                                               alt="Remove 
> Period" value="Delete"
>                                                               
> image="images/remove_button.gif" rendered="true" />
>                                               </h:column>
>                                               <h:column>
>                                                       <h:panelGrid 
> columns="1">
>                                                               <h:outputText 
> value="Open Date (MM/DD/YYYY)"
>                                                                       
> styleClass="DataHead" />
>                                                               <h:inputText 
> styleClass="DateField" id="openDate"
>                                                                       
> onchange="isDate(this.value)" maxlength="10"
>                                                                       
> value="#{item.openDate}" size="15">
>                                                                       
> <f:convertDateTime pattern="MM/dd/yyyy" />
>                                                               </h:inputText>
>                                                               <h:outputText 
> value="End Date (MM/DD/YYYY)"
>                                                                       
> styleClass="DataHead" />
>                                                               <h:inputText 
> styleClass="DateField" id="endDate"
>                                                                       
> onchange="isDate(this.value)" value="#{item.endDate}" size="15"
>                                                                       
> maxlength="10">
>                                                                       
> <f:convertDateTime pattern="MM/dd/yyyy" />
>                                                               </h:inputText>
>                                                       </h:panelGrid>
>                                               </h:column>
>                                       </x:dataTable>
>                               </h:panelGrid>
>                       </h:panelGroup>
>               </h:panelGrid>
>       </h:form>
> </f:view>
> </BODY>
> </HTML>
> ___________________
> CLASSES
> package org.test.hrstats.handler.dataentry;
> import java.util.Calendar;
> import java.util.GregorianCalendar;
> import java.util.LinkedList;
> import java.util.List;
> import javax.faces.model.DataModel;
> import javax.faces.model.ListDataModel;
> import org.test.hrstats.data.DaysToFill;
> //***********************************************************
> /*
>  * Description:
>  * 
>  * @author Luis Roche
>  * @version 1.0, 4/20/2005
>  */
> //***********************************************************
> public class TurnoverPositionDetailHandler {
>     static final long serialVersionUID = -5929348060779437941L;
>     private DataModel daysToFillDataModel = null;
>     private int daySet = 5;
>     private List daysToFill = null;
>     
>     /**
>      * TurnoverPositionDetailHandler
>      */
>     public TurnoverPositionDetailHandler() {
>         super();
>     }
>     
>     /**
>      * @see org.chi.model.CHIHandler#actionAdd()
>      */
>     public String actionAddDay() {
>         DaysToFill d = null;
>         
>         Calendar selectedDate = GregorianCalendar.getInstance();
>         selectedDate.set(Calendar.YEAR, Integer.parseInt("2005"));
>         selectedDate.set(Calendar.MONTH, 10);
>         selectedDate.set(Calendar.DAY_OF_MONTH, 
> selectedDate.getActualMaximum(Calendar.DAY_OF_MONTH));
>         selectedDate.set(Calendar.HOUR, 0);
>         selectedDate.set(Calendar.MINUTE, 0);
>         selectedDate.set(Calendar.SECOND, 0);
>         
>         for (int i = 0; i < this.daySet; i++) {
>             // add new record to collection
>             d = new DaysToFill();
>             
>             // end date
>             d.setEndDate(selectedDate.getTime());
>             
>             // open date
>             selectedDate.set(Calendar.DAY_OF_MONTH, 
> selectedDate.getActualMinimum(Calendar.DAY_OF_MONTH));
>             d.setOpenDate(selectedDate.getTime());
>             
>             this.getDaysToFill().add(d);
>         }
>         
>         return null;
>     }
>     /**
>      * @see org.chi.model.CHIHandler#actionDelete()
>      */
>     public String actionDeleteDay() {
>         DaysToFill row = (DaysToFill) this.daysToFillDataModel.getRowData();
>         this.getDaysToFill().remove(row);
>         return null;
>     }
>     /**
>      * getDaysToFill
>      * @return DataModel
>      */
>     public DataModel getDaysToFillList() {
>         this.daysToFillDataModel = new ListDataModel(this.getDaysToFill());
>         return this.daysToFillDataModel;
>     }
>     /**
>      * getDaySet
>      * @return int
>      */
>     public int getDaySet() {
>         return this.daySet;
>     }
>     /**
>      * setDaySet
>      * @param daySet int
>      */
>     public void setDaySet(int daySet) {
>         this.daySet = daySet;
>     } 
>     
>     /**
>      * getDaysToFill
>      * @return List
>      */
>     public List getDaysToFill() {
>         if (this.daysToFill == null) {
>             this.daysToFill = new LinkedList();
>         }
>         return this.daysToFill;
>     }
>       public void setDaysToFill(List daysToFill) {
>               this.daysToFill = daysToFill;
>       }
> }
> package org.test.hrstats.data;
> import java.util.Calendar;
> import java.util.Date;
> import java.util.GregorianCalendar;
> //***********************************************************
> /* Description:
>  * 
>  * @author Luis Roche
>  * @version 1.0, 5/5/2005
>  */
> //***********************************************************
> public class DaysToFill {
>     static final long serialVersionUID = -684725653790217867L;
>     private int daysToFillId = 0;
>     private Date endDate = null;
>     private Date openDate = null;
>     /**
>      * DaysToFill
>      */
>     public DaysToFill() {
>         super();
>         this.openDate = this.removeTimeFromDate(new Date());
>         this.endDate = this.removeTimeFromDate(new Date());
>     }
>     /**
>      * DaysToFill
>      * @param id int
>      */
>     public DaysToFill(int id) {
>         this();
>         this.daysToFillId = id;
>     }
>     /**
>      * getDaysToFillId
>      * @return int
>      */
>     public int getDaysToFillId() {
>         return this.daysToFillId;
>     }
>     /**
>      * getEndDate
>      * @return Date
>      */
>     public Date getEndDate() {
>         if (this.endDate != null) {
>             this.endDate = removeTimeFromDate(this.endDate);
>         }
>         return this.endDate;
>     }
>     /**
>      * getOpenDate
>      * @return Date
>      */
>     public Date getOpenDate() {
>         if (this.openDate != null) {
>             this.openDate = removeTimeFromDate(this.openDate);
>         }
>         return this.openDate;
>     }
>     /**
>      * removeTimeFromDate
>      * @param date Date
>      * @return Date
>      */
>     private final Date removeTimeFromDate(Date date) {
>         GregorianCalendar c = new GregorianCalendar();
>         c.setTime(date);
>         c.set(Calendar.HOUR, 0);
>         c.set(Calendar.MINUTE, 0);
>         c.set(Calendar.SECOND, 0);
>         return c.getTime();
>     }
>     /**
>      * setDaysToFillId
>      * @param id int
>      */
>     public void setDaysToFillId(int id) {
>         this.daysToFillId = id;
>     }
>     /**
>      * setEndDate
>      * @param date Date
>      * 
>      */
>     public void setEndDate(Date date) {
>         if (date != null) {
>             date = removeTimeFromDate(date);
>         }
>         this.endDate = date;
>     }
>     /**
>      * setOpenDate
>      * @param date Date
>      */
>     public void setOpenDate(Date date) {
>         if (date != null) {
>             date = removeTimeFromDate(date);
>         }
>         this.openDate = date;
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to