writing the correct url input

Splash Forums PrettyFaces Users writing the correct url input

This topic contains 1 reply, has 2 voices, and was last updated by  Christian Kaltepoth 9 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #18627


    Hi All,

    I have the following configuration

    <url-mapping id=”viewItem”>

    <pattern value=”/store/#{mik: invCtrl.mik}/#{iid }” />

    <view-id value=”/welcome.jsf”/>


    and the following pretty link

    <pretty:link mappingId=”viewItem”>

    View Car

    <f:param value=”#{invCtrl.modelId}”/>

    <f:param value=”#{invCtrl.makeId}”/>


    The url that is generated from that is:


    where the numbers are the ids of the make and model of a car.

    I would like the url to be displayed as


    any idea how to do that.



    Sure, you can do that. Typically developers are using database IDs to reference an object from the database in the URL like you did before. This is usually a very nice way to do it because you can simply use the ID from the URL to load the corresponding object from the database.

    If you want to have names in the URL this will become a little bit harder. If your model object has something like a name you could use that instead. But you have to make sure that names are unique so that you can always find the correct model object in the database when only having the name and not the ID any more.

    If cannot make sure that the name is unique, you should add something like a “URL key” property to your object which is guaranteed to be unique (containing “toyota” for example).

    Another option would be to use both the ID and the name of the entity in the URL. Something like:


    That would allow you to use the ID to load the correct object from the database and you have a pretty name of the entity in the URL. You would use the ID to load the object from the database and just ignore the name

    That’ something Amazon does in a similar way. Look at this URL:


    The text “Whats-New-Java-7-ebook” is for SEO reasons only. In fact you can also use this URL:


    So the unique ID for the item is “B005XSS8VC”.

    Hope this helps


Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.