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

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

Introduction

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

Prototype

public ModelAndView addObject(String attributeName, @Nullable Object attributeValue) 

Source Link

Document

Add an attribute to the model.

Usage

From source file:com.intel.cosbench.driver.web.WorkersPageController.java

private static ModelAndView createResult(MissionInfo info) {
    ModelAndView result = new ModelAndView("workers");
    result.addObject("info", info);
    result.addObject("isStopped", isStopped(info.getState()));
    result.addObject("isRunning", isRunning(info.getState()));
    return result;
}

From source file:org.ednovo.gooru.converter.serializer.ConversionSerializer.java

public static ModelAndView toModelAndView(Object object) {
    ModelAndView jsonmodel = new ModelAndView(REST_MODEL);
    jsonmodel.addObject(MODEL, object);
    return jsonmodel;
}

From source file:org.ednovo.gooru.converter.serializer.ConversionSerializer.java

public static ModelAndView toJsonModelAndView(Object object) throws Exception {
    ModelAndView jsonmodel = new ModelAndView(REST_MODEL);
    jsonmodel.addObject(MODEL, serializeToJsonObject(object));
    return jsonmodel;
}

From source file:simplestorage.controllers.HashtableController.java

/**
 * Creates a Spring ModelAndView representation from the JSON formatted
 * result./*www .j  a  va2s.  c  om*/
 *
 * @param json the data model in MVC.
 * @return ModelAndView a Spring MVC framework instance with data and view
 *         for the client
 */
private static ModelAndView constructModelAndView(String json) {
    ModelAndView mv = new ModelAndView();
    mv.addObject(JSON_MODEL, json);
    mv.setViewName(JSON_VIEW);
    return mv;
}

From source file:de.chludwig.websec.saml2sp.controller.Saml2SpController.java

public static void addUrlModelAttributes(ModelAndView modelAndView) {
    modelAndView.addObject("startPageUrl", START_PAGE_PATH);
    modelAndView.addObject("loginUrl", Saml2SPSSOController.SAML_LOGIN_PAGE_PATH);
    modelAndView.addObject("globalLogoutUrl", Saml2SPSSOController.SAML_GLOBAL_LOGOUT_URL_PATH);
    modelAndView.addObject("localLogoutUrl", Saml2SPSSOController.SAML_LOCAL_LOGOUT_URL_PATH);
    modelAndView.addObject("anonymousPageUrl", ANONYMOUS_PAGE_PATH);
    modelAndView.addObject("authenticatedPageUrl", AUTHENTICATED_PAGE_PATH);
    modelAndView.addObject("userRolePageUrl", USER_ROLE_PAGE_PATH);
    modelAndView.addObject("adminRolePageUrl", ADMIN_ROLE_PAGE_PATH);
}

From source file:de.chludwig.websec.saml2sp.controller.Saml2SpController.java

public static ModelAndView createModelAndView(String viewName, ApplicationUser currentUser) {
    ModelAndView modelAndView = createModelAndView(viewName);
    modelAndView.addObject("currentUser", currentUser);
    return modelAndView;
}

From source file:de.chludwig.websec.saml2sp.controller.Saml2SpController.java

public static ModelAndView createModelAndView(String viewName) {
    ModelAndView modelAndView = new ModelAndView(viewName);
    addUrlModelAttributes(modelAndView);
    modelAndView.addObject("time", new Date());
    return modelAndView;
}

From source file:eu.delving.core.util.ThemeFilter.java

/**
* This creates the default ModelAndView for the portal applications. It should be used in every Controller.
*
* @param view The Freemarker template that will be used by the model to render the view
* @return ModelAndView page/*from   w ww  .j ava  2  s  .  co m*/
*/

public static ModelAndView createThemedModelAndViewPage(String view) {
    final String themeTemplateDir = getTheme().getTemplateDir();
    ModelAndView page = new ModelAndView(themeTemplateDir + "/" + view);
    User user = ControllerUtil.getUser();
    page.addObject("user", user);
    return page;
}

From source file:org.iish.visualmets.util.ControllerUtils.java

/**
 * Determines the type of template: JSON or XML.
 * When the client uses a callback function with a tagname, it is assumed the response is JSON.
 * If NULL the XML template is selected.
 *
 * @param viewName Prefix of the template
 * @param callback JSONP tagname//w  w  w. j  a v  a2  s.c om
 * @param response
 * @return the FreeMarker template
 */
public static ModelAndView createModelAndViewPage(String viewName, String callback,
        HttpServletResponse response) {

    String template = (callback == null) ? viewName.concat(".xml") : viewName.concat(".json");

    ModelAndView mav = new ModelAndView(template);

    if (callback == null) {
        response.setContentType("text/xml; charset=utf-8");
    } else {
        response.setContentType("application/json; charset=utf-8");
        mav.addObject("callback", callback.trim());
    }

    return mav;
}

From source file:org.shareok.data.webserv.WebUtil.java

public static void outputJobInfoToModel(ModelAndView model, RedisJob job) {

    Date startTime = job.getStartTime();
    Date endTime = job.getEndTime();
    model.addObject("jobId", job.getJobId());
    model.addObject("status", RedisUtil.REDIS_JOB_STATUS[job.getStatus()]);
    model.addObject("startTime",
            (null == startTime) ? "" : ShareokdataManager.getSimpleDateFormat().format(startTime));
    model.addObject("endTime",
            (null == endTime) ? "" : ShareokdataManager.getSimpleDateFormat().format(endTime));
    model.addObject("jobType", DataUtil.JOB_TYPES[job.getType()]);
}