2

It's easily possible with JSF2 to process GET requests with this annotations:

<f:metadata>
  <f:viewParam name="id" value="#{bean.id}"/>
  <f:viewParam name="name" value="#{bean.name}"/>
  <f:event type="preRenderView" listener="#{bean.init}" />
</f:metadata>

and the init method in my bean:

public void init(ComponentSystemEvent e) throws AbortProcessingException {...}

This can be accessed with something like test.jsf?id=8012&name=name. Is it possible to use it like the @PathParam in REST and write the URL like test/8012/name?

PS: I know there is a term for this, but I cannot remember ....

1
  • 3
    RESTful URLs, Friendly URLs, Pretty URLs .. PrettyFaces! Commented Sep 3, 2011 at 5:56

1 Answer 1

3

The easiest way to accomplish this is by using PrettyFaces. You'll make a pretty-config.xml file that will look like this:

<url-mapping id="test">
  <pattern value="/test/#{id}/#{name}"/>
  <view-id value="/faces/test.jsf"/>
</url-mapping>

Really, it's dead simple. PF will inject path parameters into your managed beans and will even call an action afterwards if you like. I love it. :) The official documentation is probably everything you need.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.