javascript - SpringMVC : handling validation errors on a page with an ajax loaded <select> -


i'm running issue springmvc, , know if others have also.

i have <form:select> binded bean property. in jsp, after user entered inputs, select populated <options> via javascript. when post form, try validate server-side, , in case of errors, same jsp displayed <form:errors> fields showing different errors fixed.

the problem have when displaying jsp, value choosen in <form:select> lost.

this must related fact there no <form:options> when page generated, loaded via js.

what solutions handle particular case? must absolutely load select <options> server side ?

i haven't found on issue on internet, , can't believe 1 running it...

what actual problem is,

you <form:options> values loaded using javascript , once post form. create page post in-turn creates httprequest server.

incase of errors redirect same jsp page , wont contain entered values

workaround

you instead post page using ajax value retained in form , incase of errors.

instead making whole things changing in server-side. , alternate way loading options requestattribute , can set using model.addattribute() controller.


Comments

Popular posts from this blog

python - Mongodb How to add addtional information when aggregating? -

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

java - Incorrect order of records in M-M relationship in hibernate -