Example usage for javax.servlet.http HttpServletRequest getLocale

List of usage examples for javax.servlet.http HttpServletRequest getLocale

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getLocale.

Prototype

public Locale getLocale();

Source Link

Document

Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.

Usage

From source file:fr.paris.lutece.plugins.calendar.business.portlet.CalendarPortlet.java

/**
 * Returns the Xml code of the Calendar portlet without XML heading
 * /* ww w  . j  a  v a  2s  .co  m*/
 * @param request The HTTP servlet request
 * @return the Xml code of the Archive portlet content
 */
public String getXml(HttpServletRequest request) {
    StringBuffer strXml = new StringBuffer();
    Locale local;
    Plugin plugin = PluginService.getPlugin(Constants.PLUGIN_NAME);

    if (request != null) {
        local = request.getLocale();
    } else {
        local = Locale.getDefault();
    }

    XmlUtil.beginElement(strXml, TAG_CALENDAR_FILTERED_LIST);

    // fetch all the calendars related to the specified portlet
    List<AgendaResource> listAgendasInPortlet = CalendarPortletHome.findAgendasInPortlet(this.getId());
    List<AgendaResource> listAuthorizedAgenda = new ArrayList<AgendaResource>();

    // Filter to find whether user is identified and authorized to view the agenda on the front office
    for (AgendaResource agendaResource : listAgendasInPortlet) {
        if (agendaResource != null) {
            // Check security access
            String strRole = agendaResource.getRole();

            if (StringUtils.isNotBlank(strRole) && (request != null)
                    && (!Constants.PROPERTY_ROLE_NONE.equals(strRole))) {
                if (SecurityService.isAuthenticationEnable()) {
                    if (SecurityService.getInstance().isUserInRole(request, strRole)) {
                        listAuthorizedAgenda.add(agendaResource);
                    }
                }
            } else {
                listAuthorizedAgenda.add(agendaResource);
            }
        }
    }

    //Add the events of the authorized agendas
    for (AgendaResource agendaResource : listAuthorizedAgenda) {
        // Generate the XML code for the agendas :
        XmlUtil.beginElement(strXml, TAG_EVENTS);

        // ;
        String strAgendaId = agendaResource.getAgenda().getKeyName();
        String strAgendaDesc = agendaResource.getAgenda().getName();

        // Retrieve the indexed events
        Date dateBegin = CalendarPortletHome.getBeginDate(this.getId());
        Date dateEnd = CalendarPortletHome.getEndDate(this.getId());
        String[] arrayAgendaIds = { strAgendaId };
        List<Event> listIndexedEvents = CalendarSearchService.getInstance().getSearchResults(arrayAgendaIds,
                null, StringUtils.EMPTY, dateBegin, dateEnd, plugin);

        for (Event event : listIndexedEvents) {
            if ((event.getTitle() != null) && !event.getTitle().equals("")) {
                XmlUtil.beginElement(strXml, TAG_AGENDA_EVENT);
                XmlUtil.addElement(strXml, TAG_AGENDA_ID, strAgendaId);
                XmlUtil.addElement(strXml, TAG_EVENT_ID, event.getId());
                XmlUtil.addElement(strXml, TAG_AGENDA_NAME, strAgendaDesc);
                XmlUtil.addElement(strXml, TAG_AGENDA_EVENT_TITLE, event.getTitle());
                XmlUtil.addElement(strXml, TAG_AGENDA_EVENT_TOP_EVENT, event.getTopEvent());
                XmlUtil.addElement(strXml, TAG_AGENDA_EVENT_DATE,
                        DateUtil.getDateString(event.getDate(), local));
                XmlUtil.addElement(strXml, TAG_EVENT_MONTH,
                        new SimpleDateFormat("MMMM").format(event.getDate()));
                XmlUtil.addElement(strXml, TAG_EVENT_IMAGE,
                        (EventImageResourceService.getInstance().getResourceImageEvent(event.getId()))
                                .replaceAll("&", "&amp;"));
                XmlUtil.addElementHtml(strXml, TAG_EVENT_DESCRIPTION, event.getDescription());

                Calendar calendar = new GregorianCalendar();
                calendar.setTime(event.getDate());

                //String strFormat = AppPropertiesService.getProperty( Constants.PROPERTY_LABEL_FORMAT_DATE_OF_DAY );

                //DateFormat formatDate = new SimpleDateFormat( strFormat,
                //        ( request == null ) ? Locale.getDefault(  ) : request.getLocale(  ) );                       
                String strLocalizedDate = DateUtil.getDateString(event.getDate(), local);

                if (!Utils.getDate(event.getDate()).equals(Utils.getDate(event.getDateEnd()))) {
                    strLocalizedDate += (" - " + DateUtil.getDateString(event.getDateEnd(), local));
                }

                XmlUtil.addElement(strXml, TAG_EVENT_DATE_LOCAL, strLocalizedDate);
                XmlUtil.endElement(strXml, TAG_AGENDA_EVENT);
            }
        }

        XmlUtil.endElement(strXml, TAG_EVENTS);
    }

    XmlUtil.endElement(strXml, TAG_CALENDAR_FILTERED_LIST);

    //Load the xml calendar          
    strXml.append(XMLUtils.getXMLPortletCalendar(local, new GregorianCalendar(), request));

    String str = addPortletTags(strXml);

    return str;
}

From source file:tv.arte.resteventapi.web.errors.GlobalDefaultExceptionHandler.java

/**
 * Handle all exceptions of type {@link BindException} thrown by (or passing trough) the Controller's layer
 * /*from  w w  w.j a v  a  2 s. com*/
 * @param response The HttpServletResponse
 * @param e Thrown RestEventApiValidationException
 * @return
 * @throws Exception
 */
@ExceptionHandler(value = BindException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ModelAndView springBindExceptionExceptionHandler(HttpServletRequest request, BindException e)
        throws Exception {

    RestEventApiStandardResponse<RestEventApiMessage> restEventApiStandardResponse = new RestEventApiStandardResponse<RestEventApiMessage>();
    Locale userLocale = request.getLocale();
    String descriprionNotAvailableDefaultMessage = RestEventApiError.PRE_DEFINED.RIA_ERR_G_DESC_NOT_AVAILABLE
            .getDefaultMessageText();

    for (ObjectError globalError : e.getGlobalErrors()) {
        restEventApiStandardResponse.addError(new RestEventApiMessage(globalError.getDefaultMessage(),
                this.messageSource.getMessage(globalError.getCode(), globalError.getArguments(),
                        descriprionNotAvailableDefaultMessage, userLocale)));
    }

    for (FieldError fieldError : e.getFieldErrors()) {

        String messageCode = null;
        String defaultMessageText = null;

        if (fieldError.isBindingFailure()) {
            messageCode = RestEventApiError.PRE_DEFINED.RIA_ERR_V_BINDING.getCode();
            defaultMessageText = RestEventApiError.PRE_DEFINED.RIA_ERR_V_BINDING.getDefaultMessageText();
        } else {
            //TODO: Find an appropriate way to search pre-defined RestEventAPiError
            messageCode = fieldError.getDefaultMessage();
            defaultMessageText = descriprionNotAvailableDefaultMessage;
        }

        restEventApiStandardResponse
                .addError(new FieldValidationError(messageCode, this.messageSource.getMessage(messageCode,
                        fieldError.getArguments(), defaultMessageText, userLocale), fieldError.getField()));

    }

    ModelAndView mav = new ModelAndView();
    mav.addObject(restEventApiStandardResponse);
    mav.setView(restEventApiDefaultErrorView);

    return mav;
}

From source file:fr.paris.lutece.plugins.mydashboard.modules.mylutecedatabase.web.MyDashboardMyAccountComponent.java

/**
 * {@inheritDoc}//from w w  w.j  av  a2s .c o m
 */
@Override
public String getDashboardData(HttpServletRequest request) {
    if (SecurityService.isAuthenticationEnable()) {
        LuteceUser user = SecurityService.getInstance().getRegisteredUser(request);

        if ((user != null) && (user.getEmail() != null)) {
            Map<String, Object> model = new HashMap<String, Object>();

            HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_DASHBOARD_COMPONENT,
                    request.getLocale(), model);

            return template.getHtml();
        }
    }

    return StringUtils.EMPTY;
}

From source file:alpha.portal.webapp.controller.SignupController.java

/**
 * On submit./*from  w  w  w  . j  a  va  2s  .  c o m*/
 * 
 * @param user
 *            the user
 * @param errors
 *            the errors
 * @param request
 *            the request
 * @param response
 *            the response
 * @return the string
 * @throws Exception
 *             the exception
 */
@RequestMapping(method = RequestMethod.POST)
public String onSubmit(final User user, final BindingResult errors, final HttpServletRequest request,
        final HttpServletResponse response) throws Exception {
    if (request.getParameter("cancel") != null)
        return this.getCancelView();

    if (this.log.isDebugEnabled()) {
        this.log.debug("entering 'onSubmit' method...");
    }
    final Locale locale = request.getLocale();

    user.setEnabled(true);

    // Set the default user role on this new user
    user.addRole(this.roleManager.getRole(Constants.USER_ROLE));

    try {
        this.getUserManager().saveUser(user);
    } catch (final AccessDeniedException ade) {
        // thrown by UserSecurityAdvice configured in aop:advisor
        // userManagerSecurity
        this.log.warn(ade.getMessage());
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
        return null;
    } catch (final UserExistsException e) {
        errors.rejectValue("username", "errors.existing.user",
                new Object[] { user.getUsername(), user.getEmail() }, "duplicate user");

        // redisplay the unencrypted passwords
        user.setPassword(user.getConfirmPassword());
        return "signup";
    }

    this.saveMessage(request, this.getText("user.registered", user.getUsername(), locale));
    request.getSession().setAttribute(Constants.REGISTERED, Boolean.TRUE);

    // log user in automatically
    final UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(user.getUsername(),
            user.getConfirmPassword(), user.getAuthorities());
    auth.setDetails(user);
    SecurityContextHolder.getContext().setAuthentication(auth);

    // Send user an e-mail
    if (this.log.isDebugEnabled()) {
        this.log.debug("Sending user '" + user.getUsername() + "' an account information e-mail");
    }

    // Send an account information e-mail
    this.message.setSubject(this.getText("signup.email.subject", locale));

    try {
        this.sendUserMessage(user, this.getText("signup.email.message", locale),
                RequestUtil.getAppURL(request));
    } catch (final MailException me) {
        this.saveError(request, me.getMostSpecificCause().getMessage());
    }

    return this.getSuccessView();
}

From source file:fr.paris.lutece.plugins.search.solr.web.SolrSearchApp.java

/**
 * Performs a search and fills the model (useful when a page needs to remind
 * search parameters/results)//from  w  ww . j  a  va  2s .com
 *
 * @param request the request
 * @param conf the configuration
 * @return the model
 * @throws SiteMessageException if an error occurs
 */
public static Map<String, Object> getSearchResultModel(HttpServletRequest request, SolrSearchAppConf conf)
        throws SiteMessageException {
    String strQuery = request.getParameter(PARAMETER_QUERY);
    String[] facetQuery = request.getParameterValues(PARAMETER_FACET_QUERY);
    String sort = request.getParameter(PARAMETER_SORT_NAME);
    String order = request.getParameter(PARAMETER_SORT_ORDER);
    String strCurrentPageIndex = request.getParameter(PARAMETER_PAGE_INDEX);

    String fname = StringUtils.isBlank(request.getParameter(PARAMETER_FACET_NAME)) ? null
            : request.getParameter(PARAMETER_FACET_LABEL).trim();
    String flabel = StringUtils.isBlank(request.getParameter(PARAMETER_FACET_LABEL)) ? null
            : request.getParameter(PARAMETER_FACET_LABEL).trim();
    String strConfCode = request.getParameter(PARAMETER_CONF);

    Locale locale = request.getLocale();

    if (conf == null) {
        //Use default conf if not provided
        conf = SolrSearchAppConfService.loadConfiguration(null);
    }

    StringBuilder sbFacetQueryUrl = new StringBuilder();
    SolrFieldManager sfm = new SolrFieldManager();

    List<String> lstSingleFacetQueries = new ArrayList<String>();
    Hashtable<String, Boolean> switchType = getSwitched();
    ArrayList<String> facetQueryTmp = new ArrayList<String>();
    if (facetQuery != null) {
        for (String fq : facetQuery) {
            if (sbFacetQueryUrl.indexOf(fq) == -1) {
                String strFqNameIHM = getFacetNameFromIHM(fq);
                String strFqValueIHM = getFacetValueFromIHM(fq);
                if (fname == null || !switchType.containsKey(fname)
                        || (strFqNameIHM != null && strFqValueIHM != null
                                && strFqValueIHM.equalsIgnoreCase(flabel)
                                && strFqNameIHM.equalsIgnoreCase(fname))) {
                    sbFacetQueryUrl.append("&fq=" + fq);
                    sfm.addFacet(fq);
                    facetQueryTmp.add(fq);
                    lstSingleFacetQueries.add(fq);
                }
            }
        }
        //             for (String fq : facetQuery)
        //            {
        //                if (sbFacetQueryUrl.indexOf(fq) == -1)
        //                {   
        //                   //   sbFacetQueryUrl.append("&fq=" + fq);
        //                       sfm.addFacet(fq);
        //                       lstSingleFacetQueries.add(fq);
        //                }
        //            }
    }
    facetQuery = new String[facetQueryTmp.size()];
    facetQuery = facetQueryTmp.toArray(facetQuery);

    if (StringUtils.isNotBlank(conf.getFilterQuery())) {
        int nNewLength = (facetQuery == null) ? 1 : (facetQuery.length + 1);
        String[] newFacetQuery = new String[nNewLength];

        for (int i = 0; i < (nNewLength - 1); i++) {
            newFacetQuery[i] = facetQuery[i];
        }

        newFacetQuery[newFacetQuery.length - 1] = conf.getFilterQuery();
        facetQuery = newFacetQuery;
    }

    boolean bEncodeUri = Boolean.parseBoolean(
            AppPropertiesService.getProperty(PROPERTY_ENCODE_URI, Boolean.toString(DEFAULT_ENCODE_URI)));

    String strSearchPageUrl = AppPropertiesService.getProperty(PROPERTY_SEARCH_PAGE_URL);
    String strError = SolrConstants.CONSTANT_EMPTY_STRING;

    int nLimit = SOLR_RESPONSE_MAX;

    // Check XSS characters
    if ((strQuery != null) && (StringUtil.containsXssCharacters(strQuery))) {
        strError = I18nService.getLocalizedString(MESSAGE_INVALID_SEARCH_TERMS, locale);
    }

    if (StringUtils.isNotBlank(strError) || StringUtils.isBlank(strQuery)) {
        strQuery = ALL_SEARCH_QUERY;

        String strOnlyFacets = AppPropertiesService.getProperty(PROPERTY_ONLY_FACTES);

        if (StringUtils.isNotBlank(strError)
                || (((facetQuery == null) || (facetQuery.length <= 0)) && StringUtils.isNotBlank(strOnlyFacets)
                        && SolrConstants.CONSTANT_TRUE.equals(strOnlyFacets))) {
            //no request and no facet selected : we show the facets but no result
            nLimit = 0;
        }
    }

    // paginator & session related elements
    int nDefaultItemsPerPage = AppPropertiesService.getPropertyInt(PROPERTY_RESULTS_PER_PAGE,
            DEFAULT_RESULTS_PER_PAGE);
    String strCurrentItemsPerPage = request.getParameter(PARAMETER_NB_ITEMS_PER_PAGE);
    int nCurrentItemsPerPage = strCurrentItemsPerPage != null ? Integer.parseInt(strCurrentItemsPerPage) : 0;
    int nItemsPerPage = Paginator.getItemsPerPage(request, Paginator.PARAMETER_ITEMS_PER_PAGE,
            nCurrentItemsPerPage, nDefaultItemsPerPage);

    strCurrentPageIndex = (strCurrentPageIndex != null) ? strCurrentPageIndex : DEFAULT_PAGE_INDEX;

    SolrSearchEngine engine = SolrSearchEngine.getInstance();

    SolrFacetedResult facetedResult = engine.getFacetedSearchResults(strQuery, facetQuery, sort, order, nLimit,
            Integer.parseInt(strCurrentPageIndex), nItemsPerPage, SOLR_SPELLCHECK);
    List<SolrSearchResult> listResults = facetedResult.getSolrSearchResults();

    List<HashMap<String, Object>> points = null;
    if (conf.getExtraMappingQuery()) {
        List<SolrSearchResult> listResultsGeoloc = engine.getGeolocSearchResults(strQuery, facetQuery, nLimit);
        points = getGeolocModel(listResultsGeoloc);
    }

    // The page should not be added to the cache
    // Notify results infos to QueryEventListeners 
    notifyQueryListeners(strQuery, listResults.size(), request);

    UrlItem url = new UrlItem(strSearchPageUrl);
    String strQueryForPaginator = strQuery;

    if (bEncodeUri) {
        strQueryForPaginator = SolrUtil.encodeUrl(request, strQuery);
    }

    url.addParameter(PARAMETER_QUERY, strQueryForPaginator);
    url.addParameter(PARAMETER_NB_ITEMS_PER_PAGE, nItemsPerPage);

    if (strConfCode != null) {
        url.addParameter(PARAMETER_CONF, strConfCode);
    }

    for (String strFacetName : lstSingleFacetQueries) {
        url.addParameter(PARAMETER_FACET_QUERY, SolrUtil.encodeUrl(strFacetName));
    }

    // nb items per page
    IPaginator<SolrSearchResult> paginator = new DelegatePaginator<SolrSearchResult>(listResults, nItemsPerPage,
            url.getUrl(), PARAMETER_PAGE_INDEX, strCurrentPageIndex, facetedResult.getCount());

    Map<String, Object> model = new HashMap<String, Object>();
    model.put(MARK_RESULTS_LIST, paginator.getPageItems());
    // put the query only if it's not *.*
    model.put(MARK_QUERY, ALL_SEARCH_QUERY.equals(strQuery) ? SolrConstants.CONSTANT_EMPTY_STRING : strQuery);
    model.put(MARK_FACET_QUERY, sbFacetQueryUrl.toString());
    model.put(MARK_PAGINATOR, paginator);
    model.put(MARK_NB_ITEMS_PER_PAGE, nItemsPerPage);
    model.put(MARK_ERROR, strError);
    model.put(MARK_FACETS, facetedResult.getFacetFields());
    model.put(MARK_SOLR_FIELDS, SolrFieldManager.getFacetList());
    model.put(MARK_FACETS_DATE, facetedResult.getFacetDateList());
    model.put(MARK_HISTORIQUE, sfm.getCurrentFacet());
    model.put(MARK_FACETS_LIST, lstSingleFacetQueries);
    model.put(MARK_CONF_QUERY, strConfCode);
    model.put(MARK_CONF, conf);
    model.put(MARK_POINTS, points);

    if (SOLR_SPELLCHECK && (strQuery != null) && (strQuery.compareToIgnoreCase(ALL_SEARCH_QUERY) != 0)) {
        SpellCheckResponse checkResponse = engine.getSpellChecker(strQuery);

        if (checkResponse != null) {
            model.put(MARK_SUGGESTION, checkResponse.getCollatedResults());
            //model.put(MARK_SUGGESTION, facetedResult.getSolrSpellCheckResponse().getCollatedResults());
        }
    }

    model.put(MARK_SORT_NAME, sort);
    model.put(MARK_SORT_ORDER, order);
    model.put(MARK_SORT_LIST, SolrFieldManager.getSortList());
    model.put(MARK_FACET_TREE, facetedResult.getFacetIntersection());
    model.put(MARK_ENCODING, SolrUtil.getEncoding());

    String strRequestUrl = request.getRequestURL().toString();
    model.put(FULL_URL, strRequestUrl);
    model.put(SOLR_FACET_DATE_GAP, SolrSearchEngine.SOLR_FACET_DATE_GAP);

    return model;
}

From source file:com.sinosoft.one.mvc.web.instruction.ViewInstruction.java

@Override
public void doRender(Invocation inv) throws Exception {
    String name = resolvePlaceHolder(this.name, inv);
    ViewDispatcher viewResolver = getViewDispatcher(inv);
    String viewPath = getViewPath((InvocationBean) inv, name);
    if (viewPath != null) {
        HttpServletRequest request = inv.getRequest();
        HttpServletResponse response = inv.getResponse();
        ////w w  w  .j  av  a2s.c o  m
        View view = viewResolver.resolveViewName(inv, viewPath, request.getLocale());

        if (!Thread.interrupted()) {
            inv.addModel(MVC_INVOCATION, inv);
            if (request.getAttribute(MvcConstants.IS_WINDOW_REQUEST) != null) {
                request.setAttribute(MvcConstants.WINDOW_REQUEST_URI, request.getContextPath() + viewPath);
            }
            view.render(inv.getModel().getAttributes(), request, response);
        } else {
            logger.info("interrupted");
        }
    }
}

From source file:it.cilea.osd.jdyna.controller.FormBoxController.java

@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {

    H object = (H) command;//from w  w  w  . j a v  a  2  s  .c o m
    String tabId = request.getParameter("tabId");
    applicationService.saveOrUpdate(boxClass, object);
    saveMessage(request,
            getText("action.box.edited", new Object[] { object.getShortName() }, request.getLocale()));
    return new ModelAndView(getSuccessView() + "?id=" + object.getId());
}

From source file:org.openmrs.web.controller.concept.ConceptDrugFormController.java

/**
 * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest,
 *      java.lang.Object, org.springframework.validation.Errors)
 *///from w w  w.  jav a 2  s .  c  om
protected Map<String, Object> referenceData(HttpServletRequest request, Object obj, Errors errs)
        throws Exception {

    Drug drug = (Drug) obj;

    Map<String, Object> map = new HashMap<String, Object>();
    String defaultVerbose = "false";

    if (Context.isAuthenticated()) {
        if (drug.getConcept() != null) {
            map.put("conceptName", drug.getConcept().getName(request.getLocale()));
        }
        defaultVerbose = Context.getAuthenticatedUser()
                .getUserProperty(OpenmrsConstants.USER_PROPERTY_SHOW_VERBOSE);
    }

    map.put("defaultVerbose", defaultVerbose.equals("true") ? true : false);

    String editReason = request.getParameter("editReason");
    if (editReason == null) {
        editReason = "";
    }

    map.put("editReason", editReason);

    return map;
}

From source file:tv.arte.resteventapi.web.errors.GlobalDefaultExceptionHandler.java

/**
 * Handle all exceptions of type {@link ImageRepositoryException} thrown by (or passing trough) the Controller's layer
 * // w w w  .j  a  v a  2  s  .  c  o m
 * @param response The HttpServletResponse
 * @param e Thrown RestEventApiValidationException
 * @return
 * @throws Exception
 */
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public ModelAndView restEventApiMethodArgumentNotValidExceptionHandler(HttpServletRequest request,
        MethodArgumentNotValidException e) throws Exception {
    RestEventApiStandardResponse<RestEventApiMessage> restEventApiStandardResponse = new RestEventApiStandardResponse<RestEventApiMessage>();
    Locale userLocale = request.getLocale();
    String descriprionNotAvailableDefaultMessage = RestEventApiError.PRE_DEFINED.RIA_ERR_G_DESC_NOT_AVAILABLE
            .getDefaultMessageText();

    for (ObjectError globalError : e.getBindingResult().getGlobalErrors()) {
        restEventApiStandardResponse.addError(new RestEventApiMessage(globalError.getDefaultMessage(),
                this.messageSource.getMessage(globalError.getCode(), globalError.getArguments(),
                        descriprionNotAvailableDefaultMessage, userLocale)));
    }

    for (FieldError fieldError : e.getBindingResult().getFieldErrors()) {

        String messageCode = null;
        String defaultMessageText = null;

        if (fieldError.isBindingFailure()) {
            messageCode = RestEventApiError.PRE_DEFINED.RIA_ERR_V_BINDING.getCode();
            defaultMessageText = RestEventApiError.PRE_DEFINED.RIA_ERR_V_BINDING.getDefaultMessageText();
        } else {
            //TODO: Find an appropriate way to search pre-defined RestEventAPiError
            messageCode = fieldError.getDefaultMessage();
            defaultMessageText = descriprionNotAvailableDefaultMessage;
        }

        restEventApiStandardResponse
                .addError(new FieldValidationError(messageCode, this.messageSource.getMessage(messageCode,
                        fieldError.getArguments(), defaultMessageText, userLocale), fieldError.getField()));

    }

    ModelAndView mav = new ModelAndView();
    mav.addObject(restEventApiStandardResponse);
    mav.setView(restEventApiDefaultErrorView);

    return mav;
}

From source file:de.otto.mongodb.profiler.web.PageInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {

    if (handler instanceof HandlerMethod
            && ((HandlerMethod) handler).getMethod().isAnnotationPresent(Page.class)
            && (modelAndView.getView() instanceof RedirectView == false)) {
        addMainNavigationViewModel(((HandlerMethod) handler), modelAndView);
        addFooterViewModel(modelAndView, request.getLocale());
    }// w w  w . ja v  a 2 s . co m
}