routing - Play Framework - Variables in URL instead of as ? parameters -


i'm starting learn play, basic question, i've searched every term can think of , can't find answer.

all want have page on submit takes id text field , puts in url directly (e.g. /myservice/person/123). instead, url being generated contains id parameter (e.g. /myservice/person?id=123).

i know controller being invoked correctly if type url in hand, i'm inclined think routes file correct. entry looks like:

get   /person/:id    controllers.personactions.getperson(id: string)  

so i'm assuming going wrong in template, looks this:

@form(routes.personactions.getperson(personid)) {     @* @inputtext(personform("id")) *@     <input type="text" name="id" value="@personid">     <input type="submit" value="get"> } 

you can see i've commented out way using @inputtext also, behaves identically me. i'm not tied either method.

i've tried using post, removes id url entirely, don't understand either, since i'm doing simple query, i'd rather use get.

can me understand what's going on here? feel there's fundamental how routing/urlgeneration works i'm not understanding, i've gone through tutorial , docs many times today i'm @ loss.

thanks in advance.

oh, , i'm using java 7, play 2.1, , eclipse kepler

i think trying skip step , map form request data view directly controller method. need submit form, have controller parse data , render next appropriate view based on data parsed form.

remember personid in view parameter bound server-side when view rendered. in case, submit url of form hard coded whatever personid passed in view @ render time -- doesn't change dynamically when input box changes.

to fix, add controller method accept requests /person (i'm guessing based on part in question says form being submitted /person?id=123, in case should url of form you've shown above)

e.g. if want use method form add:

get     /person     controllers.personactions.findperson(id: string) 

and in personactions controller (i'm assuming you're using java, if scala i'm sure can adapt docs)

public static result findperson(string id){     /*      * i'm assuming method exists , works because       * when type in /person/123 manually routing works       * , router says getperson method name url.      */     return getperson(id); } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -