Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with rich:calendar

 
Adam Kronicki
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have problems with using the calendar tag from richfaces framework. On my page I have two calendars to select date range (to and from). However they don't seem to work properly. I have the following problems:

1. When I click on the 'pop-up' icon the calender shows and when I pick the date it closes. However when I try to click on it again nothing happens. Sth Like a 'one time opener'...
2. When I select the date, the month is always 00 (in the browser) and in Java bean code it's January (01).
3. Is it possible to initialize the two calender dates to cover the range of 'last month'? Could anyone provide me with a example code snippet for that?

Here is my jsp code:



I use JSF and Tomcat 6
 
Rudra Narayan Garnaik
Ranch Hand
Posts: 39
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adam,

Please folow the link for your problem:

Richfaces Calendar Demo

http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=calendar&skin=blueSky

or

http://livedemo.exadel.com/richfaces-demo/richfaces/calendar.jsf

It will help you.

As you asked:
1- 'one time opener' : May be problem with your browser.
2- As written - I am not sure why it is happening, but try again from scratch- that will not happen.
3- Is it possible to initialize the two calender dates to cover the range of 'last month'? - Yes you can- Just in your bean you have to create a default constructure and assign the date for your to & from date field. It is very easy.


Happy coing.

 
Adam Kronicki
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rudra Narayan Garnaik wrote:
3- Is it possible to initialize the two calender dates to cover the range of 'last month'? - Yes you can- Just in your bean you have to create a default constructure and assign the date for your to & from date field. It is very easy.

Well that part I know :> My question is: is it possible (how?) to get the current or 'today' date for the 'to' filed and then how to calc for the 'from' field.

edit: I saw that rich:calendar has Java API today() method. How can I call it inside the Bean Java class??
 
adil ourida
Greenhorn
Posts: 7
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

for the problem 00 for mounth try yyyy/MM/dd instead of yyyy/mm/dd. I wish it could help you
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

edit: I saw that rich:calendar has Java API today() method. How can I call it inside the Bean Java class??


Actually, I think "today()" is a JavaScript function that runs only on the client. The Java (server-side) equivalent would be:


Which, despite the name, is actually not just the date, but also the current time with millisecond precision. That why I like to name it "now".

The best way to get the date from a month earlier, however, is not to use Date, but to use the java Calendar classes - typically the GregorianCalendar, unless you're looking to date from the Hegira or some other less universal calendar. The Calendar object is also created with the current date/time, but there are functions to roll dates forward an backwards in days, months, years, and so forth.
 
Adam Kronicki
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:

edit: I saw that rich:calendar has Java API today() method. How can I call it inside the Bean Java class??


Actually, I think "today()" is a JavaScript function that runs only on the client. The Java (server-side) equivalent would be:


Which, despite the name, is actually not just the date, but also the current time with millisecond precision. That why I like to name it "now".

The best way to get the date from a month earlier, however, is not to use Date, but to use the java Calendar classes - typically the GregorianCalendar, unless you're looking to date from the Hegira or some other less universal calendar. The Calendar object is also created with the current date/time, but there are functions to roll dates forward an backwards in days, months, years, and so forth.


Yes I found this out :> I though it will be a JSF/RichFaces issue and it turned out to be plain Java knowledge shortage :> My code for now looks:



For 1&2 problems the change from mm to MM actually help. Weird but it works correct know...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic