Search in sources :

Example 36 with ModelAttribute

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

the class SavingsProductChangeLogController method showAllAuditLogsForSavingsProducts.

@ModelAttribute("auditLog")
@RequestMapping(method = RequestMethod.GET)
public AuditLogScreenDto showAllAuditLogsForSavingsProducts(@RequestParam(value = "productId", required = true) Integer productId) {
    SavingsProductDto productDetails = adminServiceFacade.retrieveSavingsProductDetails(productId);
    List<AuditLogDto> auditLogRecords = adminServiceFacade.retrieveSavingsProductAuditLogs(productId);
    return new AuditLogScreenDto(productDetails.getProductDetails().getId(), productDetails.getProductDetails().getName(), productDetails.getProductDetails().getCreatedDateFormatted(), auditLogRecords);
}
Also used : SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) AuditLogScreenDto(org.mifos.dto.screen.AuditLogScreenDto) AuditLogDto(org.mifos.dto.domain.AuditLogDto) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 37 with ModelAttribute

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

the class DeleteCoaController method showForm.

@ModelAttribute("formBean")
@RequestMapping(method = RequestMethod.GET)
public CoaFormBean showForm(@RequestParam(value = "id", required = true) Short id) {
    CoaDto coaDto = coaServiceFacade.getCoaDTO(id);
    CoaFormBean formBean = new CoaFormBean();
    formBean.setCoaName(coaDto.getAccountName());
    formBean.setGlCode(coaDto.getGlCodeString());
    formBean.setAccountId(id);
    return formBean;
}
Also used : CoaDto(org.mifos.application.admin.servicefacade.CoaDto) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 38 with ModelAttribute

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

the class MonthClosingController method showPopulatedForm.

@ModelAttribute("monthClosingFormBean")
public MonthClosingFormBean showPopulatedForm() {
    MonthClosingFormBean formBean = new MonthClosingFormBean();
    Date monthClosingDateToSet = monthClosingServiceFacade.getMonthClosingDate();
    if (monthClosingDateToSet == null) {
        monthClosingDateToSet = new DateTime().toDate();
    }
    formBean.setDate(new DateTime(monthClosingDateToSet));
    formBean.setLocale(Locale.getDefault());
    return formBean;
}
Also used : Date(java.util.Date) DateTime(org.joda.time.DateTime) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 39 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project spring-petclinic by spring-projects.

the class VisitController method loadPetWithVisit.

/**
     * Called before each and every @RequestMapping annotated method.
     * 2 goals:
     * - Make sure we always have fresh data
     * - Since we do not use the session scope, make sure that Pet object always has an id
     * (Even though id is not part of the form fields)
     *
     * @param petId
     * @return Pet
     */
@ModelAttribute("visit")
public Visit loadPetWithVisit(@PathVariable("petId") int petId, Map<String, Object> model) {
    Pet pet = this.pets.findById(petId);
    model.put("pet", pet);
    Visit visit = new Visit();
    pet.addVisit(visit);
    return visit;
}
Also used : Visit(org.springframework.samples.petclinic.visit.Visit) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 40 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project spring-framework by spring-projects.

the class ModelInitializer method getAttributeName.

private String getAttributeName(Class<?> valueType, MethodParameter parameter) {
    Method method = parameter.getMethod();
    ModelAttribute annot = AnnotatedElementUtils.findMergedAnnotation(method, ModelAttribute.class);
    if (annot != null && StringUtils.hasText(annot.value())) {
        return annot.value();
    }
    // TODO: Conventions does not deal with async wrappers
    return ClassUtils.getShortNameAsProperty(valueType);
}
Also used : ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) InvocableHandlerMethod(org.springframework.web.reactive.result.method.InvocableHandlerMethod) Method(java.lang.reflect.Method)

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