Guest User

Untitled

a guest
Jun 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. public class MyCommand extends HashMap<String, Object> {
  2. }
  3.  
  4. Name: <form:input path="['name']" />
  5.  
  6. 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?
  7.  
  8. public class MyCommand {
  9. private final Map<String, Object> properties = new HashMap<String, Object>();
  10.  
  11. public Map<String, Object> getProperties() { return properties; }
  12. // setter optional
  13. }
  14.  
  15. Name: <form:input path="properties['name']" />
  16.  
  17. public class SettingsInformation {
  18.  
  19. private Map<String, SettingsValue> settingsMap= MapUtils.lazyMap(new HashMap<String, SettingsValue>(),FactoryUtils.instantiateFactory(SettingsValue.class));
  20.  
  21. public Map<String, SettingsValue> getSettingsMap() {
  22. return settingsMap;
  23. }
  24.  
  25. public void setSettingsMap(Map<String, SettingsValue > settingsMap) {
  26. this.settingsMap = settingsMap;
  27. }
  28.  
  29. }
  30.  
  31. public class SettingsValue {
  32.  
  33. private String value;
  34.  
  35. public SettingsValue(String value) {
  36. this.value = value;
  37. }
  38.  
  39.  
  40. public SettingsValue() {
  41.  
  42. }
  43.  
  44. public String getValue() {
  45.  
  46. return value;
  47. }
  48.  
  49. public void setValue(String propertyValue) {
  50.  
  51. this.value = propertyValue;
  52. }
  53.  
  54. @RequestMapping(value="/settings", method=RequestMethod.GET)
  55. public ModelAndView showSettings() {
  56.  
  57. ModelAndView modelAndView = new ModelAndView("settings");
  58.  
  59. SettingsDTO settingsDTO = settingsService.getSettings();
  60. Map<String, String> settings = settingsDTO.getSettings();
  61.  
  62. SettingsInformation settingsInformation = new SettingsInformation();
  63.  
  64. for (Entry<String, String> settingsEntry : settings.entrySet()) {
  65. SettingsValue settingsValue = new SettingsValue(settingsEntry.getValue());
  66. settingsInformation.getSettingsMap().put(settingsEntry.getKey(), settingsValue);
  67. }
  68.  
  69. modelAndView.addObject("settings", settingsInformation);
  70.  
  71. return modelAndView;
  72. }
  73.  
  74. <form:form action="${actionUrl}" commandName="settings">
  75. <form:input path="settingsMap['exampleKey'].value"/>
  76. <input type="submit" value="<fmt:message key="settings.save"/>"/>
  77. </form:form>
  78.  
  79. @RequestMapping(value="/settings", method=RequestMethod.POST)
  80. public ModelAndView updateSettings(@ModelAttribute(value="settings") SettingsInformation settings) {
  81. [...]
  82. }
  83.  
  84. public class StandardDomain {
  85.  
  86. private Map<String, AnotherDomainObj> templateMap= MapUtils.lazyMap(new HashMap<String, AnotherDomainObj>(),FactoryUtils.instantiateFactory(AnotherDomainObj.class));
  87.  
  88. public Map<String, AnotherDomainObj> getTemplateContentMap() {
  89. return templateMap;
  90. }
  91.  
  92. public void setTemplateContentMap(Map<String, AnotherDomainObj > templateMap) {
  93. templateMap = templateMap;
  94. }
  95.  
  96. }
  97.  
  98. public class AnotherDomainObj {
  99.  
  100. String propertyValue="";
  101.  
  102. public String getPropertyValue() {
  103. return propertyValue;
  104. }
  105.  
  106. public void setPropertyValue(String propertyValue) {
  107. this.propertyValue = propertyValue;
  108. }
  109.  
  110.  
  111.  
  112. }
  113.  
  114. <input type="text" value="testthis" name="templateMap['keyName'].propertyValue"/>
Add Comment
Please, Sign In to add comment