Reputation: 2174
I use this (PrimeFaces, Java, JSF):
<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 readonlyInput
to true
.
I tested also readonly
to true
and both to true
but no result, always the date can be changed.
Is it a bug?
Upvotes: 7
Views: 14262
Reputation: 9
This is how I achieved read only behaviour:
<p-calendar [readonlyInput]="true" [showOnFocus]="false">
Upvotes: -2
Reputation: 1
Just add [readonlyInput]="true"
attribute in the input.
Example:
<p-calendar [readonlyInput]="true">
Upvotes: -2
Reputation: 61
If you want that user must not be able to change the value of the Calender Dates, just view it then use showOn="none"
and readonly="true"
in p:calender
attribute, I have used it and its working (I'm using Primefaces 5.0 hope it works on all versions) :
Upvotes: 6
Reputation: 11
Actually I've found the issue to be casing. In our app, it's readonlyInput and that's where it works. readOnlyInput does not.
Upvotes: 1
Reputation: 939
With PF 3.4, this solution will:
(1) Create a function:
function setCalendarVis(readOnly) {
if(readOnly)
$('input:text').removeClass('hasDatepicker').unbind();
}
(2) Define a calendar component:
<p:calendar readonly="#{bean.readonly}" value="#{bean.datefield}" mode="popup"/>
(3) Call the function, for example, maybe via an ajax event on a p:databable:
<p:ajax event="rowDblselect" update="@form" oncomplete="setCalendarVis(#{bean.readonly});"/>
My app uses different styles for read and write capability:
My use of unbind() is rather brute force. You can refine it to unbind only particular events.
Flame suit on!
Upvotes: 0
Reputation: 4189
readonly
is used when you just allow user use panel to pick date and can not change date from input. If you want user can not change date, you have to use disabled
attribute to do that.
If you want user can see date picker and can not change date, you can disable dateselectevent via:
<p:calendar onfocus="$('#ui-datepicker-div td').unbind();" readonly="true"/>
Upvotes: 1