wood burning stoves 2.0*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "problem in ajax " Watch "problem in ajax " New topic
Author

problem in ajax

Subrata Pradhan
Greenhorn

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.

shiftMaster.xhtml
<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"/>
</p:spinner>
<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" />
</p:spinner>
<putputLabel 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.
 
 
subject: problem in ajax