I have requirement to show check boxes on freemarker page for below requirement-
User will have option to select multiple item from checkbox on Scree1 as demonstrated below -
Screen1 Checkbox Option -
Server1_CheckBoxOpn
Server2_CheckBoxOpn
Server3_CheckBoxOpn
Now Suppose User have selected Server1 And Server2 from Checkbox, Then there will be a database call for each choice and will have to show corresponding output as demonstrated below -
Screen2 Checkbox Option -
Server1
(Intance1_CheckBoxOpn,Intance2_CheckBoxOpn)
Server2
(Intance1_CheckBoxOpn,Intance2_CheckBoxOpn)
Here User can again select multiple option and based on input provided on screen2, I have to do some processing.
I have used freemaker as User Interface. I am facing two issue here-
Screen1 Problem I have used below code in Freemarker to display checkbox and binding with Entity-
<@spring.formCheckboxes path="mwaCatlogueProfile.hostName" options=hostnameMap separator="<br>"/>
Where mwaCatlogueProfile.hostName (String Data Type) is my Entity Field to bind user input with Entity And hostnameMap (HashMap) is Checkbox Option Value.
But by binding String Datatype I am getting user input as String with comma separated value .
When Trying to Bind List DataType FreeMarker is throwing below error -
org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors Field error in object 'startServerDto' on field 'hostNameList': rejected value [DLVJBSCHIU1087]; codes [typeMismatch.startServerDto.hostNameList,typeMismatch.hostNameList,typeMismatch.java.util.Map,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [startServerDto.hostNameList,hostNameList]; arguments []; default message [hostNameList]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Map' for property 'hostNameList'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.util.Map' for property 'hostNameList': no matching editors or conversion strategy found]
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:115) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
I want user input from checkbox as list instead of simple String.Since keeping spring binding as String giving me checkbox comma separated value.
Screen2 Problem- I need to display output group wise.To do so, I will have to use ServerName as Key and InstanceName as ListOfValues. I can write this in Java, but don't know how to display in FreeMarker. Please suggest code chuck for same.
Many Thank in advance. Mayank
Aucun commentaire:
Enregistrer un commentaire