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

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

Introduction

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

Prototype

public void setViewName(@Nullable String viewName) 

Source Link

Document

Set a view name for this ModelAndView, to be resolved by the DispatcherServlet via a ViewResolver.

Usage

From source file:org.inbio.modeling.web.controller.EditUserController.java

/** default behavior for direct access (url) */
@Override/*w w w .  j a v  a 2 s . co m*/
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {
    UserForm userForm = (UserForm) command;
    SystemUser systemUser = null;

    systemUser = (SystemUser) userManager.loadUserByUsername(userForm.getUsername());

    userForm = new UserForm();

    userForm.setUserId(systemUser.getUserId());
    userForm.setUsername(systemUser.getUsername());
    userForm.setFullname(systemUser.getFullname());
    userForm.setEnabled(systemUser.isEnabled());

    GrantedAuthority[] authorities = systemUser.getAuthorities();

    for (int i = 0; i < authorities.length; i++)
        if (authorities[i].getAuthority().equals("ROLE_ADMIN"))
            userForm.setAdmin(true);
        else
            userForm.setUser(true);

    ModelAndView model = null;

    // Send the layer list to the JSP
    model = new ModelAndView();
    model.setViewName("admin/userDetails");
    model.addObject("userForm", userForm);

    return model;
}

From source file:bc8.movies.controllers.LoginController.java

@RequestMapping(value = "/changePassword")
public ModelAndView changePassword(String newPassword, HttpSession session) {
    ModelAndView mv = new ModelAndView("userDetails");
    User currUser;/*from  www . j  av  a 2  s.  c  o  m*/
    if (session.getAttribute("user") == null) {
        mv.setViewName("redirect:/home");
    } else if ((currUser = (User) session.getAttribute("user")) != null) {
        currUser.setPassword(newPassword);
        userService.updateUser(currUser);
    }
    return mv;
}

From source file:org.inbio.modeling.web.controller.UpdateLayerInfoController.java

/** default behavior for direct access (url) */
@Override/*  w  w  w  .j a  v a 2 s .c  om*/
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {

    List<LayerDTO> layers = null;
    LayerDTO layerDTO = (LayerDTO) command;
    String uri = request.getRequestURI();

    if (uri.matches(".*deleteLayer.*")) {
        this.deleteLayer(layerDTO);
    } else if (uri.matches(".*updateLayer.*")) {

        if (layerDTO.getId() == null)
            this.newLayer(layerDTO);
        else
            this.updateLayer(layerDTO);
    }

    ModelAndView model = null;

    // Send the layer list to the JSP
    model = new ModelAndView();
    model.setViewName("redirect:listLayers.html");

    return model;
}

From source file:it.geosolutions.geobatch.ui.mvc.ConsumerInfoController.java

@Override
protected void handleConsumer(ModelAndView mav, EventConsumer consumer) {
    mav.setViewName("consumerInfo");

    List<String> eventlist = new ArrayList<String>();

    // Progress Logging...
    Collection<IProgressListener> coll = consumer.getListeners();
    for (IProgressListener listener : coll) {
        if (listener == null) {
            continue;
            // TODO warn
        } else if (listener instanceof CumulatingProgressListener) {
            CumulatingProgressListener cpl = (CumulatingProgressListener) listener;
            for (String msg : cpl.getMessages()) {
                eventlist.add("Consumer: " + msg);
            }//from w w w . j a v  a 2  s. co  m
        } else if (listener instanceof StatusProgressListener) {
            StatusProgressListener spl = (StatusProgressListener) listener;
            eventlist.add("Consumer status: " + spl.toString());
        } else if (listener instanceof ProgressListener) {
            // get any pl
            ProgressListener anypl = (ProgressListener) listener;
            eventlist.add("Consumer action task: " + anypl.getTask());
            eventlist.add("Consumer action progress: " + anypl.getProgress() + "%");
        }
    }

    // Current Action Status...
    BaseAction<?> action = (BaseAction) ((FileBasedEventConsumer) consumer).getCurrentAction(); // TODO BETTER USE OF CONSUMER!!!
    if (action != null) {
        mav.addObject("action", action);
        //            eventlist.add("Current action type: " + action.getClass().getSimpleName());
        //            eventlist.add("Current action name: " + action.getName() );
        //            if( action.isPaused() )
        //                eventlist.add("Current action status: PAUSED");

        // try the most interesting information holder
        for (IProgressListener actionListener : action.getListeners()) {
            if (actionListener == null) {
                continue;
                // TODO warn
            } else if (actionListener instanceof CumulatingProgressListener) {
                CumulatingProgressListener cpl = (CumulatingProgressListener) actionListener;
                for (String msg : cpl.getMessages()) {
                    eventlist.add("Current action event: " + msg);
                }
            } else if (actionListener instanceof StatusProgressListener) {
                StatusProgressListener spl = (StatusProgressListener) actionListener;
                eventlist.add("Current action status: " + spl.toString());
                //                    mav.addObject("acStatus", spl);
            } else if (actionListener instanceof ProgressListener) {
                // get any pl
                ProgressListener anypl = (ProgressListener) actionListener;
                eventlist.add("Current action task: " + anypl.getTask());
                eventlist.add("Current action progress: " + anypl.getProgress() + "%");
            }
        }

    }

    //        eventlist.add(consumer.toString());

    mav.addObject("consumer", consumer);
    mav.addObject("eventlist", eventlist);
}

From source file:com.tce.oauth2.spring.client.controller.TodoController.java

@RequestMapping("/todos")
public ModelAndView index(HttpServletRequest request) {
    List<Todo> todos = todoService.findByUsername((String) request.getSession().getAttribute("access_token"),
            (String) request.getSession().getAttribute("username"));
    ModelAndView model = new ModelAndView();
    model.addObject("todo", new Todo());
    model.addObject("todos", todos);
    model.setViewName("todolist");
    return model;
}

From source file:pl.lodz.uni.math.controller.HelloController.java

@RequestMapping(value = "/admin**", method = RequestMethod.GET)
public ModelAndView adminPage() {

    ModelAndView model = new ModelAndView();
    //model.addObject("title", "Spring Security Hello World");
    //model.addObject("message", "This is protected page!");
    model.setViewName("admin/admin");

    return model;

}

From source file:org.n52.aviation.aviationfx.spring.ExceptionHandlerImpl.java

private ModelAndView createModelAndView(Exception e, HttpServletRequest req) {
    LOG.warn("Returning exception", e);
    ModelAndView mav = new ModelAndView();
    mav.addObject(DEFAULT_ERROR_VIEW, e.getMessage());
    mav.addObject(BACKLINK, req.getRequestURL());
    mav.setViewName(DEFAULT_ERROR_VIEW);
    return mav;//from w ww .ja va 2s  . com
}

From source file:ru.langboost.controllers.security.SecurityController.java

@RequestMapping(value = "/registration", method = RequestMethod.GET)
public ModelAndView registration() {
    ModelAndView model = new ModelAndView();
    model.addObject("roles", Arrays.asList(Roles.values()));
    model.setViewName("security/registration");
    return model;
}

From source file:net.cit.tetrad.resource.LoginResource.java

@RequestMapping("/popup_login.do")
public ModelAndView popup_login() throws Exception {
    ModelAndView mav = new ModelAndView();
    mav.setViewName("popup_login");
    return mav;/*w  ww . j  a  v a2 s . c o m*/
}

From source file:com.yilv.web.SessionController.java

@RequestMapping("session.do")
public ModelAndView list(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ClientSession[] sessions = new ClientSession[0];
    sessions = SessionManager.getInstance().getSessions().toArray(sessions);

    List<SessionVO> voList = new ArrayList<SessionVO>();
    for (ClientSession sess : sessions) {
        SessionVO vo = new SessionVO();
        vo.setId(sess.getId());/* www  .j a  va 2  s .c  o  m*/
        vo.setResource(sess.getAddress().getResource());
        // Status
        if (sess.getStatus() == Session.STATUS_CONNECTED) {
            vo.setStatus("CONNECTED");
        } else if (sess.getStatus() == Session.STATUS_AUTHENTICATED) {
            vo.setStatus("AUTHENTICATED");
        } else if (sess.getStatus() == Session.STATUS_CLOSED) {
            vo.setStatus("CLOSED");
        } else {
            vo.setStatus("UNKNOWN");
        }
        // Presence
        if (!sess.getPresence().isAvailable()) {
            vo.setPresence("Offline");
        } else {
            Presence.Show show = sess.getPresence().getShow();
            if (show == null) {
                vo.setPresence("Online");
            } else if (show == Presence.Show.away) {
                vo.setPresence("Away");
            } else if (show == Presence.Show.chat) {
                vo.setPresence("Chat");
            } else if (show == Presence.Show.dnd) {
                vo.setPresence("Do Not Disturb");
            } else if (show == Presence.Show.xa) {
                vo.setPresence("eXtended Away");
            } else {
                vo.setPresence("Unknown");
            }
        }
        vo.setClientIP(sess.getHostAddress());
        vo.setCreatedDate(sess.getCreationDate());
        voList.add(vo);
    }

    ModelAndView mav = new ModelAndView();
    mav.addObject("sessionList", voList);
    mav.setViewName("session/list");
    return mav;
}