ReadOnlyInput does not work in p: calendars

I use this:

<p:calendar id="popupCal" yearRange="c:c+1" lang="fr" required="true" requiredMessage="Date obligatoire" readonlyInput="true" navigator="true" pattern="dd-M-yyyy" locale="fr" showOn="both" value="#{commandeMB.commande.dateCmd}" mindate="#{commandeMB.todaysDate}" /> 

and as I wrote, I set readonyinput to true

I also tested readonly for true and both for true, but not for the result, you can always change the date

this is mistake?

Thank you in advane

+6
source share
4 answers

If you want this user to not be able to change the value of the Calendar Date, just view it and then use the showOn="none" attribute and readonly="true" in p:calender , I used it and its operation (I am using Primefaces 5.0, We hope that it will work on all versions):

+5
source

readonly used when you simply allow the user panel to select a date and cannot change the input date. If you want the user to not be able to change the date, you must use the disabled attribute to do this.

If you want the user to be able to see the date selection and not be able to change the date, you can disable dateelectevent with:

 <p:calendar onfocus="$('#ui-datepicker-div td').unbind();" readonly="true"/> 
+1
source

I actually found the problem as a casing string. In our application, it is readonlyInput and that is where it works. readOnlyInput no.

+1
source

With PF 3.4, this solution will be:

  • Keep opacity 1.0 in the read-only input field (i.e., not dim opacity with disabled = true);
  • Remove the Datepicker class from the field;
  • Disable events from the field.

(1) Create a function:

function setCalendarVis(readOnly) { if(readOnly) $('input:text').removeClass('hasDatepicker').unbind(); }

(2) Define the calendar component:

<p:calendar readonly="#{bean.readonly}" value="#{bean.datefield}" mode="popup"/>

(3) Call the function, for example, perhaps through the ajax event on p: databable:

<p:ajax event="rowDblselect" update="@form" oncomplete="setCalendarVis(#{bean.readonly});"/>

My application uses different styles for reading and writing: enter image description here

My use of unbind () is rather brute force. You can refine it to cancel only certain events.

Fire suit on!

0
source

Source: https://habr.com/ru/post/944614/


All Articles