List of usage examples for org.springframework.ui Model addAttribute
Model addAttribute(String attributeName, @Nullable Object attributeValue);
From source file:org.zht.framework.data.ParamObject.java
public static void setModelAttribute(Model model, ParamObject paramObject) { if (model == null || paramObject == null) { return;/*from ww w. j a v a2s .c om*/ } model.addAttribute("webParams", paramObject.getWebParams()).addAttribute("paramObject", paramObject); }
From source file:org.zht.framework.web.controller.BaseController.java
protected static void setDataAttribute(Model model, List<?> dataList, String dataName, Long totalCount, String countNnme) {/*from www.j a va2 s . c o m*/ if (model == null || dataList == null || dataName == null) { return; } model.addAttribute(dataName, dataList).addAttribute(countNnme, totalCount == null ? 0L : totalCount); }
From source file:org.zht.framework.web.controller.BaseController.java
protected static void setDataAttributeAndPageInfo(Model model, List<?> dataList, String dataName, Long totalCount, ParamObject paramObject) { if (model == null || dataList == null || dataName == null || paramObject == null) { return;//from ww w. ja va 2 s . c o m } model.addAttribute(dataName, dataList).addAttribute("totalCount", totalCount == null ? 0L : totalCount); model.addAttribute("webParams", paramObject.getWebParams()).addAttribute("paramObject", paramObject); }
From source file:org.zht.framework.web.controller.BaseController.java
protected static void setDataAttributeAndPageInfo(Model model, List<?> dataList, String dataName, Long totalCount, String countNnme, ParamObject paramObject) { if (model == null || dataList == null || dataName == null || paramObject == null) { return;//from w ww . j ava 2 s . c o m } model.addAttribute(dataName, dataList).addAttribute(countNnme, totalCount == null ? 0L : totalCount); model.addAttribute("webParams", paramObject.getWebParams()).addAttribute("paramObject", paramObject); }
From source file:ru.mystamps.web.controller.SeriesController.java
private static void addImageFormToModel(Model model) { AddImageForm form = new AddImageForm(); model.addAttribute("addImageForm", form); }
From source file:com.github.sebhoss.identifier.usecases.IndexPages.java
@SafeVarargs private static String index(final Model model, final Integer quantity, final Consumer<Model>... consumers) { Arrays.stream(consumers).forEach(consumer -> consumer.accept(model)); model.addAttribute(QUANTITY, quantity); return "index"; // delegates to the 'index' template }
From source file:com.mobileman.projecth.web.util.UserUtils.java
public static void changePassword(User user, HttpServletRequest request, Model model, UserService service, ConfigurationService configurationService) { try {//w ww. j av a2 s .c o m //String oldPassword = request.getParameter("oldpassword"); String password = request.getParameter("password"); String password2 = request.getParameter("password2"); if (StringUtils.isNotBlank(password)) { if (!password.equals(password2)) { model.addAttribute("passwordnotsame", true); } else { service.changePassword(user.getId(), password); model.addAttribute("passwordchanged", true); } } } catch (LoginException lex) { switch (lex.getReason()) { case PASSWORD_TOO_LONG: model.addAttribute("errorpassword_too_long", Boolean.TRUE); model.addAttribute("max_password_length", configurationService.getMaxPasswordLength()); break; case PASSWORD_TOO_SHORT: model.addAttribute("errorpassword_too_short", Boolean.TRUE); model.addAttribute("min_password_length", configurationService.getMinPasswordLength()); break; default: model.addAttribute("passworderror", true); } } catch (Exception ex) { model.addAttribute("passworderror", true); } }
From source file:de.hybris.platform.acceleratorstorefrontcommons.controllers.util.GlobalMessages.java
public static void addMessage(final Model model, final String messageHolder, final String messageKey, final Object[] attributes) { final GlobalMessage message = new GlobalMessage(); message.setCode(messageKey);/*from ww w . ja v a2s . c om*/ message.setAttributes(attributes != null ? Arrays.asList(attributes) : Collections.emptyList()); final Map<String, Object> modelMap = model.asMap(); if (modelMap.containsKey(messageHolder)) { final List<GlobalMessage> messages = new ArrayList<>((List<GlobalMessage>) modelMap.get(messageHolder)); messages.add(message); model.addAttribute(messageHolder, messages); } else { model.addAttribute(messageHolder, Collections.singletonList(message)); } }
From source file:com.mobileman.projecth.web.util.PatientUtils.java
/** * @param model/*from w ww . ja va 2s . c o m*/ * @param data * @param patient * @param selectedDisease */ public static void loadPatientHeader(Model model, DataHolder data, User patient, Disease selectedDisease) { LocaleService localeService = InitController.getWebApplicationContext().getBean(LocaleService.class); String patien_name = localeService.getUnknowMessage(); String patien_surname = localeService.getUnknowMessage(); Name name = patient.getName(); if (name != null) { patien_name = name.getName(); patien_surname = name.getSurname(); } model.addAttribute("visitorCanSeeUserData", Boolean.TRUE); model.addAttribute("patien_login", patient.getUserAccount().getLogin()); model.addAttribute("patien_name", patien_name); model.addAttribute("patien_surname", patien_surname); Pair<Date, Date> diagDates = data.getInitialSymptomAndDaiagnosisDate(); model.addAttribute("patient_initialsymptomdate", DateUtils.germanLongDate2str(diagDates.getFirst())); model.addAttribute("patient_initialdiagnosisdate", DateUtils.germanLongDate2str(diagDates.getSecond())); String gend = UserUtil.fmtGender(patient); model.addAttribute("patient_gender", gend); model.addAttribute("patient_avatar", computeAvatar(patient.getSex())); model.addAttribute("patient_age", computeAge(patient.getBirthday())); model.addAttribute("patient_place", patient.getCountry() != null ? patient.getCountry().getName() : localeService.getUnknownLocation()); model.addAttribute("patient_logincount", patient.getLoginsCount()); model.addAttribute("patient_created", DateUtils.germanShortDate2str(patient.getUserAccount().getCreated())); model.addAttribute("patient_lastlogin", DateUtils.germanShortDate2str(patient.getLastLogin())); model.addAttribute("patient_lastupdate", DateUtils.germanShortDate2str(patient.getLastUpdate())); model.addAttribute("patient_my_story", patient.getAboutMe()); model.addAttribute("user_weight", UserUtils.fmtUserWeight(patient)); //diseases List<Disease> diseases = patient.getDiseases(); List<DiseaseInfo> diseaseInfo = new ArrayList<DiseaseInfo>(); Long selectedDiseaseId = selectedDisease == null ? null : selectedDisease.getId(); for (Disease disease : diseases) { diseaseInfo.add(new DiseaseInfo(disease, patient.getId(), selectedDiseaseId)); } model.addAttribute("patient_diseases", diseaseInfo); //medications model.addAttribute("patient_selected_disease", data.getDisease()); if (selectedDiseaseId != null) { model.addAttribute("patient_medications", InitController.getWebApplicationContext().getBean(PatientMedicationService.class) .findAllConsumedMedications(patient.getId(), selectedDiseaseId)); } }
From source file:com.exxonmobile.ace.hybris.storefront.controllers.util.GlobalMessages.java
public static void addMessage(final Model model, final String messageHolder, final String messageKey, final Object[] attributes) { final GlobalMessage message = new GlobalMessage(); message.setCode(messageKey);/*from w w w.j a v a 2 s . com*/ message.setAttributes(attributes != null ? Arrays.asList(attributes) : Collections.emptyList()); final Map<String, Object> modelMap = model.asMap(); if (modelMap.containsKey(messageHolder)) { final List<GlobalMessage> messages = new ArrayList<GlobalMessage>( (List<GlobalMessage>) modelMap.get(messageHolder)); messages.add(message); model.addAttribute(messageHolder, messages); } else { model.addAttribute(messageHolder, Collections.singletonList(message)); } }