Example usage for org.springframework.web.servlet ModelAndView ModelAndView

List of usage examples for org.springframework.web.servlet ModelAndView ModelAndView

Introduction

In this page you can find the example usage for org.springframework.web.servlet ModelAndView ModelAndView.

Prototype

public ModelAndView() 

Source Link

Document

Default constructor for bean-style usage: populating bean properties instead of passing in constructor arguments.

Usage

From source file:edu.bbu.security.web.controllers.MainController.java

@RequestMapping(value = "/admin**", method = RequestMethod.GET)
public ModelAndView adminPage() {
    System.out.println("lofasz admin");
    ModelAndView model = new ModelAndView();
    model.addObject("title", "Spring Security Custom Login Form");
    model.addObject("message", "This is protected page!");
    model.setViewName("admin");

    return model;

}

From source file:bfkltd.formulations.controller.CategoryController.java

@RequestMapping(value = "/categoryManager", method = RequestMethod.GET)
public ModelAndView categoryManager() {
    ModelAndView modelAndView = new ModelAndView();
    String output = buildCategory(0, "");
    modelAndView.addObject("categoryOutput", output);
    modelAndView.setViewName("category/categoryManager");
    return modelAndView;
}

From source file:com.mycompany.springmvcaccount.controller.UserController.java

@RequestMapping(value = "/register")
public ModelAndView showFormRegister() {
    ModelAndView mv = new ModelAndView();
    mv.addObject("user", new User());
    mv.addObject("gender", Gender.values());
    mv.addObject("countries", countries);
    mv.setViewName("registerForm");

    return mv;//from   w  w  w.  j  a v  a2 s . c  om
}

From source file:org.openmrs.hl7.web.controller.Hl7InArchiveMigrationController.java

/**
 * Adds data to the modelAndView object to be rendered in hl7 archive migrate page
 * //  ww  w  . java  2s .  c om
 * @return the modelAndView
 */
@RequestMapping(value = "/admin/hl7/hl7InArchiveMigration.htm")
public ModelAndView renderMigratePage() {

    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("/module/legacyui/admin/hl7/hl7InArchiveMigration");
    modelAndView.addObject("time_out", HL7Constants.THREAD_SLEEP_PERIOD);
    modelAndView.addObject("hl7_archives_dir", HL7Util.getHl7ArchivesDirectory().getAbsolutePath());
    modelAndView.addObject("migration_status", Hl7InArchivesMigrateThread.getTransferStatus().toString());
    modelAndView.addObject("isMigrationRunning", Hl7InArchivesMigrateThread.isActive());

    return modelAndView;
}

From source file:com.necl.core.controller.ReviseController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView getAdvancePage(@RequestParam String id) {

    try {//from   ww w . j  av  a 2s.  c  o m
        ModelAndView model = new ModelAndView();

        List<History> historyList = new ArrayList<>();
        historyList = historyService.findByTicketNo(id);
        DecimalFormat numFormat;
        numFormat = new DecimalFormat("#,##0.00");
        List<HistoryNumber> number2 = new ArrayList<>();

        for (int i = 0; i < historyList.size(); i++) {
            HistoryNumber number = new HistoryNumber();

            number.setTicketRev(historyList.get(i).getTicketRev());
            number.setDate(historyList.get(i).getDate());
            number.setApprovedName1(historyList.get(i).getApprovedName1());
            number.setApprovedRemark1(historyList.get(i).getApprovedRemark1());
            number.setApprovedName2(historyList.get(i).getApprovedName2());
            number.setApprovedRemark2(historyList.get(i).getApprovedRemark2());
            number.setReqTotalAmt(numFormat.format(historyList.get(i).getReqTotalAmt()));
            number2.add(number);
        }

        model.addObject("historyList", number2);
        model.setViewName("showrevise");
        return model;
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return null;
}

From source file:com.controller.UsuariosController.java

@RequestMapping("usuarios.htm")
public ModelAndView getListUsuarios(HttpServletRequest request) {
    ModelAndView mav = new ModelAndView();
    sesion = request.getSession();//  w  ww .ja  va  2  s . c  o  m
    if (sesion.getAttribute("usuario") == null) {
        mensaje = "Ingrese sus datos para poder ingresar al sistema";
        mav.addObject("mensaje", mensaje);
        mav.setViewName("login/login");

    } else {
        if (sesion.getAttribute("tipoUsuario").toString().compareTo("Administrador") == 0) {

            UsuariosDao userDao = new UsuariosDao();
            List<Usuarios> listUser = userDao.getAllUsuarios();
            mav.addObject("listaUsuarios", listUser);
            //sesion.setAttribute("listaUsuarios", listUser);
            mav.setViewName("usuarios/usuarios");
        } else {
            mav.setViewName("panel/panel");
        }
    }
    return mav;
}

From source file:com.ut.healthelink.controller.productSuiteController.java

/**
 * The '/health-e-net' request will display the health-e-net information page.
 *///from   w w  w  . ja v a  2 s.co m
@RequestMapping(value = "/health-e-net", method = RequestMethod.GET)
public ModelAndView healthenet() throws Exception {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("/healthenet");
    mav.addObject("pageTitle", "Health-e-Net");
    return mav;
}

From source file:com.neu.controller.AdditionSuccessController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    //throw new UnsupportedOperationException("Not yet implemented");
    int result = 0;
    DataSource ds = (DataSource) this.getApplicationContext().getBean("myDataSource");
    ModelAndView mv = new ModelAndView();
    HttpSession session = request.getSession();
    int count = (Integer) (session.getAttribute("count"));

    try {/*from www  .  jav  a 2  s .  c  om*/

        QueryRunner run = new QueryRunner(ds);
        ResultSetHandler<Books> books = new BeanHandler<Books>(Books.class);

        for (int i = 1; i <= count; i++) {

            String isbnField = "isbn" + i;
            String titleField = "title" + i;
            String authorField = "author" + i;
            String priceField = "price" + i;

            String isbn = request.getParameter(isbnField).replaceAll("<|>|@|;|,|=|}|$|&", "");
            String title = request.getParameter(titleField).replaceAll("<|>|@|;|,|=|}|$|&", "");
            String author = request.getParameter(authorField).replaceAll("<|>|@|;|,|=|}|$|&", "");
            float price = Float
                    .parseFloat(request.getParameter(priceField).replaceAll("<|>|@|;|,|=|}|$|&", ""));

            Object[] params = new Object[4];
            params[0] = isbn;
            params[1] = title;
            params[2] = author;
            params[3] = price;

            result = run.update("Insert into books(isbn,title,authors,price) values(?,?,?,?)", params);

        }
    } catch (Exception ex) {
        System.out.println("Details Not Added In DB!! " + ex.getMessage());
    }
    if (result > 0) {
        mv.setViewName("success");
    } else {
        mv.setViewName("error");
    }
    return mv;
}

From source file:com.ejemplo.sencha.server.rest.UsuariosController.java

/**
 * Lista todos los usuarios de la BD//w  w  w . j a  v a2s.c  o m
 * @param request
 * @param response
 * @return 
 */
@RequestMapping(method = { RequestMethod.GET }, value = "/listarusuarios")
public ModelAndView obtener10Parqueaderos(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView retorno = new ModelAndView();
    List<Usuario> listaEntidades;
    try {
        listaEntidades = daoUsuario.listar();
        if (listaEntidades == null) {
            listaEntidades = new ArrayList<Usuario>();
        }
    } catch (Exception e) {
        System.out.println("Error " + e.getMessage());
        listaEntidades = new ArrayList<Usuario>();
    }
    retorno.addObject("cantidad", listaEntidades.size());
    retorno.addObject("datos", listaEntidades);

    return retorno;
}