Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyCommand extends HashMap<String, Object> {
- }
- Name: <form:input path="['name']" />
- org.springframework.beans.NotReadablePropertyException: Invalid property '[name]' of bean class [com.me.MyCommand]: Bean property '[name]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
- public class MyCommand {
- private final Map<String, Object> properties = new HashMap<String, Object>();
- public Map<String, Object> getProperties() { return properties; }
- // setter optional
- }
- Name: <form:input path="properties['name']" />
- public class SettingsInformation {
- private Map<String, SettingsValue> settingsMap= MapUtils.lazyMap(new HashMap<String, SettingsValue>(),FactoryUtils.instantiateFactory(SettingsValue.class));
- public Map<String, SettingsValue> getSettingsMap() {
- return settingsMap;
- }
- public void setSettingsMap(Map<String, SettingsValue > settingsMap) {
- this.settingsMap = settingsMap;
- }
- }
- public class SettingsValue {
- private String value;
- public SettingsValue(String value) {
- this.value = value;
- }
- public SettingsValue() {
- }
- public String getValue() {
- return value;
- }
- public void setValue(String propertyValue) {
- this.value = propertyValue;
- }
- @RequestMapping(value="/settings", method=RequestMethod.GET)
- public ModelAndView showSettings() {
- ModelAndView modelAndView = new ModelAndView("settings");
- SettingsDTO settingsDTO = settingsService.getSettings();
- Map<String, String> settings = settingsDTO.getSettings();
- SettingsInformation settingsInformation = new SettingsInformation();
- for (Entry<String, String> settingsEntry : settings.entrySet()) {
- SettingsValue settingsValue = new SettingsValue(settingsEntry.getValue());
- settingsInformation.getSettingsMap().put(settingsEntry.getKey(), settingsValue);
- }
- modelAndView.addObject("settings", settingsInformation);
- return modelAndView;
- }
- <form:form action="${actionUrl}" commandName="settings">
- <form:input path="settingsMap['exampleKey'].value"/>
- <input type="submit" value="<fmt:message key="settings.save"/>"/>
- </form:form>
- @RequestMapping(value="/settings", method=RequestMethod.POST)
- public ModelAndView updateSettings(@ModelAttribute(value="settings") SettingsInformation settings) {
- [...]
- }
- public class StandardDomain {
- private Map<String, AnotherDomainObj> templateMap= MapUtils.lazyMap(new HashMap<String, AnotherDomainObj>(),FactoryUtils.instantiateFactory(AnotherDomainObj.class));
- public Map<String, AnotherDomainObj> getTemplateContentMap() {
- return templateMap;
- }
- public void setTemplateContentMap(Map<String, AnotherDomainObj > templateMap) {
- templateMap = templateMap;
- }
- }
- public class AnotherDomainObj {
- String propertyValue="";
- public String getPropertyValue() {
- return propertyValue;
- }
- public void setPropertyValue(String propertyValue) {
- this.propertyValue = propertyValue;
- }
- }
- <input type="text" value="testthis" name="templateMap['keyName'].propertyValue"/>
Add Comment
Please, Sign In to add comment