Example usage for org.springframework.web.jsf FacesContextUtils getWebApplicationContext

List of usage examples for org.springframework.web.jsf FacesContextUtils getWebApplicationContext

Introduction

In this page you can find the example usage for org.springframework.web.jsf FacesContextUtils getWebApplicationContext.

Prototype

@Nullable
public static WebApplicationContext getWebApplicationContext(FacesContext fc) 

Source Link

Document

Find the root WebApplicationContext for this web app, typically loaded via org.springframework.web.context.ContextLoaderListener .

Usage

From source file:com.artemisa.web.converter.ProductoConverter.java

@Override
public IBaseService getBaseService(FacesContext tx) {
    return (IBaseService) FacesContextUtils.getWebApplicationContext(tx).getBean("productoServiceImpl");
}

From source file:com.ilkgunel.hastaneotomasyonu.controller.GetCities.java

public List<String> fillList() {
    ApplicationContext context = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
    CitiesService citiesService = (CitiesService) context.getBean("citiesService");
    return citiesService.getAllCityNames();
}

From source file:pl.chilldev.web.spring.context.SpringBeansFacesPageMetaModelResolver.java

/**
 * {@inheritDoc}/*  w  ww  .j  a v  a2  s  . com*/
 *
 * @since 0.0.3
 */
@Override
public PageMetaModel getPageMetaModel(FaceletContext context) throws PageMetaModelContextException {
    WebApplicationContext applicationContext = FacesContextUtils
            .getWebApplicationContext(context.getFacesContext());

    try {
        this.logger.debug("Taking PageMetaModel from Spring context.");
        return applicationContext.getBean(PageMetaModel.class);
    } catch (BeansException error) {
        this.logger.error("Error while fethcing page model from Spring context.", error);
        throw new PageMetaModelContextException("Error fetching page meta model from Spring context.", error);
    }
}

From source file:com.ilkgunel.hastaneotomasyonu.controller.GetAppointmentsOfPatient.java

public void fillList() throws Exception {
    ApplicationContext context = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
    TakenAppointmentsService takenAppointmentsService = (TakenAppointmentsService) context
            .getBean("takenAppointmnetsService");

    takenAppointmentsOfPatient = takenAppointmentsService
            .getAppointmentsOfPatient(saveAppointments.comingIdentityNumber);
}

From source file:com.ilkgunel.hastaneotomasyonu.service.DoctorService.java

public List<String> getAllDoctorNames(String clinic, String hospital) throws Exception {
    ApplicationContext context = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
    ClinicService clinicService = (ClinicService) context.getBean("clinicService");

    int clinicId = 0;
    for (Klinikler k : clinicService.getClinicResults()) {
        if (k.getKlinikadi().equals(clinic)) {
            clinicId = k.getId();/*w  w  w . java  2  s  .  com*/
            break;
        }
    }

    int hospitalId = 0;

    HospitalsService hospitalsService = (HospitalsService) context.getBean("hospitalService");

    for (Hastaneler h : hospitalsService.getHospitalResults()) {
        if (h.getHastaneadi().equals(hospital)) {
            hospitalId = h.getId();
        }
    }
    //doctorResults=new ArrayList<>();
    doctors = new ArrayList<>();
    Map map = new HashMap();
    map.put("clinicid", clinicId);
    map.put("hospitalid", hospitalId);
    doctorResults = doctorFacade.findListByNamedQuery("Doktorlar.findByBransIdAndHastaneID", map);

    for (Doktorlar d : doctorResults) {
        doctors.add(d.getDoktoradi());
    }
    return doctors;
}

From source file:com.ilkgunel.hastaneotomasyonu.controller.GetDistricts.java

public List<String> fillList() throws Exception {
    System.out.println("GetDistricts FillList metodu alt!");
    ApplicationContext context = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
    DistrictService districtService = (DistrictService) context.getBean("districtService");
    return districtService.getAllDistrictNames(saveAppointments.getCurrentCity());
}

From source file:com.ilkgunel.hastaneotomasyonu.controller.GetHospitals.java

public List<String> fillList() throws Exception {
    ApplicationContext context = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
    HospitalsService hospitalsService = (HospitalsService) context.getBean("hospitalService");
    return hospitalsService.getAllHospitalNames(saveAppointments.currentDistrict);
}

From source file:com.ilkgunel.hastaneotomasyonu.controller.GetAppointmentsOfPatient.java

public void cancelAppointment() {
    ApplicationContext context = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
    TakenAppointmentsService takenAppointmentsService = (TakenAppointmentsService) context
            .getBean("takenAppointmnetsService");

    FacesContext fc = FacesContext.getCurrentInstance();
    Map<String, String> params = fc.getExternalContext().getRequestParameterMap();
    cancelMessage = takenAppointmentsService
            .cancelAppointment(Integer.parseInt(params.get("takenAppointmentId")));

}

From source file:com.ilkgunel.hastaneotomasyonu.service.SaveAppointmentsService.java

public String saveAppointmentToDb(Takenappointments takenappointments) throws Exception {
    ApplicationContext context = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
    List<Randevusaatleri> appointmentClockResults = new ArrayList<>();
    String hour = "";
    int randevuid = 0;

    appointmentClockResults = randevuSaatleriFacade.findListByNamedQuery("Randevusaatleri.findAll");
    for (Randevusaatleri r : appointmentClockResults) {
        if (r.getSaatid() == takenappointments.getClockid()) {
            System.out.println("Saatin ID'si:" + takenappointments.getClockid());
            hour = r.getSaat();/*  w w w . j ava 2s .c  o m*/
            randevuid = r.getRandevuid();
            break;
        }
    }

    takenappointments.setHour(hour);
    //TypedQuery<Uygunrandevular> appointmentdIdQuery=em.createQuery("SELECT u FROM Uygunrandevular u WHERE u.uygunrandevuid=:appointmentid",Uygunrandevular.class);
    List<Uygunrandevular> appointmentIdResults = new ArrayList<>();
    Map parameters = new HashMap();
    parameters.put("uygunrandevuid", randevuid);
    // appointmentdIdQuery.setParameter("appointmentid", randevuid);
    appointmentIdResults = availableAppointmentsFacade
            .findListByNamedQuery("Uygunrandevular.findByUygunrandevuid", parameters);

    for (Uygunrandevular u : appointmentIdResults) {
        takenappointments.setDate(u.getTarih());
    }

    /*Query updateQuery=em.createQuery("UPDATE Randevusaatleri r SET r.saatalindimi=TRUE,r.title='DOLU' WHERE r.saatid=:clockId");
    updateQuery.setParameter("clockId", Integer.parseInt(clockId));
    int updateCount = query.executeUpdate();   
    if (updateCount > 0) {
        System.out.println("Done...");
    }*/
    //Randevusaatleri r=em.find(Randevusaatleri.class, Integer.parseInt(clockId));
    Randevusaatleri r = randevuSaatleriFacade.find(takenappointments.getClockid());
    r.setSaatalindimi(true);
    r.setTitle("DOLU");
    randevuSaatleriFacade.updateMemberInfo(r);
    //em.getTransaction().commit();

    String operationResult = takenAppointmentsFacade.create(takenappointments);

    GetAvaliableAppointments getAvaliableAppointments = new GetAvaliableAppointments();
    getAvaliableAppointments.changeRenderingStates();

    //        GetAvaliableAppointments getAvaliableAppointments=(GetAvaliableAppointments) context.getBean("getAvaliableAppointments");
    //        getAvaliableAppointments.changeRenderingStates();

    return operationResult;
}

From source file:tds.tdsadmin.web.backingbean.DefaultBacking.java

public DefaultBacking() {
    WebApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
    TDSAdminDAO tdsAdminDAO = ctx.getBean(TDSAdminDAO.class);
    controller = new TDSAdminController();
    this.controller.setDao(tdsAdminDAO);
    ITrClient trClient = ctx.getBean(ITrClient.class);
    this.controller.setTrClient(trClient);
    response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
    SbacUser user = (SbacUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    this.setRequestor(user.getEmail());
    if (trClient == null)
        _logger.error("DefaultBacking: TrClient is null");
    if (tdsAdminDAO == null)
        _logger.error("DefaultBacking: tdsAdminDAO is null");
}