List of usage examples for org.springframework.core Conventions getVariableName
public static String getVariableName(Object value)
From source file:com.brienwheeler.web.spring.web.ModelUtils.java
public static void addAttributeIfNotPresent(Model model, Object attributeValue) { String attributeName = Conventions.getVariableName(attributeValue); if (!model.containsAttribute(attributeName)) model.addAttribute(attributeName, attributeValue); }
From source file:com.sinosoft.one.mvc.web.var.ModelImpl.java
public Model add(Object value) { if (value != null) { if (value instanceof Collection) { Collection<?> collection = (Collection<?>) value; if (collection.size() == 0) { return this; }//from w w w . j a v a 2 s.c om } return add(Conventions.getVariableName(value), value); } return this; }
From source file:com.laxser.blitz.web.var.ModelImpl.java
@Override public Model add(Object value) { if (value != null) { if (value instanceof Collection) { Collection<?> collection = (Collection<?>) value; if (collection.size() == 0) { return this; }// ww w . j a va 2s . c o m } return add(Conventions.getVariableName(value), value); } return this; }
From source file:cn.iyowei.stockai.rest.DataMap.java
/** * Add the supplied attribute to this {@code Map} using a * {@link org.springframework.core.Conventions#getVariableName generated name}. * <p><emphasis>Note: Empty {@link Collection Collections} are not added to * the model when using this method because we cannot correctly determine * the true convention name. View code should check for {@code null} rather * than for empty collections as is already done by JSTL tags.</emphasis> * * @param attributeValue the model attribute value (never {@code null}) *///from ww w . j av a 2s . com public DataMap addAttribute(Object attributeValue) { Assert.notNull(attributeValue, "Model object must not be null"); if (attributeValue instanceof Collection && ((Collection<?>) attributeValue).isEmpty()) { return this; } return addAttribute(Conventions.getVariableName(attributeValue), attributeValue); }
From source file:org.springframework.boot.web.servlet.DynamicRegistrationBean.java
/** * Deduces the name for this registration. Will return user specified name or fallback * to convention based naming./*from www .jav a 2 s. c o m*/ * @param value the object used for convention based names * @return the deduced name */ protected final String getOrDeduceName(Object value) { return (this.name != null) ? this.name : Conventions.getVariableName(value); }
From source file:org.springframework.springfaces.mvc.internal.ModelBuilder.java
/** * Adds the specified key/value pair to the model as long as the model does not already contain the key. * @param source a textual description of the source of the item that can be used for logging * @param key the key to add to the model or <tt>null</tt> if the key should be generated from the value * @param value the value to add to the model. If the value is not specified then the model remains unchanged * @param resolveExpressions determines if values can contain <tt>String</tt> EL expression that should be resolved * @param expandModelHolder determines if values containing {@link SpringFacesModel} objects should have each member * of the holder added to the model as a separate item *//*from w w w . j a v a2s. c o m*/ private void addIfNotInModel(String source, String key, Object value, boolean resolveExpressions, boolean expandModelHolder) { if (value == null) { if (this.logger.isDebugEnabled()) { this.logger.debug("Skipping parameter " + source + " due to null value"); } return; } if (key == null) { key = Conventions.getVariableName(value); } if (this.model.containsKey(key)) { if (this.logger.isDebugEnabled()) { this.logger.debug("Skipping parameter " + source + " due to exsting value in model"); } return; } if (resolveExpressions) { value = resolveExpressionIfNecessary(value); } if (value instanceof SpringFacesModel && expandModelHolder) { SpringFacesModel modelHolder = (SpringFacesModel) value; for (Map.Entry<String, Object> modelEntry : modelHolder.entrySet()) { addIfNotInModel(source, modelEntry.getKey(), modelEntry.getValue(), false, false); } } else { this.model.put(key, value); } }