Conditional HTTP 404 response, only with validation?

Splash Forums PrettyFaces Users Conditional HTTP 404 response, only with validation?


This topic contains 4 replies, has 2 voices, and was last updated by  Zhomart 10 years, 8 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #17916


    Hi guys,

    Just downloaded PrettyFaces 3.2.0, seems very clean & simple solution, but faced one thing, hope you guys could help me with it:

    I’ve got following classical case:

    http://website/product#{No} “Where #{No} is some number (ID)”

    So, my configs should contain something like this:

    <url-mapping id=”product-page”>

    <pattern value=”/product#{pid :}” />



    Since, one of the main aims of the pretty faces is SEO-friendliness, I wish there could be some convenient way of giving 404 response on non-existing product ID’s.

    After reading docs, I came up with following:

    1) <action>#{backing.loadItem}</action>

    But, it’s not possible, as I know, to bind some outcome to 404, without redirecting to some “fake” outcome, which would result in redirection to non-existing page.

    2) adding validation, the problem is validation is done before values are applied to the beans, it would be inconvenient workaround to prevent “product double-loading”.

    Any suggestions?


    PrettyFaces allows to send custom HTTP response codes using the PrettyContext class. Here is a simple example that shows how I solve the validation issue in my projects:

    <url-mapping id="report">
    <pattern value="/report/#{}/details" />

    public class ReportBean {

    private Long id;

    private ReportDao reportDao;

    public void loadData() {

    Report report = reportDao.getById(id);
    if(report == null) {

    // more stuff here


    /* Getters + Setters */


    I hope this helps! :)



    Thanks a lot!

    That’s awesome!


    Sounds like you like this feature! :)



    Yep, it is exactly what I wanted.

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

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

Comments are closed.