Search in sources :

Example 46 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project x-pipe by ctripcorp.

the class AbstractDispatcherMetaServerController method populateModel.

@ModelAttribute
public void populateModel(@PathVariable final String clusterId, @RequestHeader(name = MetaServerService.HTTP_HEADER_FOWRARD, required = false) ForwardInfo forwardInfo, Model model, HttpServletRequest request) {
    if (forwardInfo != null) {
        logger.info("[populateModel]{},{}", clusterId, forwardInfo);
    }
    MetaServer metaServer = getMetaServer(clusterId, forwardInfo, request.getRequestURI());
    if (metaServer == null) {
        throw new UnfoundAliveSererException(clusterId, slotManager.getServerIdByKey(clusterId), currentMetaServer.getServerId());
    }
    model.addAttribute(MODEL_META_SERVER, metaServer);
    if (forwardInfo != null) {
        model.addAttribute(forwardInfo);
    }
}
Also used : UnfoundAliveSererException(com.ctrip.xpipe.redis.meta.server.rest.exception.UnfoundAliveSererException) MultiMetaServer(com.ctrip.xpipe.redis.meta.server.impl.MultiMetaServer) MetaServer(com.ctrip.xpipe.redis.meta.server.MetaServer) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 47 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project com.revolsys.open by revolsys.

the class WebAnnotationMethodHandlerAdapter method addReturnValueAsModelAttribute.

protected final void addReturnValueAsModelAttribute(final Method handlerMethod, final Class<?> handlerType, final Object returnValue, final ExtendedModelMap implicitModel) {
    final ModelAttribute attr = AnnotationUtils.findAnnotation(handlerMethod, ModelAttribute.class);
    String attrName = attr != null ? attr.value() : "";
    if ("".equals(attrName)) {
        final Class<?> resolvedType = GenericTypeResolver.resolveReturnType(handlerMethod, handlerType);
        attrName = Conventions.getVariableNameForReturnType(handlerMethod, resolvedType, returnValue);
    }
    implicitModel.addAttribute(attrName, returnValue);
}
Also used : ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 48 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project SimpleContentPortlet by Jasig.

the class ConfigureContentController method getForm.

/**
 * Get the form object for the portlet configuration.  If this portlet has
 * already been configured with content, the current HTML will be
 * pre-populated into the form object.  If this is a new portlet, the
 * initial content will be an empty string.
 *
 * @param request PortletRequest
 * @return form object for the portlet configuration
 */
@ModelAttribute("form")
public ContentForm getForm(PortletRequest request) {
    // TODO: Get the locale specified in the drop-down list
    String content = this.contentDao.getContent(request, null);
    ContentForm form = new ContentForm();
    form.setContent(content);
    return form;
}
Also used : ContentForm(org.jasig.portlet.cms.mvc.form.ContentForm) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 49 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project tesb-rt-se by Talend.

the class AppController method createRequestParameters.

@ModelAttribute("inputData")
public SearchRequestParameters createRequestParameters() {
    SimpleDateFormat sdf = new SimpleDateFormat(DateFormatValidator.DEFAULT_FORMAT);
    SearchRequestParameters params = new SearchRequestParameters();
    params.setCustomerName("aebert");
    params.setPickupDate(sdf.format(new Date()));
    params.setReturnDate(sdf.format(new Date(System.currentTimeMillis() + ADAY)));
    return params;
}
Also used : SearchRequestParameters(org.talend.esb.client.app.model.SearchRequestParameters) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 50 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project BroadleafCommerce by BroadleafCommerce.

the class CustomerPhoneController method initPhoneNameForm.

/**
 * Called before each and every request comes into the controller, and is placed on the request for use by those methods.
 *
 * @param request
 * @param model
 *
 * @return
 */
@ModelAttribute("phoneNameForm")
public PhoneNameForm initPhoneNameForm(HttpServletRequest request, Model model) {
    PhoneNameForm form = new PhoneNameForm();
    form.setPhone((Phone) entityConfiguration.createEntityInstance("org.broadleafcommerce.profile.core.domain.Phone"));
    return form;
}
Also used : PhoneNameForm(org.broadleafcommerce.profile.web.core.model.PhoneNameForm) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Aggregations

ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)59 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)19 IOException (java.io.IOException)7 Valid (javax.validation.Valid)6 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)6 SimpleDateFormat (java.text.SimpleDateFormat)5 LinkedHashMap (java.util.LinkedHashMap)5 HttpSession (javax.servlet.http.HttpSession)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Sort (org.springframework.data.domain.Sort)5 FileNotFoundException (java.io.FileNotFoundException)4 DateFormat (java.text.DateFormat)4 java.util (java.util)4 Callable (java.util.concurrent.Callable)4 ExecutionException (java.util.concurrent.ExecutionException)4 ExecutorService (java.util.concurrent.ExecutorService)4 Executors (java.util.concurrent.Executors)4 Future (java.util.concurrent.Future)4 TimeUnit (java.util.concurrent.TimeUnit)4 PreDestroy (javax.annotation.PreDestroy)4