hibernate - Multi page form data validation in Play Framework? -


i beginner in java play framework. building app take form data spread in multiple pages 4 5 pages. data mapped same model. how can data uploaded user per page, validate against model's constraints, , @ end save whole data in model.

for ex:- if page 1 has name field required, , page 2 has hobbies field required. how can validate data filled in particular page, navigate till last page, , save data in model, in last page.

model have 60-70 fields.

i using hibernate orm.

thanks !

you prefill next form values of last form, save them in database, go next form, load entered values values , pre-fill next form , on. this, use method in controller:

public static result filloutform1(){  hobby form1 = new hobby("sitting still", "diabetes");  form<hobby > prefilledform = newhobbyform.fill(form1);  return ok(views.html.yourviewclass.render(prefilledform); } 

with "send" values first view class form. in there, user answers more fields , hits submit. need route controller, handle new input in routes.conf:

get     /form1              controllers.application.filloutform1() post    /form1              controllers.application.sendform1() 

this in controller class:

public static result sendform1(){         form<hobby> boundhobby = newhobbyform.bindfromrequest();         hobby newhobby = boundhobby.get();         //in hobby class need finder implementation, can interact database. save() put database. may different database use!         newhobby.save();          return redirect(routes.application.index()); } 

you can not redirect index, next view class next form , there last answers db, prefill them again , put them form. need.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -