0

I use a calendar in h:commandButton. I need to update a PanelGroup based on the date selected from the commandButton (calendar). The corresponding code is as follows:

<h:commandButton styleClass="ui-tabs calendar-icons" onclick="generateCalender()">

    <f:setPropertyActionListener  target="dateValue" value="true"></f:setPropertyActionListener>

</h:commandButton>

<c:set var="formattedDate" value="#{dateValue == 'true' ? formatDate : currentDate}"/>

Each time i select a date, the panelGroup must be updated. But the page gets refreshed each time I clicked the button because the type = "submit" is the default type for h:commandButton. If I use the type = "button", f:setPropertyActionListener is not working.

Is there any way other than using f:setPropertyActionListener to set values when the command button is clicked and set the value for formattedDate based on the obtained value?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Divya
  • 69
  • 1
  • 7
  • Which JSF version are you using? As you've tagged Primefaces, there's a calendar component ready to use. – Aritz Mar 07 '16 at 14:20
  • I am using JSF2.0 version. For your kind information, I cannot use calendar component for this project. – Divya Mar 10 '16 at 07:45
  • I guess you want to perform an ajax request and show the calendar with javascript later on. Just use a `f:ajax` inside the command button and call the `generateCalender()` javascript function in the ajax `oncomplete` – Aritz Mar 10 '16 at 08:00

0 Answers0