You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kishen Simbhoedatpanday <es...@gmail.com> on 2007/06/28 14:55:35 UTC
DateTimePicker (type time) problem
Hello,
We have a problem using the <s:datepicker> tag when it comes to modifying a
date and time.
It seems there is no solution in struts2 to edit a date + time with the
datepicker tag, so we use them separately.
In our Action class we have a attribute called "currentTimePart":
private Date currentDatePart;
private Date currentTimePart;
(getter and setter are available).
In our Action method we use the following code :
public String modify() throws Exception {
log.debug("view method called");
Date now = new Date();
this.setCurrentDatePart(now);
Calendar cal = Calendar.getInstance();
cal.setTime(now);
cal.set(Calendar.HOUR, 10);
cal.set(Calendar.MINUTE, 15);
this.setCurrentTimePart(cal.getTime());
return SUCCESS;
}
As you can see, the current date is set in a Calendar instance.
The HOUR and MINUTE are overriden and the currentTimePart is set.
We use the following tag in the JSP page:
<s:datetimepicker name="currentDatePart" displayFormat="dd-MM-yyyy"
theme="simple" />
<br />
<s:datetimepicker name="currentTimePart" displayFormat="HH:mm"
theme="simple" type="time"/>
(Notice the type="time" attribute.)
The page successfully shows a datePicker with the correct value, but the
timePicker shows the value "00:00".
It seems that the DateTimePicker component, in struts2 or dojo framework,
does not handle the time part of the given Date object correctly.
Can anyone help us out?
Thank you!
Greetz
Kishen (and co-workers)
Re: DateTimePicker (type time) problem
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Kishen Simbhoedatpanday wrote:
> I thought the displayFormat was for display purposes only.
> But "HH:mm" does not work when giving the currentTimePart "16:15".
> It still gives the "00:00"
>
>
My only remaining suggestion is that you create a page full of time
pickers and try all the possible combinations. In our case we always
set the value attribute explicitly (separate from the name attribute)
and it has been working for the "h:mm a" pattern.
On a side note, we stopped using the time-picker anyway because the
client didn't like it - two simple selects with hours and mins in them,
backed by a javascript function to encode/decode the values into a
single time string was their preference and would have been less effort
to start with. Besides the trouble integrating the time-picker into
your application, the usability is questionable (popop->click hour->pops
down->popup again->click minute->popdown). The only thing it has going
for it is that is looks nice.
We still use the date-picker but will replace it jsCalendar or Musachy's
YUI plugin the next chance we get.
> We also have the following issue...
> When we change the currentTimePart to "16:35" and submit the form, the
> currentTimePart value is: "2007-06-28T16:35:00+02:00".
>
Yeah, you'll have to parse it.
As I mentioned in a previous email, another option may be to use
javascript to concat the date component from the date picker with the
time component from a time picker, and post that value.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DateTimePicker (type time) problem
Posted by Kishen Simbhoedatpanday <es...@gmail.com>.
We are using Strings for now. Hopefully we will get a working component like
dateTimePicker that will automatically change a String to Dates (or
Calendars) and back soon.
I thought the displayFormat was for display purposes only.
But "HH:mm" does not work when giving the currentTimePart "16:15".
It still gives the "00:00"
We also have the following issue...
When we change the currentTimePart to "16:35" and submit the form, the
currentTimePart value is: "2007-06-28T16:35:00+02:00".
I guess we can get the time with SimpleDateFormat (pattern something like
"yyyy-MM-dd'T'HH:mm")?
Jeromy Evans - Blue Sky Minds wrote:
>
> Kishen Simbhoedatpanday wrote:
>> Thank you Jeromy!
>>
>> When using the 'displayFormat="h:mm a"' in the datetimepicker tag...
>>
>> So we set the following in our Action method:
>> this.setCurrentTimePart("16:15");
>>
> The exception is in the DateFormat.parse() method called by the
> DateTimePicker. "16:15" is an invalid because "h:mm a" is only a 12
> hour format. You need "HH:mm"
> See the javadoc for SimpleDateFormat for the description of the pattern.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/DateTimePicker-%28type-time%29-problem-tf3994225.html#a11345492
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DateTimePicker (type time) problem
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Kishen Simbhoedatpanday wrote:
> Thank you Jeromy!
>
> When using the 'displayFormat="h:mm a"' in the datetimepicker tag...
>
> So we set the following in our Action method:
> this.setCurrentTimePart("16:15");
>
The exception is in the DateFormat.parse() method called by the
DateTimePicker. "16:15" is an invalid because "h:mm a" is only a 12
hour format. You need "HH:mm"
See the javadoc for SimpleDateFormat for the description of the pattern.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DateTimePicker (type time) problem
Posted by Kishen Simbhoedatpanday <es...@gmail.com>.
Thank you Jeromy!
When using the 'displayFormat="h:mm a"' in the datetimepicker tag and
changing currentTimePart to String, it will result the given Hours and
Seconds on the page.
So we set the following in our Action method:
this.setCurrentTimePart("16:15");
But....
we get the following stacktrace:
2007-06-28 16:40:44,969 ERROR http-8080-Processor21
components.DateTimePicker.format(316) : Could not parse date
java.text.ParseException: Unparseable date: "16:15"
at java.text.DateFormat.parse(DateFormat.java:335)
at
org.apache.struts2.components.DateTimePicker.format(DateTimePicker.java:309)
at
org.apache.struts2.components.DateTimePicker.evaluateParams(DateTimePicker.java:209)
at org.apache.struts2.components.UIBean.end(UIBean.java:481)
at
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
.....
You got them too?
Jeromy Evans - Blue Sky Minds wrote:
>
> We use:
>
> <s:datetimepicker name="incomingAnswer" displayFormat="h:mm a"
> type="time"
> value="%{defaultAnswerTime}"
> required="true"/>
>
> where incomingAnswer and defaultAnswerTime are Strings in the hh:mm
> format. The string's components can then be applied to your Calendar
> object within the action.
>
> As discussed in recent threads, this version of the datetimepicker has a
> few issues that can avoided if you use String instead of Dates.
>
> An alternative you could try is to use javascript to combine/separate
> the value of the two datetimepickers to/from a single RFC3339 string, in
> which case the standard Date converter should work.
>
>
>
>
--
View this message in context: http://www.nabble.com/DateTimePicker-%28type-time%29-problem-tf3994225.html#a11344528
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DateTimePicker (type time) problem
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
We use:
<s:datetimepicker name="incomingAnswer" displayFormat="h:mm a"
type="time"
value="%{defaultAnswerTime}"
required="true"/>
where incomingAnswer and defaultAnswerTime are Strings in the hh:mm
format. The string's components can then be applied to your Calendar
object within the action.
As discussed in recent threads, this version of the datetimepicker has a
few issues that can avoided if you use String instead of Dates.
An alternative you could try is to use javascript to combine/separate
the value of the two datetimepickers to/from a single RFC3339 string, in
which case the standard Date converter should work.
eskape wrote:
> This problem does not concern initial values.
> It is about being able to edit the time part of the given Date object into
> the DateTimePicker component.
>
> When we want to edit the given Date ONLY, the DateTimePicker works fine.
> When using the DateTimePicker as a "TimePicker (<s:datetimepicker
> type="time" />)" there seems to be a problem setting the time part of the
> given date, resulting the "00:00" on the page.
>
> When we look at the rendered code we see that value of the DateTimePicker
> (currentTimePart) is "2007-06-28T00:00:00+02:00"
>
>
> Musachy Barroso wrote:
>
>> You need to set the initial value with the "value" attribute (or I'm
>> missing
>> something obvious here :) )
>>
>> regards
>> musachy
>>
>> On 6/28/07, Kishen Simbhoedatpanday <es...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> We have a problem using the <s:datepicker> tag when it comes to modifying
>>> a
>>> date and time.
>>> It seems there is no solution in struts2 to edit a date + time with the
>>> datepicker tag, so we use them separately.
>>>
>>> In our Action class we have a attribute called "currentTimePart":
>>>
>>> private Date currentDatePart;
>>> private Date currentTimePart;
>>> (getter and setter are available).
>>>
>>> In our Action method we use the following code :
>>>
>>> public String modify() throws Exception {
>>> log.debug("view method called");
>>>
>>> Date now = new Date();
>>> this.setCurrentDatePart(now);
>>> Calendar cal = Calendar.getInstance();
>>> cal.setTime(now);
>>> cal.set(Calendar.HOUR, 10);
>>> cal.set(Calendar.MINUTE, 15);
>>> this.setCurrentTimePart(cal.getTime());
>>>
>>> return SUCCESS;
>>> }
>>>
>>> As you can see, the current date is set in a Calendar instance.
>>> The HOUR and MINUTE are overriden and the currentTimePart is set.
>>>
>>> We use the following tag in the JSP page:
>>> <s:datetimepicker name="currentDatePart" displayFormat="dd-MM-yyyy"
>>> theme="simple" />
>>> <br />
>>> <s:datetimepicker name="currentTimePart" displayFormat="HH:mm"
>>> theme="simple" type="time"/>
>>> (Notice the type="time" attribute.)
>>>
>>> The page successfully shows a datePicker with the correct value, but the
>>> timePicker shows the value "00:00".
>>>
>>> It seems that the DateTimePicker component, in struts2 or dojo framework,
>>> does not handle the time part of the given Date object correctly.
>>>
>>> Can anyone help us out?
>>>
>>> Thank you!
>>>
>>> Greetz
>>> Kishen (and co-workers)
>>>
>>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DateTimePicker (type time) problem
Posted by eskape <es...@gmail.com>.
This problem does not concern initial values.
It is about being able to edit the time part of the given Date object into
the DateTimePicker component.
When we want to edit the given Date ONLY, the DateTimePicker works fine.
When using the DateTimePicker as a "TimePicker (<s:datetimepicker
type="time" />)" there seems to be a problem setting the time part of the
given date, resulting the "00:00" on the page.
When we look at the rendered code we see that value of the DateTimePicker
(currentTimePart) is "2007-06-28T00:00:00+02:00"
Musachy Barroso wrote:
>
> You need to set the initial value with the "value" attribute (or I'm
> missing
> something obvious here :) )
>
> regards
> musachy
>
> On 6/28/07, Kishen Simbhoedatpanday <es...@gmail.com> wrote:
>>
>> Hello,
>>
>> We have a problem using the <s:datepicker> tag when it comes to modifying
>> a
>> date and time.
>> It seems there is no solution in struts2 to edit a date + time with the
>> datepicker tag, so we use them separately.
>>
>> In our Action class we have a attribute called "currentTimePart":
>>
>> private Date currentDatePart;
>> private Date currentTimePart;
>> (getter and setter are available).
>>
>> In our Action method we use the following code :
>>
>> public String modify() throws Exception {
>> log.debug("view method called");
>>
>> Date now = new Date();
>> this.setCurrentDatePart(now);
>> Calendar cal = Calendar.getInstance();
>> cal.setTime(now);
>> cal.set(Calendar.HOUR, 10);
>> cal.set(Calendar.MINUTE, 15);
>> this.setCurrentTimePart(cal.getTime());
>>
>> return SUCCESS;
>> }
>>
>> As you can see, the current date is set in a Calendar instance.
>> The HOUR and MINUTE are overriden and the currentTimePart is set.
>>
>> We use the following tag in the JSP page:
>> <s:datetimepicker name="currentDatePart" displayFormat="dd-MM-yyyy"
>> theme="simple" />
>> <br />
>> <s:datetimepicker name="currentTimePart" displayFormat="HH:mm"
>> theme="simple" type="time"/>
>> (Notice the type="time" attribute.)
>>
>> The page successfully shows a datePicker with the correct value, but the
>> timePicker shows the value "00:00".
>>
>> It seems that the DateTimePicker component, in struts2 or dojo framework,
>> does not handle the time part of the given Date object correctly.
>>
>> Can anyone help us out?
>>
>> Thank you!
>>
>> Greetz
>> Kishen (and co-workers)
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
>
--
View this message in context: http://www.nabble.com/DateTimePicker-%28type-time%29-problem-tf3994225.html#a11343305
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DateTimePicker (type time) problem
Posted by Musachy Barroso <mu...@gmail.com>.
You need to set the initial value with the "value" attribute (or I'm missing
something obvious here :) )
regards
musachy
On 6/28/07, Kishen Simbhoedatpanday <es...@gmail.com> wrote:
>
> Hello,
>
> We have a problem using the <s:datepicker> tag when it comes to modifying
> a
> date and time.
> It seems there is no solution in struts2 to edit a date + time with the
> datepicker tag, so we use them separately.
>
> In our Action class we have a attribute called "currentTimePart":
>
> private Date currentDatePart;
> private Date currentTimePart;
> (getter and setter are available).
>
> In our Action method we use the following code :
>
> public String modify() throws Exception {
> log.debug("view method called");
>
> Date now = new Date();
> this.setCurrentDatePart(now);
> Calendar cal = Calendar.getInstance();
> cal.setTime(now);
> cal.set(Calendar.HOUR, 10);
> cal.set(Calendar.MINUTE, 15);
> this.setCurrentTimePart(cal.getTime());
>
> return SUCCESS;
> }
>
> As you can see, the current date is set in a Calendar instance.
> The HOUR and MINUTE are overriden and the currentTimePart is set.
>
> We use the following tag in the JSP page:
> <s:datetimepicker name="currentDatePart" displayFormat="dd-MM-yyyy"
> theme="simple" />
> <br />
> <s:datetimepicker name="currentTimePart" displayFormat="HH:mm"
> theme="simple" type="time"/>
> (Notice the type="time" attribute.)
>
> The page successfully shows a datePicker with the correct value, but the
> timePicker shows the value "00:00".
>
> It seems that the DateTimePicker component, in struts2 or dojo framework,
> does not handle the time part of the given Date object correctly.
>
> Can anyone help us out?
>
> Thank you!
>
> Greetz
> Kishen (and co-workers)
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd