-1

I have this URL

http://localhost:8084/somesite/leaveHTML.xhtml?id=somestring.

Now i am able to extract the id from the URL using jquery but i am not so sure, how can i use this string to retrieve the data from the database and populate the fields onload of a JSF page.

DataNucleus
  • 15,497
  • 3
  • 32
  • 37
phenom_aks
  • 77
  • 4
  • 11
  • Related: [What can `` and `` be used for?](http://stackoverflow.com/questions/6377798/what-can-fmetadata-and-fviewparam-be-used-for) – BalusC Oct 29 '12 at 13:06

1 Answers1

4

I don't really understand why you need to retrieve URL using jQuery. If you just need to populate you web page with data from database based on the URL parameters, you can just use JSF <f:viewparam> tag for that purpose.

<f:viewParam id="id" name="id" value="#{myBean.id}" required="true" />

It will retrieve parameters and assign them as bean values. If you really need to send it from your view you can use something like Seam remoting and use it to send URL parameters via ajax to your server. Or maybe even easier, create a servlet and communicate to it via ajax to retrieve info from database via ajax.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Ilya Sidorovich
  • 1,530
  • 1
  • 13
  • 15