Calendar dateSelect time problem.

UI Components for JSF
Post Reply
phnxck
Posts: 1
Joined: 16 Jan 2013, 16:10

04 Feb 2013, 15:18

Hi. I am using calendar component with dateSelect event attached, as below:

Code: Select all

<p:calendar id="startDate" value="#{newModuleDateProposalController.chosenDate}" pattern="MM/dd/yyyy HH:mm" readonlyInput="true" required="true" label="Start Date" showButtonPanel="false">
    <p:ajax event="dateSelect" listener="#{newModuleDateProposalController.recalculateRecurrenceDates}" process="recurrenceManagement" update="dateProposal" />
</p:calendar>
The problem is, that when I at first choose date and time, everything is ok, but when I attempt to chose another date, somehow information about time gets lost, and validation error message follows:
"Start Date: '02/21/2013 ' could not be understood as a date and time."
I have to pick time again to get rid of the validation message.
However, when I remove dateSelect event declaration, all works great (time is not lost).
PrimeFaces 3.3
JSF Mojarra 2.1.16
JBoss AS 7.1

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

04 Feb 2013, 23:40

click URL below and read.

http://code.google.com/p/primefaces/wiki/MigrationGuide

also, when this change was introduced during development of PrimeFaces 3.5 (SNAPSHOT), I opened a forum topic about this and shared how I fixed this.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

adlofto
Posts: 3
Joined: 10 Apr 2013, 16:31

10 Apr 2013, 16:42

I don't believe you answered his question as I'm having the exact same issue:

Code: Select all

<p:calendar pattern="MM/dd/yyyy hh:mm a" showOn="button">
						<p:ajax event="dateSelect" update="updateval"
							popupIconOnly="true"
							listener="#{bean.listener}" />
					</p:calendar>
When you click the date the first time its all good but if you select another date in the popup, it will only pick the Date part and not the Time.

It works fine without the ajax event.

I see this topic discusses that as well: viewtopic.php?f=3&t=22982

Any updates on this?

[edit] I'm using Primefaces Version 3.5, Primefaces Mobile 0.9.3, jsf 2.0.10 [/edit]
Primefaces 3.5
Primefaces Mobile 0.9.3
Mojarra JSF 2.0.10
Weblogic 10.3.4

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

10 Apr 2013, 17:06

adlofto wrote:When you click the date the first time its all good but if you select another date in the popup, it will only pick the Date part and not the Time.

It works fine without the ajax event.

I see this topic discusses that as well: viewtopic.php?f=3&t=22982
Good point. Search issue tracker for this issue, and if you don't find it, then please add a new issue to issue tracker, and reference the forum topic URL of this forum topic, and you can also include the forum topic URL above as well in the new issue in issue tracker, and respond here with the new issue # 'and' new issue URL.
adlofto wrote:[edit] I'm using Primefaces Version 3.5, Primefaces Mobile 0.9.3, jsf 2.0.10 [/edit]
You could add this information to your signature like I did (and like many others have done already), so you don't have to provide this information in every response/question of yours. Right? :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

adlofto
Posts: 3
Joined: 10 Apr 2013, 16:31

10 Apr 2013, 17:26

smithh032772 wrote:
adlofto wrote:[edit] I'm using Primefaces Version 3.5, Primefaces Mobile 0.9.3, jsf 2.0.10 [/edit]
You could add this information to your signature like I did (and like many others have done already), so you don't have to provide this information in every response/question of yours. Right? :)
Good call! :D

I just registered since I'm starting to use Primefaces now. I checked issue tracker and could not find any mention of that problem so went ahead and submitted an issue:

https://code.google.com/p/primefaces/is ... 1365607411

I think I did it appropriately hehe.

Thanks for your help though!
Primefaces 3.5
Primefaces Mobile 0.9.3
Mojarra JSF 2.0.10
Weblogic 10.3.4

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

10 Apr 2013, 17:47

And I clicked Star on the issue that you created, so i will be informed of updates on that issue in issue tracker.

Earlier, I wanted to say, that I 'learned' long time ago to NOT use p:calendar for date 'and' time.

I use p:calendar for DATE and (PrimeFaces Extension) pe:timePicker for TIME. Maybe 1 year ago (or less/more), I went throughout my app and made sure p:calendar for DATE and pe:timePicker for TIME. I think I recognized this bug back then, and I needed/wanted p:ajax after enduser select DATE and TIME, so using 2 different components with their own p:ajax...fixed the issue for me.

So, in my app, I have the following:

for non-mobile devices

Code: Select all

<h:panelGrid columns="3" cellpadding="1" cellspacing="1">
    <h:outputText value="Trip Date/Time:" />
    <p:calendar id="tripDate" value="#{pf_ordersController.tripDate[0]}"
                mode="popup" showOn="focus"
                pattern="MM/dd/yyyy" navigator="true"
                size="10" label="Trip Date">
        <f:convertDateTime pattern="MM/dd/yyyy" />
        <p:ajax partialSubmit="false" event="dateSelect"
                listener="#{pf_ordersController.tripDateSelectedOnAddEdit}"
                update="@(.ui-panel) :orderEditForm:reportDate :orderEditForm:reportTime :orderEditForm:returnDate :orderEditForm:returnTime :orderEditForm:formMessages :orderEditForm:_ajax_status"/>
        <p:ajax partialSubmit="false"
                update="@(.ui-panel) :orderEditForm:formMessages :orderEditForm:_ajax_status"
                listener="#{pf_ordersController.tripDateChangedOnAddEdit}"/>
    </p:calendar>
    <pe:timePicker id="tripTime" value="#{pf_ordersController.tripTime[0]}"
                   label="Trip Time" mode="popup" showPeriod="true"
                   style="width: 80px;">
        <f:convertDateTime pattern="hh:mm a" />
    </pe:timePicker>
</h:panelGrid>
for mobile devices via HTML5 type="date" and type="time" (which opens dialog on mobile device...smile)

Code: Select all

<h:panelGrid columns="2" cellpadding="1" cellspacing="1">
    <h:outputText value="Trip Date:" />
    <p:inputText id="tripDateOnMobile"
                 value="#{pf_ordersController.tripDate[0]}"
                 label="Trip Date" type="date">
        <f:convertDateTime pattern="yyyy-MM-dd" />
        <p:ajax partialSubmit="false"
                update="@(.ui-panel) :orderEditForm:reportDateOnMobile :orderEditForm:reportTimeOnMobile :orderEditForm:returnDateOnMobile :orderEditForm:returnTimeOnMobile :orderEditForm:formMessages :orderEditForm:_ajax_status"
                listener="#{pf_ordersController.tripDateChangedOnAddEdit}"/>
    </p:inputText>
    <h:outputText value="Trip Time:" />
    <p:inputText id="tripTimeOnMobile"
                 value="#{pf_ordersController.tripTime[0]}"
                 label="Trip Time" type="time">
        <f:convertDateTime pattern="HH:mm" />
        <p:ajax partialSubmit="false"
                update="@(.ui-panel) :orderEditForm:formMessages :orderEditForm:_ajax_status"
                listener="#{pf_ordersController.tripTimeChangedOnAddEdit()}"/>
    </p:inputText>
</h:panelGrid>
you may ask, and how do you merge the date and time back into one java.util.Date value? Simple, use joda-time library/JAR!!! Google it, download it, and start using it!

Code: Select all

// tripDateTime
DateTime dt_tripTime = new DateTime(tripTime.get(0));
DateTime tripDateTime = new DateTime(tripDate.get(0)).withHourOfDay(dt_tripTime.getHourOfDay())
                        .withMinuteOfHour(dt_tripTime.getMinuteOfHour());
current.setTripDateTime(tripDateTime.toDate());
and you may ask, why do I have the following bean attributes referenced in the bean and xhtml?

Code: Select all

private List<Date> tripDate, tripTime
because, there is a page that I want to develop that require multiple dates/times to be entered by enduser, but that is still on the to-do list. In the meanwhile, I tweaked the static web page, running on the public web site, which uses CGI to send formmail to an email acct, which is monitored by this java web app, and data is downloaded and stored into the database via
a bean defined/marked with the following:

Code: Select all

@Singleton
@Lock(LockType.WRITE)
@AccessTimeout(value = 2, unit = TimeUnit.MINUTES) bean
and a @Schedule method on that/similar bean...learned to do this from TomEE committers. :)

So, not a real big need for the xhtml page to be developed...right now. :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

adlofto
Posts: 3
Joined: 10 Apr 2013, 16:31

10 Apr 2013, 18:56

I haven't looked into Primefaces Extensions at this point so I'll throw that on my TODO to check out. Thanks for the suggestions.
Primefaces 3.5
Primefaces Mobile 0.9.3
Mojarra JSF 2.0.10
Weblogic 10.3.4

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 72 guests