How to make p:calendar set its value at manual input?

UI Components for JSF
Post Reply
RalfWohner
Posts: 7
Joined: 29 Jan 2016, 16:11

28 Jun 2017, 11:12

Hello there,

my Problem: In my page, there's a p:calendar with the (required) option to manually enter a date value. If the user does, the flyout calendar correctly reflects the date, but the value is not yet set in the component. That only happens if you click the highlighted date with the mouse, click somewhere else on the page or tab out of the input box.

Now, in this page, the calendar happens to be the last element, so people tend to just enter the date and then click the "Send" button without leaving the calendar input box first.

Obviously, now the "Send" button "wins the race against" the calendar setting its value, so the old value (null resp. the initial value) is sent to the Bean instead of the entered date.

Can anyone help? Is there a workaround?
I already added this to my "Send" button to simulate a click on the body, which helps in ~ 3/4 of the tests, but that's not secure enough for a production environment.

Code: Select all

onclick="document.getElementsByTagName('BODY')[0].click();"
Obviously now I have a race condition between the body click/calendar setting the value vs. the sending of the form.

Help would be greatly appreciated.

Best regards,

Ralf
Using PrimeFaces 5.1 (Extensions 2.0.0) / JBoss-JSF-API 2.2 on a Wildfly 8.1.0
Client Browsers range from IE10 to anything modern

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

29 Jun 2017, 13:08

Tried newer PF versions? Might have been an issue that already has been fixed

RalfWohner
Posts: 7
Joined: 29 Jan 2016, 16:11

07 Jul 2017, 10:34

Hi there,

maybe the solution I found helps someone:

My "Send" button was

Code: Select all

<h:commandButton action="#{myBean.saveButtonAction()}" onclick="document.getElementsByTagName('BODY')[0].click();" .../>
Now I replaced the "h-Button" by a "p-Link" without Ajax, but with a delay of .5 sec:

Code: Select all

<p:commandLink styleClass="vat-actionbutton vat-progress1" ajax="false" delay="500" .../>
Now it seems to work. The delay gives the

Code: Select all

<p:calendar .../>
time to blur and set its value before the form is submitted.

Obviously primefaces components work better together than with standard components.

Thanks anyway, hope it helps someone!

Ralf
Using PrimeFaces 5.1 (Extensions 2.0.0) / JBoss-JSF-API 2.2 on a Wildfly 8.1.0
Client Browsers range from IE10 to anything modern

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests