9 Replies Latest reply on Sep 25, 2008 9:00 PM by Nicklas Karlsson

    excelExporter.export export datatime throw java.lang.String cannot be cast to java.util.Date

    he youlin Novice

      I have excelExporter.export to export datatable containning datetime type.It throw java.lang.String cannot be cast to java.util.Date

        • 2. Re: excelExporter.export export datatime throw java.lang.String cannot be cast to java.util.Date
          Daniel Roth Apprentice

          If you read the forum policy you would know that you should : provide enough information so someone can help you, including source code, exception stack traces, log excerpts, Seam versions.


          Hence, do that, and we'll answer :-)

          • 3. Re: excelExporter.export export datatime throw java.lang.String cannot be cast to java.util.Date
            he youlin Novice
            Latest 2.1 Unstable Nightly Build Build #318 (2008-9-25 0:01:45) 
            Tomacat 6,JDK6.
            
            <h:form id="theForm">
                 <input type="hidden" name="tnid" value="#{monthEndTransAction.tnid}"/>
                 <input type="hidden" name="isprod" value="#{monthEndTransAction.isprod}"/>
                 <h:commandLink value="ExportExcel" action="#{excelExporter.export('theForm:theDataTable')}"/>
                 <rich:dataTable id="theDataTable" value="#{monthEndTransAction.transactionLogs}" var="tn" rows="10">
                      <rich:column title="#{tn.item.itemno}">
                           <f:facet name="header"><h:outputText value="item"/></f:facet>
                           <h:outputText value="#{tn.item.itemno}"/>
                      </rich:column>
                      <rich:column title="#{tn.item.itemDesc}">
                           <f:facet name="header"><h:outputText value="desc"/></f:facet>
                           <h:outputText value="#{tn.item.itemDesc}"/>
                      </rich:column>
                      <rich:column title="#{tn.fromInv.description}">
                           <f:facet name="header"><h:outputText value="Inventory"/></f:facet>
                           <h:outputText value="#{tn.fromInv.description}"/>
                      </rich:column>
                      
                      <rich:column title="#{tn.ttypeName}">
                           <f:facet name="header"><h:outputText value="TransType"/></f:facet>
                           <h:outputText value="#{tn.ttypeName}"/>
                      </rich:column>
                      <rich:column>
                           <f:facet name="header"><h:outputText value="Qty"/></f:facet>
                           <h:outputText value="#{(tn.qty eq null)?0:tn.qty}"/>
                      </rich:column>
                      <rich:column>
                           <f:facet name="header"><h:outputText value="Unit"/></f:facet>
                           <h:outputText value="#{tn.item.unit}"/>
                      </rich:column>
                      <rich:column>
                           <f:facet name="header"><h:outputText value="CurrentQty"/></f:facet>
                           <h:outputText value="#{(tn.onhandQty eq null)?0:tn.onhandQty}"/>
                      </rich:column>
                      <rich:column>
                           <f:facet name="header"><h:outputText value="Oper"/></f:facet>
                           <h:outputText value="#{tn.user.name}"/>
                      </rich:column>
                      <rich:column title="#{tn.batchno}">
                           <f:facet name="header"><h:outputText value="BatchNo"/></f:facet>
                           <h:outputText value="#{tn.batchno}"/>
                      </rich:column>
                      <rich:column title="#{tn.datetime}">
                           <f:facet name="header"><h:outputText value="DateTime"/></f:facet>
                           <h:outputText value="#{tn.datetime}" >
                           <s:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"/>
                           </h:outputText>
                      </rich:column>
                      <rich:column title="#{tn.productNo}">
                           <f:facet name="header"><h:outputText value="ProductNo"/></f:facet>
                           <h:outputText value="#{tn.productNo}"/>
                      </rich:column>
                           </rich:dataTable>
                 </h:form>
            
            
            tn.datetime is java.util.Date type.
            
            In JXLHelp.java 
            line 648
             return new DateTime(column, row, (Date) data, cellFormat);
            
            (Date)data cause exception.
            
            
            
            

            • 4. Re: excelExporter.export export datatime throw java.lang.String cannot be cast to java.util.Date
              Daniel Roth Apprentice

              This is probably a bug. I will look into it asap. I think the converter it the problem.

              • 5. Re: excelExporter.export export datatime throw java.lang.String cannot be cast to java.util.Date
                he youlin Novice

                Thanks.
                BWT since build about 2008-9-4 the Latest 2.1 Unstable seam is terribly  slow. I return the build 2008-9-4.



                And in the Latest 2.1 Unstable Nightly Build if i write identity.addRole(somerole) once more the role somerole will lost.


                • 6. Re: excelExporter.export export datatime throw java.lang.String cannot be cast to java.util.Date
                  Daniel Roth Apprentice

                  I change my mind. I added this to the example.


                  <rich:column>
                  <f:facet name="header">
                  <h:outputText value="Date" />
                  </f:facet>
                  <h:outputText value="#{person.date}" >
                  <s:convertDateTime pattern="yyyy-MM-dd"/>
                  </h:outputText>
                  </rich:column>
                  



                  (added public java.util.Date getDate() on Person as well). Works fine :-) Have you got the latest code etc? Otherwise I think you have to create an JIRA with an example on how to reproduce.


                  However, there is a bit of a mismatch between csv/jxl exporter. jxl may actually take a Date object as input. (The cell in excel will be of type date), but with the CSV exporter you will get the toString value.

                  • 7. Re: excelExporter.export export datatime throw java.lang.String cannot be cast to java.util.Date
                    Nicklas Karlsson Master

                    File a JIRA for the role disappearing.


                    And another for the performance if you can pinpoint it more closely with profiling etc.

                    • 8. Re: excelExporter.export export datatime throw java.lang.String cannot be cast to java.util.Date
                      Nicklas Karlsson Master

                      Yes, file a JIRA with the involved entities as well.


                      The casting is done only after it has been determined that the value indeed is a Date but perhaps there is a situation where the converter might have an undesired effect. But as I said, file a JIRA. If it can be reproduced, it can most probably be fixed.