November 3rd, 2009 by Lincoln Baxter III

New releases, and changes coming in PrettyFaces

PrettyFaces – SEO, Dynamic Parameters, Bookmarks, and Navigation for JSF / JSF2 version 2.0.3 offers a BIG new feature for URL validation, while 1.2.6 is a maintenance release, primarily adding the <p:link anchor=”…”> attribute – it does not include the new validation features.

Coinciding with the JSF2.0 release, OcpSoft will be updating PF1.2.x for maintenance only, however, community participation is still welcome on all versions of the project.

You can now become powered-by-prettyfaces, or have your prettyfaces-powered site listed to build additional SEO page-rank. We want to know who is using our tool!

While it could potentially impact some applications functional behavior, the change is necessary in order to make progress and enable cool new features now and in the future! So, apologies for any trouble, but we’re sure that you’ll like what’s coming!

Big new feature in 2.0.3_RC1:

Integrated URL validation – Everyone should be afraid of user input, and parsing values from the URL is no different. But be not afraid! It is now possible to attach JSF validators to URL and Query parameters. This functionality parallels the new <f:pageParam> tag provided in JSF2, but also provides additional hooks into Validation error handling.

<url-mapping id="validate">
	<pattern value="/validate/#{validationBean.pathInput}">
		<validate param="0" validatorIds="validator1 validator2" 
			onError="#{validationBean.handle}" />
	</pattern>
	<query-param name="param1" validatorIds="validator2" onError="pretty:demo">
		#{validationBean.queryInput}
	</query-param>
	<view-id>/faces/validation/test.jsf</view-id>
</url-mapping>

As you can see, path parameters may now be validated with the <validate> element, and query parameters have a new “validatorIds” attribute. Any number of validatorIds may be attached to a given parameter. If validation fails, the system will send a 404 – Page Not Found response to the client.

If the default validation error handling is not enough, each validation may be provided with an optional “onError” attribute, which can be a “pretty:mappingId” (which issues a redirect to the page specified), or a #{jsfBean.handlerMethod} to allow complete control of the validation error. If the handler method returns null, or empty, the error is ignored and the lifecycle will continue. If the handler method returns a pretty:mappingId, PrettyFaces navigation will be invoked.

May the power of pretty be with you.




Lincoln Baxter, III

About the author:

Lincoln Baxter, III is the Chief Editor of Red Hat Developers, and has worked extensively on JBoss open-source projects; most notably as creator & project lead of JBoss Forge, author of Errai UI, and Project Lead of JBoss Windup. This content represents his personal opinions, not those of his employer.

He is a founder of OCPsoft, the author of PrettyFaces and Rewrite, the leading URL-rewriting extensions for Servlet, Java EE, and Java web frameworks; he is also the author of PrettyTime, social-style date and timestamp formatting for Java. When he is not swimming, running, or playing competitive Magic: The Gathering, Lincoln is focused on promoting open-source software and making technology more accessible for everyone.

Posted in Releases

7 Comments

  1. Dominik says:

    Very nice lincoln! I will blog about this too!

    Greetings,
    Dominik

  2. Bjorn says:

    How do I validate URL parameters in PrettyFaces 1.2.6_RC1? Thanks in advance.

  3. Lincoln says:

    Integrated validation is only available in the 2.0.x series. Sorry, Bjorn. We’re phasing out enhancements to the 1.x series with the recent release of JSF2.

    As a workaround, I recommend doing validation in a prettyfaces action method.

  4. Kris says:

    How can I build pretty urls in trinidad iterator or
    Any help will be good.

    thanks!

  5. Lincoln says:

    Since Trinidad is a component, I’m not sure what you are asking. PrettyFaces defines behavior that occurs before view files are encountered, so iterator should not interfere at all with PrettyFaces. Also, if you could please post your next question to the users-group, we can answer your question for everyone there 🙂 thanks! Lincoln

    ( http://groups.google.com/group/prettyfaces-users )

  6. Kris says:

    Hi,
    I wanna display a list of product in my online store. To displaying products in jsf form i’m using data table or iterator component. So I do not know how to create pretty link for them 🙂

    Thx Kris

    1. Lincoln says:

      Just use pretty:link and pass in f:param value=”#{row.value}” like you would in any other link.

Leave a Comment




Please note: In order to submit code or special characters, wrap it in

[code lang="xml"][/code]
(for your language) - or your tags will be eaten.

Please note: Comment moderation is enabled and may delay your comment from appearing. There is no need to resubmit your comment.