/** * Gets the binding with the specified name, or returns null if no such binding is found. * @param name the name of the binding. * @return the binding */ public Binding getBinding(String name) { for (Binding binding : bindings) { if (name.equals(binding.getProperty())) { return binding; } } return null; }
/** * <p> * Adds a {@link DefaultMapping} for every configured view {@link Binding} for which there is an incoming request * parameter. If there is no matching incoming request parameter, a special mapping is created that will set the * target field on the model to an empty value (typically null). * </p> * * @param mapper the mapper to which mappings will be added * @param parameterNames the request parameters * @param model the model */ protected void addModelBindings(DefaultMapper mapper, Set<String> parameterNames, Object model) { for (Binding binding : binderConfiguration.getBindings()) { String parameterName = binding.getProperty(); if (parameterNames.contains(parameterName)) { addMapping(mapper, binding, model); } else { if (fieldMarkerPrefix != null && parameterNames.contains(fieldMarkerPrefix + parameterName)) { addEmptyValueMapping(mapper, parameterName, model); } } } }
Expression source = new RequestParameterExpression(binding.getProperty()); ParserContext parserContext = new SimpleParserContext(model.getClass()); Expression target = expressionParser.parseExpression(binding.getProperty(), parserContext); DefaultMapping mapping = new DefaultMapping(source, target); mapping.setRequired(binding.getRequired()); logger.debug("Adding mapping for parameter '" + binding.getProperty() + "'");
Expression source = new RequestParameterExpression(binding.getProperty()); ParserContext parserContext = new SimpleParserContext(model.getClass()); Expression target = expressionParser.parseExpression(binding.getProperty(), parserContext); DefaultMapping mapping = new DefaultMapping(source, target); mapping.setRequired(binding.getRequired()); logger.debug("Adding mapping for parameter '" + binding.getProperty() + "'");
/** * <p> * Adds a {@link DefaultMapping} for every configured view {@link Binding} for which there is an incoming request * parameter. If there is no matching incoming request parameter, a special mapping is created that will set the * target field on the model to an empty value (typically null). * </p> * * @param mapper the mapper to which mappings will be added * @param parameterNames the request parameters * @param model the model */ protected void addModelBindings(DefaultMapper mapper, Set<String> parameterNames, Object model) { for (Binding binding : binderConfiguration.getBindings()) { String parameterName = binding.getProperty(); if (parameterNames.contains(parameterName)) { addMapping(mapper, binding, model); } else { if (fieldMarkerPrefix != null && parameterNames.contains(fieldMarkerPrefix + parameterName)) { addEmptyValueMapping(mapper, parameterName, model); } } } }
private void addMapping(DefaultMapper mapper, Binding binding, Object model) { Expression source = new RequestParameterExpression(binding.getProperty()); ParserContext parserContext = new FluentParserContext().evaluate(model.getClass()); Expression target = expressionParser.parseExpression(binding.getProperty(), parserContext); DefaultMapping mapping = new DefaultMapping(source, target); mapping.setRequired(binding.getRequired()); if (binding.getConverter() != null) { ConversionExecutor conversionExecutor = conversionService.getConversionExecutor(binding.getConverter(), String.class, target.getValueType(model)); mapping.setTypeConverter(conversionExecutor); } if (logger.isDebugEnabled()) { logger.debug("Adding mapping for parameter '" + binding.getProperty() + "'"); } mapper.addMapping(mapping); }
/** * Gets the binding with the specified name, or returns null if no such binding is found. * @param name the name of the binding. * @return the binding */ public Binding getBinding(String name) { Iterator it = bindings.iterator(); while (it.hasNext()) { Binding binding = (Binding) it.next(); if (name.equals(binding.getProperty())) { return binding; } } return null; }
private void addModelBindings(DefaultMapper mapper, Set parameterNames, Object model) { Iterator it = binderConfiguration.getBindings().iterator(); while (it.hasNext()) { Binding binding = (Binding) it.next(); String parameterName = binding.getProperty(); if (parameterNames.contains(parameterName)) { addMapping(mapper, binding, model); } else { if (fieldMarkerPrefix != null && parameterNames.contains(fieldMarkerPrefix + parameterName)) { addEmptyValueMapping(mapper, parameterName, model); } } } }
/** * Gets the binding with the specified name, or returns null if no such binding is found. * @param name the name of the binding. * @return the binding */ public Binding getBinding(String name) { for (Binding binding : bindings) { if (name.equals(binding.getProperty())) { return binding; } } return null; }