Package pl.zgora.uz.wmie.fe.ajax.action

Source Code of pl.zgora.uz.wmie.fe.ajax.action.StanowiskaAjaxAction

package pl.zgora.uz.wmie.fe.ajax.action;

import java.util.Iterator;
import java.util.Map;

import javax.servlet.ServletContext;

import org.directwebremoting.ScriptSession;
import org.directwebremoting.ServerContext;
import org.directwebremoting.ServerContextFactory;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.directwebremoting.proxy.ScriptProxy;

import pl.zgora.uz.wmie.fe.bean.FilterBean;
import pl.zgora.uz.wmie.fe.service.StanowiskoService;
import pl.zgora.uz.wmie.fe.dto.FormAjaxResponse;
import pl.zgora.uz.wmie.fe.hbm.classes.Stanowisko;
import pl.zgora.uz.wmie.fe.util.BusinessUtil;

public class StanowiskaAjaxAction {
  public String deleteStanowiska(Integer id){
    try {
    StanowiskoService stanowiskoService = (StanowiskoService) BusinessUtil.findBusiness("StanowiskoService");
      stanowiskoService.deleteById(id);
    } catch (Exception e) {
      e.printStackTrace();
      return e.getCause().getMessage();
    }
    return "";
  }

 
  public FormAjaxResponse addStanowisko(Map<String, String> params){
    try {
      StanowiskoService stanowiskoService = (StanowiskoService) BusinessUtil.findBusiness("StanowiskoService");
      Stanowisko s =new Stanowisko();
      s.setNazwa(params.get("nazwaStanowiska").toString());
      stanowiskoService.save(s);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    FormAjaxResponse response = new FormAjaxResponse();
    response.setErrorCode(0);
   
    return response;
   
  }
 
  public String cos(){
    WebContext webContext = WebContextFactory.get();
    ServletContext servletContext = webContext.getServletContext();

    ServerContext serverContext = ServerContextFactory.get(servletContext);
    Iterator iterator = serverContext.getAllScriptSessions().iterator();
    String currentPage = webContext.getCurrentPage();
    serverContext.getScriptSessionsByPage(currentPage);
    while(iterator.hasNext()){
      ScriptProxy proxy = new ScriptProxy((ScriptSession) iterator.next());
      proxy.addFunctionCall("redirect");
    }
   
    return "miro";
  }
 
}
TOP

Related Classes of pl.zgora.uz.wmie.fe.ajax.action.StanowiskaAjaxAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.