Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in ajax  RSS feed

Subrata Pradhan
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!