I have used spring MVC with JSP/JSTL for my previous application. I was going through JSF for my next project. But now I'm wondering how do I manage this all with many navigation rules. Won't the application become tightly coupled? How do I use it for a large project.
Asked
Active
Viewed 346 times
1
-
_Won't the application become tightly coupled?_ Please elaborate – jmj Jul 01 '12 at 18:11
-
This is indeed not tight coupling. Instead, navigation rules in `faces-config.xml` makes it too loosely coupled. Basically, it's one abstract layer "too much". This extra layer is often not beneficial in the average JSF web appilcation and can thus safely be omitted by using implicit navigation. – BalusC Jul 01 '12 at 18:24
-
Take a look at PrettyFaces http://ocpsoft.org/prettyfaces/ – La Chamelle Jul 02 '12 at 09:32
-
@LaChamelle: PrettyFaces is an URL rewriting solution, not a navigation handler. – BalusC Jul 02 '12 at 12:21
1 Answers
1
Just make use of implicit navigation. If you make your navigation case outcome
the same as the to-view-id
, then you don't need to define a <navigation-case>
at all.
For simple page-to-page navigation, use <h:link>
or <h:button>
.
<h:link value="Go to page2" outcome="page2" />
The link's URL will implicitly resolve to the right URL for page2.xhtml
.
For navigation on form submits as performed by <h:commandLink>
and <h:commandButton>
, return the proper outcome in action method.
public String submit() {
// ...
return "page2";
}
Note that using POST for plain page-to-page navigation is bad design as this is user and SEO unfriendly.