I have a JSF form with 2 dates. Start Date is required.
2 things I would need:
- When the End date is filled in --> Then the Days should be calculated and filled in.
- When the Days are filled in (example: 31) --> Then the End date should be filled in.
How can this be done in JSF?
My form:
<h:form id="date">
<h:panelGrid columns="3">
<p:outputLabel for="startDate" value="Start Date"/>
<p:calendar id="startDate" value="#{dateBean.startDate}" required="true" pattern="d MMM yyyy"/>
<p:message for="startDate"/>
<p:outputLabel for="endDate" value="End Date"/>
<p:calendar id="endDate" value="#{dateBean.endDate}" pattern="d MMM yyyy"/>
<p:message for="endDate"/>
<p:outputLabel for="days" value="Days"/>
<p:inputText id="days" value="#{dateBean.days}"/>
<p:message for="days"/>
</h:panelGrid>
</h:form>
My Bean:
@Named(value = "dateBean")
@SessionScoped
public class DateBean implements Serializable {
private static final long serialVersionUID = 1L;
private Date startDate;
private Date endDate;
private Integer days;
//getters and setters
...