File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes problem in ajax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "problem in ajax " Watch "problem in ajax " New topic

problem in ajax

Subrata Pradhan

Joined: May 05, 2012
Posts: 8
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.

<h:form id="shiftForm">
<h:panelGrid columns="2">
<putputLabel 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"/>
<putputLabel 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" />
<putputLabel value="Shift Hours" for="shiftHours"/>
<h:inputText id="shiftHours" value="#{shiftMasterService.timeDifference}" style="align:right" readonly="true" />
<p:panelGrid columns="2" style="width:100%">
<f:facet name="footer">
<p:commandButton value="Save" update=":mainForm" oncomplete="dlg.hide()" action="#{}"/>

private Double startTime;
private Double endTime;
private Double shiftHours;

Setter getter

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;
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.
I agree. Here's the link:
subject: problem in ajax
It's not a secret anymore!