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.myjerry.evenstar.web.tools.ImportBlogController.java

public ModelAndView view(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView mav = new ModelAndView();

    Long blogID = StringUtils.getLong(request.getParameter("blogID"));

    mav.setViewName(".tools.import.blog");
    mav.addObject("blogID", blogID);
    return mav;// w  ww .j a v a 2  s . co m
}

From source file:com.anthony.forumspring.controller.TopicController.java

@RequestMapping(value = "/Topics/CreateTopics", method = RequestMethod.GET)
public ModelAndView createTopicView() {
    ModelAndView mav = new ModelAndView();
    List<Categorie> ca = c.findAllC();
    mav.addObject("categorie", ca);
    mav.setViewName("createTopics");
    return mav;/*from   ww  w.  j  a v a  2 s .co  m*/
}

From source file:com.controller.PanelController.java

@RequestMapping("panel.htm")
public ModelAndView getPanel(HttpServletRequest request) {
    sesion = request.getSession();//  ww w .j  a  va2  s  . c  o  m
    ModelAndView mav = new ModelAndView();
    String mensaje = null;

    if (sesion.getAttribute("usuario") == null) {
        mav.setViewName("login/login");

    } else {
        sesionUser = sesion.getAttribute("usuario").toString();
        if (sesion.getAttribute("tipoUsuario").toString().compareTo("Administrador") == 0) {
            mav.setViewName("viewsAdmin/panelAdmin");
            System.out.println("el usuario es administrador");
        } else {
            mav.setViewName("panel/panel");
        }
    }
    return mav;

}

From source file:org.guanxi.sp.engine.service.shibboleth.ShibbolethProfileService.java

/** @see org.guanxi.sp.engine.service.generic.ProfileService#doProfile(javax.servlet.http.HttpServletRequest, String, String, org.guanxi.xal.saml2.metadata.GuardRoleDescriptorExtensions, String, org.guanxi.common.entity.EntityFarm) */
public ModelAndView doProfile(HttpServletRequest request, String guardID, String guardSessionID,
        GuardRoleDescriptorExtensions guardNativeMetadata, String entityID, EntityFarm farm)
        throws GuanxiException {
    ModelAndView mAndV = new ModelAndView();
    mAndV.setViewName(wayfViewJSP);

    // If there's an entityID try to load its metadata
    String wayfForGuard = null;/*from   www . j av a2 s  .c o  m*/
    String defaultWAYFLocation = null;
    if (entityID != null) {
        EntityManager manager = farm.getEntityManagerForID(entityID);
        Metadata idpMetadata = manager.getMetadata(entityID);
        EntityDescriptorType saml2Metadata = (EntityDescriptorType) idpMetadata.getPrivateData();
        EndpointType[] ssoServices = saml2Metadata.getIDPSSODescriptorArray(0).getSingleSignOnServiceArray();
        for (EndpointType ssoService : ssoServices) {
            if (ssoService.getBinding().equals("urn:mace:shibboleth:1.0:profiles:AuthnRequest")) {
                wayfForGuard = ssoService.getLocation();
                logger.info("Guard '" + guardID + "' obtained WAYFless location : " + wayfForGuard);
            }
        }
    }

    // No entityID or no suitable profile endpoint so use a WAYF
    if (wayfForGuard == null) {
        // Find out which WAYF to use for this Guard
        for (String guardId : wayfs.keySet()) {
            if (guardId.equals(DEFAULT_WAYF_MARKER)) {
                defaultWAYFLocation = wayfs.get(guardId);
            }
            if (guardId.equals(guardID)) {
                wayfForGuard = wayfs.get(guardId);
            }
        }
        wayfForGuard = (wayfForGuard != null) ? wayfForGuard : defaultWAYFLocation;
        logger.info("Guard '" + guardID + "' obtained WAYF location : " + wayfForGuard);
    }

    try {
        // Guard either gets its own WAYF or the default one for all other Guards
        mAndV.getModel().put("wayfLocation", wayfForGuard);
        mAndV.getModel().put("shire", URLEncoder.encode(attributeConsumerService, "UTF-8"));
        mAndV.getModel().put("target", URLEncoder.encode(guardSessionID, "UTF-8"));
        mAndV.getModel().put("time", Long.toString(System.currentTimeMillis() / 1000));
        mAndV.getModel().put("providerId", guardID);
    } catch (UnsupportedEncodingException uee) {
        logger.error("something went wrong putting the WAYF location together", uee);
        throw new GuanxiException(uee);
    }

    return mAndV;
}

From source file:rashjz.info.com.az.config.AdviceController.java

@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
    // If the exception is annotated with @ResponseStatus rethrow it and let
    // the framework handle it - like the OrderNotFoundException example
    // at the start of this post.
    // AnnotationUtils is a Spring Framework utility class.
    if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
        throw e;//w ww. j  a va2s .  co  m
    }

    // Otherwise setup and send the user to a default error-view.
    ModelAndView mav = new ModelAndView();
    mav.addObject("exception", e);
    mav.addObject("url", req.getRequestURL());
    mav.setViewName(DEFAULT_ERROR_VIEW);
    return mav;

}

From source file:com.epam.training.taranovski.web.project.controller.LoginController.java

/**
 *
 * @param modelAndView/*from   ww  w  .  j a v a  2  s.c o  m*/
 * @param sessionStatus
 * @return
 */
@RequestMapping("/toLoginPage")
public ModelAndView logout(ModelAndView modelAndView, SessionStatus sessionStatus) {
    sessionStatus.setComplete();
    modelAndView.setViewName(LOGIN_PAGE);
    return modelAndView;
}

From source file:de.fzi.ALERT.actor.SubscriptionEditor.Controller.MessageListController.java

@RequestMapping(value = "/showMsg.html", method = RequestMethod.GET)
public ModelAndView showMsg(ModelMap model, @ModelAttribute("msgList") List<MessageForm> msgList,
        @RequestParam("msgId") int msgId) {

    MessageForm msg = new MessageForm();
    int msgListSize = msgList.size();
    if (msgListSize > 0) {
        for (int i = 0; i < msgListSize; i++) {
            if (msgList.get(i).getMessageId() == msgId) {
                msg = msgList.get(i);/*from  w  ww  .  j a v  a  2  s  . co m*/
            }
        }
    }

    ModelAndView mav = new ModelAndView();
    mav.setViewName("showMsg");
    mav.addObject("message", msg);

    return mav;
}

From source file:com.qcadoo.view.internal.controllers.PasswordResetController.java

@RequestMapping(value = "passwordReset", method = RequestMethod.GET)
public ModelAndView getForgotPasswordFormView(
        @RequestParam(required = false, defaultValue = FALSE) final Boolean iframe,
        @RequestParam(required = false, defaultValue = FALSE) final Boolean popup, final Locale locale) {

    ModelAndView mav = new ModelAndView();
    viewParametersAppender.appendCommonViewObjects(mav);
    mav.setViewName("qcadooView/passwordReset");
    mav.addObject("translation", translationService.getMessagesGroup("security", locale));
    mav.addObject("currentLanguage", locale.getLanguage());
    mav.addObject("locales", translationService.getLocales());

    mav.addObject("iframe", iframe);
    mav.addObject("popup", popup);

    return mav;/*from   w  w w . ja  v a 2  s . c om*/
}

From source file:org.emr.controller.ApplicationController.java

@RequestMapping(value = "/login")
public ModelAndView throwLogin() {
    System.out.println("login action called : ");
    ModelAndView mv = new ModelAndView();
    mv.setViewName("login.html");
    return mv;/*from w  ww  . jav a2  s.co m*/
}

From source file:org.emr.controller.ApplicationController.java

@RequestMapping(value = "/test1")
public ModelAndView responseJson() {
    System.out.println("request for test ");
    ModelAndView mv = new ModelAndView();
    mv.setViewName("manage.html");
    return mv;//from  w ww .  j a  v a2 s.  c om
}