Hi,
now i´m working with primefaces v3.M2. In my app I use p:calendar component as 'readonly' field. I have a problem with that, when users select a date, is imposible to unselect it ... i propose to add a button that clear the calendar, and unselect the previous date.
I found another problem with p:calendar, when click the 'today' button, ajax event doesnt´t work; only work fine when I select a date clicking over the number of the day.
Please help me out in this.
Thanks in advance
Reset date in a p:calendar
You have to make it not read-only for this to work right now. Can you make it not read-only? Should be more user-friendly then since users can just tab and enter the value directly. To clear the date you just submit an empty value
Primefaces 3.0.M3 with JSF 2.1.2 on Tomcat 7
You can initalize your Date member in construtor to the date you want and make the component readonly="true" (note in userguide: readonly, not "read-only")Should be more user-friendly then since users can just tab and enter the value directly.
and to prevent users to type anything use: readOnlyInputText="true". To be completely sure use minDate and maxDate to the Intialized value.
You just add a simple p:commandbutton with update={calndars`id} and an action that resets the beanValue, (method: String yourMethod() in your Bean) Make sure to return null to prevent navigation. Ready.Can someone add reset button to calendar?
Stay tuned.
Adam
Busy applying primefaces patches to my local repo at /dev/null
-
- Posts: 15
- Joined: 26 Jan 2012, 16:58
Placing a button is not enough, there are screens which do not accept adding another button.
It should be allowed to render a "Clear" button or any custom button
It should be allowed to render a "Clear" button or any custom button
You can do this with Javascript.
Here is the code...
Here is the Javascript...
Alternative Javascript
Here is the code...
Code: Select all
<p:calendar value="#{property.propDate}" id="date" readOnlyInputText="true" pattern="MM/dd/yyyy" size="15" widgetVar="dateVar" />
<p:spacer width="10" />
<p:commandLink value="Clear Date" onclick="javascript:clearDate();" />
Code: Select all
function clearDate() {
dateVar.setDate(null);
}
Code: Select all
function clearDate() {
document.getElementById("form1:date_input").value = "";
}
Prime Faces 6.2
Mojarra 2.2.14
Apache Tomcat 9.0
Internet Explorer 10,11
Mojarra 2.2.14
Apache Tomcat 9.0
Internet Explorer 10,11
-
- Information
-
Who is online
Users browsing this forum: No registered users and 39 guests