简体   繁体   中英

How to extract url path and query parameters from JSF 2.2?

I'm new to JSF. I have two use cases.

1: URL: https://site.com/context/part/{partId}
2: URL: https://site.com/context/register-token?tokenType=xxxxxx&token=xxxxx

in each of these cases i'd like to extract the variable information, execute code in a java class (scoped bean/@PostConstruct, i presume) then display appropriate content based on the values.

I'm sure this is pretty straight forward in JSF and I have seen quite a few nice suggestions on how to do pieces of these, but they seem to not be without controversy, so I can't say they're the correct way due to my ignorance. Additionally there seems to be significant enough changes in 2.2 the older posts could be out of date as far as "correctness" goes. Lastly there doesn't seem to be a guide (that I can find) that specifically talks to these workflows specifically in 2.2.

Can anyone provide me a semi comprehensive "correct" way to do these things in JEE7/JSF2.2?

Correct can be subjective I know, but my thinking though this seems rudimentary enough that in this case a vanilla happy path suggestion would be enough.

Much appreciated, thanks.

Finishing comment from above as the last issue has been resolved...

For workflow 1: i found this and it worked: http://www.oracle.com/technetwork/articles/java/jsf22-1377252.html

But it seemed limited to query params.

For workflow 2: I'm using prettyfaces and i was able to get it to work ~sort-of~ by using this (Section 3.6): http://ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.actions

My web assets not resolving issue was resolved, by using this tip given by @chkal: PrettyFaces using mapped urls and actions, i lose all my stylings .

This suggestion pushed me over the edge to abandon a pure JSF solution and use pretty faces especially since im going to lean towards workflow 2 more often than not: Should I use f:event or action element in PrettyFaces?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM