The pages.xml file assumes that for a given view-id, all responses/updates
are handled identically. That isn't necessarily a good idea as it means that the
action is the same in all cases and that violates separation of concerns. In specific, the
example in the tutorial:
| <page view-id="/calculator.jsp"
action="#{calculator.calculate}">
| <param name="x" value="#{calculator.lhs}"/>
| <param name="y" value="#{calculator.rhs}"/>
| <param name="op" converter="#{operatorConverter}"
value="#{calculator.op}"/>
| </page>
|
implies that calculator.calculate knows about EVERY op possible. In this example, it
isn't possible to add a new operation without modifying calculator.calculate.
Sometimes that is a good idea if there are a very few operations available, but if there
are lots of operations, then calculator.calculate needs to have some sort of registration
mechanism for new operations - however, consider the operation ?: that takes x,y,z. This
operation won't work because the parsing doesn't work correctly. Or consider the
hex conversion operation - again, the value is probably a double or integer or some such
thing, and the parsing doesn't work for that either.
It would be helpful to have something like:
| <pages>
| <page view-id="/calculator.jsp"
action="#{calculator.calculate}">
| <param name="x" value="#{calculator.lhs}"/>
| <param name="y" value="#{calculator.rhs}"/>
| <param name="op" converter="#{operatorConverter}"
value="#{calculator.op}"/>
| <view-modifier value="#{calculator.op}" />
| </page>
| <page view-id="/calculator.jsp" view-modifier="+"
action="#{calculator.add}" />
| <page view-id="/calculator.jsp" view-modifier="?:">
| <param name="z" value="#{trivalued.z}" />
| </page>
| </pages>
|
Note that this works fairly well with RESTful services - the post can be done to the same
URL, but different actions can go through different operations, and then still render the
same overall page.
It also works well if you want to add another outcome variant - just add a view modifier
and add a new outcome.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049427#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...