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:de.topicmapslab.majortom.server.admin.interceptor.LayoutInterceptor.java

private void includeLayout(ModelAndView modelAndView, String originalView) {
    boolean noLayout = originalView.startsWith(NO_LAYOUT);

    String realViewName = (noLayout) ? originalView.substring(NO_LAYOUT.length()) : originalView;

    if (noLayout) {
        modelAndView.setViewName(realViewName);
    } else {/*  ww w.java 2s.com*/
        modelAndView.addObject("view", realViewName);
        modelAndView.setViewName(layoutView);
    }
}

From source file:me.bulat.jivr.webmin.web.root.AppRootController.java

@RequestMapping(value = { "/success" }, method = { RequestMethod.GET })
public ModelAndView successRegistration() {
    ModelAndView model = new ModelAndView();
    model.addObject("title", "Jivr Web Console Registration page");
    model.addObject("message", "Registration Success!");
    model.setViewName("form/success");
    return model;
}

From source file:com.highcharts.export.controller.ExportController.java

@ExceptionHandler(SVGConverterException.class)
public ModelAndView handleSVGRasterizeException(Exception ex) {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("error");
    modelAndView.addObject("message", "Something went wrong while converting.");
    return modelAndView;
}

From source file:com.highcharts.export.controller.ExportController.java

@ExceptionHandler(IOException.class)
public ModelAndView handleIOException(Exception ex) {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("error");
    modelAndView.addObject("message", ex.getMessage());
    return modelAndView;
}

From source file:com.highcharts.export.controller.ExportController.java

@ExceptionHandler(ServletException.class)
public ModelAndView handleServletException(Exception ex) {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("error");
    modelAndView.addObject("message", ex.getMessage());
    return modelAndView;
}

From source file:org.guanxi.sp.engine.service.generic.GenericProfileService.java

public ModelAndView gps(HttpServletRequest request, HttpServletResponse response) {
    String guardID = request.getParameter(Guanxi.WAYF_PARAM_GUARD_ID);
    String guardSessionID = request.getParameter(Guanxi.WAYF_PARAM_SESSION_ID);

    // Optional entityID
    String idpEntityID = request.getParameter("entityID");

    // If the Guard hasn't specified an entityID, see if it has one registered for it
    if (idpEntityID == null) {
        if (entityIDs != null) {
            String entityIDForGuard = null;
            String defaultEntityID = null;

            // Find out which entityID to use for this Guard
            for (String registeredGuardID : entityIDs.keySet()) {
                if (registeredGuardID.equals(DEFAULT_ENTITYID_MARKER)) {
                    defaultEntityID = entityIDs.get(registeredGuardID);
                }/*  w  w  w . j  a  v  a  2s.  co m*/
                if (guardID.equals(registeredGuardID)) {
                    entityIDForGuard = entityIDs.get(registeredGuardID);
                }
            }

            idpEntityID = (entityIDForGuard != null) ? entityIDForGuard : defaultEntityID;
            logger.info("Guard '" + guardID + "' obtained entityID : " + idpEntityID);
        }
    } else {
        logger.info("Guard '" + guardID + "' specified entityID : " + idpEntityID);
    }

    // If no IdP entityID, see if it's coming from the discovery service
    if ((idpEntityID == null) && (useDiscoveryService)) {
        idpEntityID = request.getParameter("edsEntityID");
    }

    // Get the Guard's metadata, previously loaded by the Bootstrapper
    EntityDescriptorType guardEntityDescriptor = (EntityDescriptorType) getServletContext()
            .getAttribute(guardID);
    if (guardEntityDescriptor == null) {
        logger.error("Guard '" + guardID + "' not found in metadata repository");
        ModelAndView mAndV = new ModelAndView();
        mAndV.setViewName(errorView);
        mAndV.getModel().put(errorViewDisplayVar,
                messages.getMessage("engine.error.no.guard.metadata", null, request.getLocale()));
        return mAndV;
    }

    // Load the GuanxiGuardService node from the metadata
    GuardRoleDescriptorExtensions guardNativeMetadata = Util.getGuardNativeMetadata(guardEntityDescriptor);

    /* Convert the Guard's session ID to an Engine session ID and store the Guard's GuanxiGuardService
     * node under it. This will be deleted from the context once the SAML round trip has been processed
     * and the attributes sent to the Guard.
     */
    getServletContext().setAttribute(guardSessionID.replaceAll("GUARD", "ENGINE"), guardEntityDescriptor);

    EntityFarm farm = (EntityFarm) getServletContext().getAttribute(Guanxi.CONTEXT_ATTR_ENGINE_ENTITY_FARM);
    try {
        return getProfileService(request, farm, idpEntityID).doProfile(request, guardID, guardSessionID,
                guardNativeMetadata, idpEntityID, farm);
    } catch (GuanxiException ge) {
        logger.error("Profile Service error: ", ge);
        ModelAndView mAndV = new ModelAndView();
        mAndV.setViewName(errorView);
        mAndV.getModel().put(errorViewDisplayVar, ge.getMessage());
        return mAndV;
    }
}

From source file:com.highcharts.export.controller.ExportController.java

@ExceptionHandler(TimeoutException.class)
public ModelAndView handleTimeoutException(Exception ex) {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("error");
    modelAndView.addObject("message",
            "Timeout converting SVG, is your file this big, or maybe you have a syntax error in the javascript callback?");
    return modelAndView;
}

From source file:com.highcharts.export.controller.ExportController.java

@ExceptionHandler(PoolException.class)
public ModelAndView handleServerPoolException(Exception ex) {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("error");
    modelAndView.addObject("message",
            "Sorry, the server is handling too many requests at the moment. Please try again.");
    return modelAndView;
}

From source file:com.highcharts.export.controller.ExportController.java

@ExceptionHandler(InterruptedException.class)
public ModelAndView handleInterruptedException(Exception ex) {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("error");
    modelAndView.addObject("message",
            "It took too long time to process the options, no SVG is created. Make sure your javascript is correct");
    return modelAndView;
}

From source file:de.tr.ctrl.CustomerController.java

/**
 * <p>/*from w  w  w.  j av a2 s  .com*/
 * sets the view name for license description.
 * </p>
 * 
 * <p>
 * Expected HTTP GET and request '/license-description.html'.
 * </p>
 * 
 * @param session
 * @return View name 'license-description' selecting view
 *         '/view/license-description.jsp'.
 */
@RequestMapping(value = "/license-description.html", method = RequestMethod.GET)
public ModelAndView licenseDescription() {
    ModelAndView mv = new ModelAndView();
    mv.setViewName("license-description"); //sets view name
    return mv;
}