This is the code of controller class and while running the deviceService returns null value. the deviceService should return some value in controller from service class.
@ManagedBean
@ViewScoped
public class DeviceController implements Serializable {
private Device device;
private List<Device> deviceList;
@ManagedProperty("#{deviceService}")
public DeviceService deviceService;
/**
* @return the deviceService
*/
public DeviceService getDeviceService() {
return deviceService;
}
/**
* @param deviceService the deviceService to set
*/
public void setDeviceService(DeviceService deviceService) {
this.deviceService = deviceService;
}
and this is deviceService class code
@Service("deviceService")
@Transactional(readOnly = true)
public class DeviceService {
@Autowired
IDeviceDao iDevice;
@Transactional(readOnly = false)
public void addDevice(Device device) {
iDevice.addDevice(device);
}
public List<Device> getDeviceList() {
return iDevice.getDeviceList();
}
@Transactional(readOnly = false)
public void deleteDevice(Device device) {
iDevice.deleteDevice(device);
}
}