Hello I am newbie in
JSF. At present I am facing a strange problem when using ajax in my UI. I am getting null value of field which value sets by ajax operation in ManageBean Class. I am using jsf 2.1 with primefaces.
shiftMaster.xhtml
<h:form id="shiftForm">
<h:panelGrid columns="2">
<p:outputLabel value="Start time" for="startTime"/>
<p:spinner id="startTime" value="#{shiftMasterService.selectedShiftPojo.startTime}" min="00.00" max="24.00">
<f:ajax event="blur" render=":shiftHours" execute="startTime endTime"/>
</p:spinner>
<p:outputLabel value="End time" for="endTime"/>
<p:spinner id="endTime" widgetVar="eTime" value="#{shiftMasterService.selectedShiftPojo.endTime}" min="00.00" max="24.00">
<f:ajax event="blur" render=":shiftHours" execute="startTime endTime" />
</p:spinner>
<p:outputLabel value="Shift Hours" for="shiftHours"/>
<h:inputText id="shiftHours" value="#{shiftMasterService.timeDifference}" style="align:right" readonly="true" />
</h:panelGrid>
<p:panelGrid columns="2" style="width:100%">
<f:facet name="footer">
<p:commandButton value="Save" update=":mainForm" oncomplete="dlg.hide()" action="#{shiftMasterService.save()}"/>
</f:facet>
</p:panelGrid>
</h:form>
ShiftMasterPojo
private Double startTime;
private Double endTime;
private Double shiftHours;
Setter getter
ShiftMasterService
@ManagedBean(name="shiftMasterService")
@SessionScoped
public class ShiftMasterService {
private ShiftMasterPojo selectedShiftPojo;
setter getter
public Double getTimeDifference()
{
double timeDiff = 0.0;
System.out.println("GET TIME DIFFERENCE......");
if(selectedShiftPojo.getEndTime()==null && selectedShiftPojo.getStartTime()==null)
return timeDiff;
else
{
timeDiff = selectedShiftPojo.getEndTime() - selectedShiftPojo.getStartTime();
return timeDiff;
}
}
public void save()
{
System.out.println("Shift Hour>>"+selectedShiftPojo.getShiftHours());
new ShiftMasterDao().save(selectedShiftPojo);
}
}
When i am submit the Shiftform, getting null value of shiftHour field in save method of ManageBean Class(ShiftMasterService) . plzzz help me.