Primefaces 3.0M1 on GlassFish v3 ,Mojarra 2.0.3 - NetBeans 6.9.1
I am not clear on how to navigate to a different page on dateSelectEvent listener in the Schedule component.
I am trying to do some validation on the date clicked and based on whether the date clicked is after today or not , the control needs to navigate to a different page. It works fine if i handle the event in a dialog. But i need to handle the events on the date click in a different page.
Any hints on how this can be done is highly appreciated.
<p:schedule value="#{scheduleController.eventModel}" editable="true" widgetVar="schedulerList"
id="scheduleEvents"
aspectRatio="1.9" slotMinutes="30" firstHour="7"
resizable="false" draggable="false"
eventSelectListener="#{eventStatusController.onEventSelect}"
dateSelectListener="#{searchAvailabilityController.onDateSelect}"
onDateSelectComplete="handleDateSelectComplete(xhr, status, args);"
>
</p:schedule>
function handleDateSelectComplete(xhr, status, args) {
if (args.validate) {
return "reserveVisit.xhtml";
}else{
alert(args.message);
}
}
public String onDateSelect(DateSelectEvent selectEvent) {
eventDate = selectEvent.getDate();
RequestContext reqCtx = RequestContext.getCurrentInstance();
if (checkIfSelectedDateIsValid(eventDate)) {
reqCtx.addCallbackParam("validate", true);
} else {
reqCtx.addCallbackParam("validate", false);
reqCtx.addCallbackParam("message", "Please select Valid Date");
}
return "reserveVisit.xhtml?faces-redirect=true";
}
Thanks,
Smitha
Navigating to different page on DateSelectEvent in Schedule
In onDateSelect() use some code like this (perhaps without
faces-redirect=true if you don't use post-redirect-get):
faces-redirect=true if you don't use post-redirect-get):
Code: Select all
FacesContext fc = FacesContext.getCurrentInstance();
NavigationHandler nav = fc.getApplication().getNavigationHandler();
nav.handleNavigation(fc, null, "/" + page + "?faces-redirect=true");
fc.renderResponse();
Last edited by healeyb on 28 Jun 2011, 17:54, edited 1 time in total.
-
- Posts: 3
- Joined: 24 Nov 2010, 18:24
Thank you so much for such a quick and accurate response. It works.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 50 guests