Ahem, there's no right or wrong way.
Option 2 has the (big) advantage that it requires less code.
Option 1 has the advantage that the business logic is not coupled to FacesMessages, which
means that it would be reusable as a WS or whatever.
So it really depends on asking yourself the question: "how likely is it that I'm
going to need to use this functionality from something other than JSF in the next 6
months?"
And, or course, that's often a very difficult problem to answer. However, if you
don't have a great answer, notice that with modern refactoring tools, it is really not
that difficult to get from 2 to 1 if and when you need to do it. In fact, its only
arguable that there is less work to do 1 immediately rather than do 2 now and then
refactor to get to 1 (if and when you need it).
I strongly believe that it's usually much more important to get *working functionality
now*, than it is to plan for stuff that might or might not happen in 6 months or a year or
two years. Deliver useful stuff ASAP, secure ongoing funding for your project, and ongoing
cooperation, trust and feedback from your users. Then in 6 months time when you really
need it, you'll be able to do the refactorings you really need, with a lot less
pressure, and a lot more knowledge.
BTW, there is always Option 3:
<rule if="#{addressmanager.addressChangeAllowed}">
| <redirect view-id="/addressChanged.xhtml">
| <message>The address was changed.</message>
| </redirect>
| </rule>
| <rule if="#{not addressmanager.addressChangeAllowed}">
| <render view-id="/changeAddress.xhtml">
| <message>The address can not be changed.</message>
| </render>
| </rule>
| |
| | But I understand that this is not to all tastes ;-)
| |
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4032901#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...