I have an EO with attributes that are dates in the postgresql db.
invoiceBookedDate is a date. It is modeled as a LocalDate. In my UI, I have an AjaxDatePicker which appears to only create NSTimestamps. So I create a cover methods (setter and getter) that accept the NSTimestamp and convert LocalDates.
invoiceList = Invoice.fetchInvoices(versionListEC, ERXQ.equals(Invoice.INVOICE_BOOKED_DATE_KEY, theLocalDate()), null);
works beautifully to get the list of all Invoices booked on the date from the AjaxDatePicker.
but when I try to populate the JasperReport using the WOWODC 2010 example, I get errors.
public static Callable<File> createSingleDateReportTask(NSTimestamp theDate) {
NSLog.out.appendln("NSTimestamp theDate = " + theDate);
String myDate = mainDateFormatter.format(theDate);
LocalDate reportLocalDate = new LocalDate(myDate);
ERXFetchSpecification<Invoice> fs = new ERXFetchSpecification<Invoice>(Invoice.ENTITY_NAME,
ERXQ.equals(Invoice.INVOICE_BOOKED_DATE_KEY, reportLocalDate), null);
NSLog.out.appendln("fs = " + fs);
String reportDescription = "A report on Invoices booked on: ";
HashMap<String, Object> parameters = new HashMap<String, Object>();
parameters.put("reportDescription", reportDescription);
// Builder pattern for constructor since.
ERJRFetchSpecificationReportTask reportTask = new ERJRFetchSpecificationReportTask(fs, "BillingToday.jasper", parameters);
return reportTask;
}
I know the above qualifier works, as it is working to create the array that I use in the displayGroup.
Here is the error trace:
Jan 30 08:03:51 TheWorkTracker[56046] INFO NSLog - NSTimestamp theDate = 2010-12-06 00:00:00 Etc/GMT
Jan 30 08:03:51 TheWorkTracker[56046] INFO NSLog - fs = <class er.extensions.eof.ERXFetchSpecification(entityName=Invoice,
qualifier=(invoiceBookedDate = (org.joda.time.LocalDate)'2010-12-06'),
isDeep=true, usesDistinct=false,
sortOrdering=null,
hints=null,
_prefetchingRelationshipKeyPaths = null)>
Jan 30 08:03:51 TheWorkTracker[56046] INFO er.jrexample.controllers.AbstractPageController - Controller named 'er.jrexample.controllers.FileTaskDownloadController' just instantiated in page named 'com.eltek.components.TWTBilling_DailyReportComponent'
Jan 30 08:03:51 TheWorkTracker[56046] INFO NSLog - FileTaskDownloadController called
Jan 30 08:03:51 TheWorkTracker[56046] INFO NSLog - nextPageController called = Billing List
Jan 30 08:03:52 TheWorkTracker[56046] ERROR er.jasperreports.ERJRFetchSpecificationReportTask - Error in JR task
ClassCastException: com.eltek.utilities.LocalDate cannot be cast to java.util.Date
at BillingToday_1296250490999_974810.evaluate(BillingToday_1296250490999_974810:171)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:182)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:589)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:557)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:929)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:383)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:368)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:147)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:499)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:325)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:261)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:127)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:942)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:860)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:540)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdfFile(JasperRunManager.java:351)
at er.jasperreports.ERJRUtilities.runCompiledReportToPDFFile(ERJRUtilities.java:54)
at er.jasperreports.ERJRFetchSpecificationReportTask._call(ERJRFetchSpecificationReportTask.java:131)
at er.jasperreports.ERJRFetchSpecificationReportTask.call(ERJRFetchSpecificationReportTask.java:98)
at er.jasperreports.ERJRFetchSpecificationReportTask.call(ERJRFetchSpecificationReportTask.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
... skipped 1 stack elements
nextPage action fired
Jan 30 08:03:53 TheWorkTracker[56046] ERROR er.jrexample.components.GenericAjaxLongResponsePage - Long Response Error:
{}
ClassCastException: com.eltek.utilities.LocalDate cannot be cast to java.util.Date
at BillingToday_1296250490999_974810.evaluate(BillingToday_1296250490999_974810:171)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:182)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:589)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:557)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:929)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:383)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:368)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:147)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:499)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:325)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:261)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:127)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:942)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:860)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:540)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdfFile(JasperRunManager.java:351)
at er.jasperreports.ERJRUtilities.runCompiledReportToPDFFile(ERJRUtilities.java:54)
at er.jasperreports.ERJRFetchSpecificationReportTask._call(ERJRFetchSpecificationReportTask.java:131)
at er.jasperreports.ERJRFetchSpecificationReportTask.call(ERJRFetchSpecificationReportTask.java:98)
at er.jasperreports.ERJRFetchSpecificationReportTask.call(ERJRFetchSpecificationReportTask.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
... skipped 1 stack elements
Jan 30 08:03:54 TheWorkTracker[56046] ERROR er.jrexample.controllers.FileTaskDownloadController - Error
what can I do? I am lost.
Ted
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobje...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/webobjects-dev-garchive-31333%40googlegroups.com
This email sent to webobjects-dev...@googlegroups.com
> Jan 30 08:03:52 TheWorkTracker[56046] ERROR er.jasperreports.ERJRFetchSpecificationReportTask - Error in JR task
> ClassCastException: com.eltek.utilities.LocalDate cannot be cast to java.util.Date
From what class com.eltek.utilities.LocalDate inherits? If it's from JodaTime's LocalDate, well that class don't inherits from java.util.Date!
> http://lists.apple.com/mailman/options/webobjects-dev/probert%40macti.ca
>
> This email sent to pro...@macti.ca
I am using the Joda example that was discussed before (from the Henrique Prange example).
With the information you gave me, this is what I did.
googled java class inheritance to learn what this is:
The syntax for creating a subclass is simple. At the beginning of your class declaration, use the extends keyword, followed by the name of the class to inherit from:
class MountainBike extends Bicycle {
// new fields and methods defining a mountain bike would go here
}
so what do I have in LocalTime:
/**
* LocalDate custom type.
*
* @author <a href="mailto:hpr...@gmail.com">Henrique Prange</a>
*/
public class LocalDate implements ReadablePartial, Comparable<Object>
{
}
great the example never mentions implements. so googling "java class extends implements" gives a tutorial:
class MyClass extends MySuperClass implements YourInterface {
//field, constructor, and method declarations
}
So my attempt is to add into LocalDate the extends like this:
public class LocalDate extends java.util.Date implements ReadablePartial, Comparable<Object>
{
}
but then there is an error:
- The interface Comparable cannot be implemented more than once with different arguments: Comparable<Date> and
Comparable<Object>
so I checked the docs on java.util.Date:
public class Date
extends Object
implements Serializable, Cloneable, Comparable<Date>
so he implements Comparable<Date> but LocalDate had Comparable<Object>.
I hate this stuff. So I deleted Comparable from LocalDate and now there is an error with a method:
Name clash: The method compareTo(Object) of type LocalDate has the same erasure as compareTo(T) of type Comparable<T> but does
not override it
I made the executive decision to comment out the compareTo() method in LocalDate.
And to my complete surprise, it works.
But without your help reading the error log, I didn't even have an idea where to start looking.
Of course, maybe my hacking is actually making things worse. I guess I will have to keep my fingers crossed and hope youse guys don't get too tired helping people like me.
Thank you,
Ted
--- On Sun, 1/30/11, Pascal Robert <pro...@macti.ca> wrote:
What was the actual method signature of the LocalDate compareTo method? I'm guessing was "compareTo(Object obj)" or similar. By commenting it out you're no longer overriding it with a clashing class name. Now when compareTo is called, it's using the compareTo method on Date instead, which is likely what you want anyway.
Now, on the question of changing LocalDate from extending Joda LocalDate to java.util.Date, is an entirely different thing... can't help you there.
Dave
On Jan 30, 2011, at 8:31 AM, Theodore Petrosky wrote:
> Name clash: The method compareTo(Object) of type LocalDate has the same erasure as compareTo(T) of type Comparable<T> but does
> not override it
_______________________________________________
> I have an EO with attributes that are dates in the postgresql db.
>
> invoiceBookedDate is a date. It is modeled as a LocalDate.
This sounds right. (I'm assuming that you've followed Henrique's example closely, and that "LocalDate" there is in some package of your own, and that it contains an org.joda.time.LocalDate as a private field. Looks like it from your stack trace.)
> In my UI, I have an AjaxDatePicker which appears to only create NSTimestamps. So I create a cover methods (setter and getter) that accept the NSTimestamp and convert LocalDates.
As an aside, that's probably alright just going to or from the UI, but be careful. The point of the LocalDate exercise was to avoid the problems that arise representing a 1-day resolution date as full-resolution timestamp.
> invoiceList = Invoice.fetchInvoices(versionListEC, ERXQ.equals(Invoice.INVOICE_BOOKED_DATE_KEY, theLocalDate()), null);
>
> works beautifully to get the list of all Invoices booked on the date from the AjaxDatePicker.
That's a good sign. As you observe, you should be able to use LocalDates directly in qualifiers. It suggests you've set up the custom attribute type correctly.
> but when I try to populate the JasperReport using the WOWODC 2010 example, I get errors.
I've never used JasperReports, so I don't have much to offer from this point onwards.
> Jan 30 08:03:52 TheWorkTracker[56046] ERROR er.jasperreports.ERJRFetchSpecificationReportTask - Error in JR task
> ClassCastException: com.eltek.utilities.LocalDate cannot be cast to java.util.Date
> at BillingToday_1296250490999_974810.evaluate(BillingToday_1296250490999_974810:171)
So the exception is coming from somewhere deep within JasperReports. Again, I don't know anything about how it works, but I'd be asking why JR is trying to cast that to a Date. Have you told it to expect some attribute to be a java.util.Date?
--
Paul.
> So my attempt is to add into LocalDate the extends like this:
>
> public class LocalDate extends java.util.Date implements ReadablePartial, Comparable<Object>
> {
>
> }
I don't think you need or want to do this. I don't think your LocalDate wrapper (which, for those who haven't looked at Henrique's example, just extends java.lang.Object, implements ReadablePartial, Comparable<Object>, and contains a private field of type org.joda.time.LocalDate) should be a subclass of Date, which is a full-resolution timestamp type.
> but then there is an error:
>
> - The interface Comparable cannot be implemented more than once with different arguments: Comparable<Date> and
> Comparable<Object>
>
> so I checked the docs on java.util.Date:
>
> public class Date
> extends Object
> implements Serializable, Cloneable, Comparable<Date>
>
> so he implements Comparable<Date> but LocalDate had Comparable<Object>.
>
> I hate this stuff. So I deleted Comparable from LocalDate and now there is an error with a method:
>
> Name clash: The method compareTo(Object) of type LocalDate has the same erasure as compareTo(T) of type Comparable<T> but does
> not override it
>
> I made the executive decision to comment out the compareTo() method in LocalDate.
>
> And to my complete surprise, it works.
Unfortunately, that's likely to be just some good luck. It may well work in this case, but it doesn't seem right to me (or necessary). I would go back and ask why JasperReports is _expecting_ to be able to cast some value to a Date.
--
Paul.
Thank you for looking at my attempts.
I am using the JasperReports example that Kieran Kelleher created for WOWODC 2010 as my starting point. It is helpful not only for the beginning steps for integrating JR but figuring out iReport to create the report templates.
He mentions in the presentation that there will be a fuller example committed to Wonder and perhaps this issue is already addressed. However, in the meantime, I will continue reading the limited documentation on JasperReports and follow the code to see if I can figure out why I get this error.
Of course if I just forget about the date resolution issue and use timestamps the issue goes away, but I have to deal with my app refusing to work when I switch platforms. So I could spend the time learning the methods of getting around the Java dateTime issues.
Thanks again.
Ted
--- On Mon, 1/31/11, Paul Hoadley <pa...@logicsquad.net> wrote:
> From: Paul Hoadley <pa...@logicsquad.net>
> Subject: Re: JasperReport LocalDate question
> To: "Theodore Petrosky" <ted...@yahoo.com>
On Jan 30, 2011, at 3:33 PM, John Huss wrote:
> People have been doing WO apps withOUT Joda for a long time
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobje...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
First, sorry, but the API compatible example is not yet committed to Wonder. Long story short, I have been too busy with my work, but it is still on my TO DO list and I am feeling anxious (aka., motivated) to get it done as soon as I get a chance which may be sooner rather than later. Meanwhile the original pre-Wonder framework and working example are still available in the http://montreal2010.googlecode.com/svn/trunk/ SVN repository and can be checked out into a separate workspace for playing with and learning.
OK, now back to your problem. Your problem is easily solvable by using the Joda class for your field definition inside your iReport template.
To find out how, just go to the JasperReports video at about 39 minutes in and listen to the discussion about NSTimestamp, which iReport knows nothing about either. In the video, it shows you how to add apple Foundation classes to iReports classpath so that you can use NSTimestamp in your report template as a field class definition. Use the same procedure to add the JodaTime jar to the iReport classpath and thenuse the LocalDate class for the 'Field Class' in the field Properties settings in iReport.
To help you get concepts, note also the discussion about BigDecimal and class cast exception around 42:15 on the video timeline.
HTH, Kieran
PS. The fact that we *don't have to* use NSTimestamp and that we can use java.util.Date as a field class type insdie iReport is because NSTimestamp EXTENDS java.util.Date.
> http://lists.apple.com/mailman/options/webobjects-dev/kelleherk%40gmail.com
>
> This email sent to kell...@gmail.com
I think John mean "without Joda" in that sentence.... People have been using WO without Joda for a ling time.
On Jan 30, 2011, at 3:33 PM, John Huss wrote:
> People have been doing WO apps withOUT Joda for a long time
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobje...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
Thank you for all your hard work on JasperReports. I am sure the process is time consuming.
So if I understand the sequence from the video, I put both javafoundation.jar and joda-time-1.6.2.jar in the folder with iReport and link to them with the preference/class path preference.
Will the appropriate class types show up in the Property => Field Class? I am able to type in the field name manually however no classes show in the list (other than the defaults).
and what about the Text Field? I can not change the Expression Class to match the Field's class.
I hope you have time to help me with this.
Ted
--- On Mon, 1/31/11, Kieran Kelleher <kell...@gmail.com> wrote:
> Kieran,
>
> Thank you for all your hard work on JasperReports. I am sure the process is time consuming.
>
> So if I understand the sequence from the video, I put both javafoundation.jar and joda-time-1.6.2.jar in the folder with iReport and link to them with the preference/class path preference.
No. The video links javafoundation as an example to show how to make NSTimestamp class available in iReport designer. You just need to follow the same procedure and link joda-time into iReport classpath to make your LocalDate class available in iReport.
>
> Will the appropriate class types show up in the Property => Field Class? I am able to type in the field name manually however no classes show in the list (other than the defaults).
IIRC, only the built-in class types show up in the list. Just type in the fully qualified class name .... org.jodatime.Whatever into the Field class or Expression class. When you compile the template in iReport, you will get a compilation error if it cannot find the class in the classpath.
so far so good, but I can only select the built-in classes for the Expression Class of the TextField. so yes I get a compile time error.
I am doing something wrong.
Ted
I used the org.joda.time.LocalDate for the Field Class Definition. I still get the compile time error that it can not cast from LocalDate to java.util.Date:
So I tried changing to an NSTimestamp to see if I installed the jars correctly and Voila. No compilation errors. So it looks like Joda LocalDate does not Extend java.util.Date.
We have entered the world of, "I have no idea where to go now".
Thanks for your help.
Ted
Compilation exceptions: com.jaspersoft.ireport.designer.compiler.ErrorsCollector@d8a9586 net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. Cannot cast from LocalDate to Date value = (java.util.Date)(((org.joda.time.LocalDate)field_invoiceDateTimestamp.getValue())); //$JR_EXPR_ID=12$ <--------------------------------------------------------------------------------> 2. Cannot cast from LocalDate to Date value = (java.util.Date)(((org.joda.time.LocalDate)field_invoiceDateTimestamp.getOldValue())); //$JR_EXPR_ID=12$ <-----------------------------------------------------------------------------------> 3. Cannot cast from LocalDate to Date
value = (java.util.Date)(((org.joda.time.LocalDate)field_invoiceDateTimestamp.getValue())); //$JR_EXPR_ID=12$ <--------------------------------------------------------------------------------> 3 errors at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:191) at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:498) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
--- On Mon, 1/31/11, Kieran Kelleher <kell...@gmail.com> wrote:
I am sure that somewhere in your template you have defined either a (1) Field Class, or (2) an Expression class as a Date, or possibly (3) you are using a joda LocalDate in an expression function that takes a param of a Date. This is not a bug. You are doing something wrong.
Your error messages are giving you a clue:
value = (java.util.Date)(((org.joda.time.LocalDate)field_invoiceDateTimestamp.getValue()));
that expression simply will not work. LocalDate cannot be cast to a Date.
I have not worked with Jasper for a few months, so details might be a little fuzzy, but if for example you want a group by, or order by expression derived from a LocalDate, then you can convert it to a simple String, Long or Integer and group/order on that result...... for example, assuming "field_invoiceDateTimestamp" is a joda LocalDate......
[Long] value = Long.valueOf( field_invoiceDateTimestamp.getLocalMillis() );
OR
[String] value = field_invoiceDateTimestamp.toString();
Not sure what you are trying to do with it. In any case, you need to work directly with LocalDate class and its methods and forget about java.util.Date since Joda LocalTime is not a Date and cannot be cast to a Date since it does not subclass Date.
-Kieran
At this point, I really have to second John Huss' recommendation that you take a time-out from development and get a more thorough understanding of Java. You are missing key points that people are making because you don't recognize them as key points. For example, In the very first response to your question, Pascal told you that LocalDate does not extend java.util.Date. You also didn't catch that Kieran's in comment about including other classes javafoundation.jar was only there in support of NSTimestamp and wouldn't apply to a non-WO class like Joda's LocalDate.
I personally came to WO without a strong programming background and it was _very_ difficult for me (go find some of my posts from 2004-2005!) until I took a step back and read a few books on Java and Object Oriented programming. I wrote literally thousands of lines of code that I ended up throwing away because I didn't fully comprehend OO programming or I was working against WO. (Head First Java was the book that brought it all together for me and made it make sense) Don't make the mistake I did.
WO is an amazing technology that will help a reasonably knowledgeable developer quickly do things that would take a coding guru a huge amount of time in any other technology. But in the hands of a complete novice, it will suck up a huge amount of your time and effort and you'll end up with something that will likely never work the way you want it to.
This list is one of the best development resources ever. The greatest minds in WO read and contribute to this list every day (Chuck does too) and they don't expect me, you or anyone to be an expert. You don't have to understand Practical WebObjects, but you do need to understand the core concepts OO programming. I think you'll be a much happier and far more productive WO developer if you take some time to reinforce the basics before you try to understand the requeust-response loop (I still haven't fully parsed that one yet) or make effective use of an experimental framework like ERJasperReports.
Please don't get me wrong, there is always a place here for new developers asking questions about the basics. After all, those are the questions that I actually have a shot at being able answer! Take a step back, don't try to implement the world.
Yet. :-)
Dave
On Feb 1, 2011, at 9:38 AM, Theodore Petrosky wrote:
> http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com
>
> This email sent to webob...@avendasora.com
On 02/02/2011, at 1:08 AM, Theodore Petrosky wrote:
> I used the org.joda.time.LocalDate for the Field Class Definition.
Don't you want to be using your wrapper class for LocalDate, not Joda's LocalDate? This name collision is unfortunate—when I borrowed the code from Henrique's sample project, I renamed the wrapper class to LSLocalDate to avoid just this confusion. It's the wrapper class that's in your model, and that is presumably being handed to JR.
> I still get the compile time error that it can not cast from LocalDate to java.util.Date:
Of course, that doesn't explain why JR is still trying to cast it to a Date. I just don't know enough to help there.
> So I tried changing to an NSTimestamp to see if I installed the jars correctly and Voila. No compilation errors. So it looks like Joda LocalDate does not Extend java.util.Date.
It certainly doesn't. Nor does your wrapper class. Nor should they.
> We have entered the world of, "I have no idea where to go now".
That's disappointing (mostly for you!), because the Joda LocalDate class works just fine as a custom attribute type, and solves exactly your original problem. I'm sorry I don't know enough about JR to help you integrate it there.
--
Paul.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobje...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
For instance. there are two places one needs to tell iReport about the class definitions.
1. in the creation of the Field Variables. first you give it a name then the Field Class. In this case org.joda.time.LocalDate.
2. then you apply the Field variable to a Text Field. The Text Field has both a Text Field Expression and an Expression Class. This is where I am falling down. The Expression Class is not editable. You can only choose from the internal list of Classes. (java.util.Date, java.lang.String,…etc)
In the last email from Kieren(sp) he mentions some possibilities for applying class to the Field Variable. So I am in the process of reading as much as possible on iReport and JodaTime as well as looking at the methods available in LocalDart.
I think it is fantastic that Henrique's example allows me to use dates in my backend. That said, I guess I could add some accessors to my WO model that vend out NSTimestamp just for this. Then I am done.
I really wanted (and want) to learn how to use the JodaTime (LocalDate) in iReport.
Ted
--- On Tue, 2/1/11, Paul Hoadley <pa...@logicsquad.net> wrote:
> From: Paul Hoadley <pa...@logicsquad.net>
> Subject: Re: JasperReport LocalDate question
> To: "Theodore Petrosky" <ted...@yahoo.com>
> Cc: "WebObjects-Dev Mailing List List" <webobje...@lists.apple.com>
public NSTimestamp invoiceBDTimestamp() {
DateTime dt = new DateTime(invoiceBookedDate().toString());
NSTimestamp theIBDTS = new NSTimestamp(dt.getMillis());
return theIBDTS;
}
Now I can access it as an NSTimestamp in iReport. Problem is gone.
Ted
--- On Tue, 2/1/11, Paul Hoadley <pa...@logicsquad.net> wrote:
> From: Paul Hoadley <pa...@logicsquad.net>
> Subject: Re: JasperReport LocalDate question
> To: "Theodore Petrosky" <ted...@yahoo.com>
> Cc: "WebObjects-Dev Mailing List List" <webobje...@lists.apple.com>
> Date: Tuesday, February 1, 2011, 5:35 PM
> so that's what I just tried. a cover method to access the LocalDate
>
>
> public NSTimestamp invoiceBDTimestamp() {
> DateTime dt = new DateTime(invoiceBookedDate().toString());
> NSTimestamp theIBDTS = new NSTimestamp(dt.getMillis());
>
> return theIBDTS;
> }
>
> Now I can access it as an NSTimestamp in iReport. Problem is gone.
The Problem is not seen. :-) Now you have a point in time again, which means the date can change with changes in time zone and day light savings time.
Chuck
> http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
>
> This email sent to ch...@global-village.net
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects
> 2. then you apply the Field variable to a Text Field. The Text Field has both a Text Field Expression and an Expression Class. This is where I am falling down. The Expression Class is not editable. You can only choose from the internal list of Classes. (java.util.Date, java.lang.String,…etc)
Choose a String! Your LocalDate wrapper should be able to display itself as a String just fine.