pages.xml virtual pages usage
gonzalad Feb 26, 2008 12:17 PMHello,
Here's quite a long mail (sorry) !
Purpose
Request for enhancement.
Context
In our application, we have links calling some 'virtual' pages. Those virtual pages execute some actions before rendering the real pages.
Those 'virtual' pages enables us to do some pre-processing before rendering the real page (i.e. do some conversation cleanup stuff or things related).
Virtual and real pages are all declared in the pages.xml.
Our problem is that 'action', 'restrict', .. elements declared for the real pages are not
executed when coming from the 'real' page.
I suppose the 'virtual' pages mecanism could be interesting in other situations.
Is it viable to ask for an enhancement on this subject (executing 'action', 'restrict', 'login-required', 'conversation-required', 'page', ...on pages being rendered) ?
Please note, the notion of virtual pages has already been discussed before (lookat : http://www.jboss.com/index.html?module=bb&op=viewtopic&t=88388)
I define a virtual page in pages.xml, e.g. a page that doesn't actually exist, but where the action listener would decide the page to be rendered, e.g:<page view-id="/virtual.xhtml" action="#{switchboard.chooseAPage}" />
virtual.xhtml being non-existant, and switchboard.chooseAPage being a stateless session bean method that returns the real view-id to display.
The user would possibly enter the URL ending in /myapp/virtual.elvis, and #{switchboard.chooseAPage} might return a value such as eminem.jsp or britney.xhtml
Sample
Our menu actions are linked to the 'virtual pages' using the prefix '/global'.
For instance for our 'Charge / Search' link (Charge is an entity), we have the following jsf page fragment :
<rich:menuItem rendered="#{s:hasRole('EDUWSPH CHAINT')}"> <s:link id="rechercheChargeH" view="/global/charge/recherche_charge.jspx" value="Search Charge..."/> </rich:menuItem>
In our page.xml, we declare :
<page view-id="/global/*"> <action execute="#{conversationHelper.endAllConversationsAndBeginLongRunning}"/> </page> <page view-id="/views/*" login-required="true"/> <page view-id="/global/views/charge/*"> <action execute="#{menuAction.setMenuCourant('charge')}"/> </page> <page view-id="/global/views/charge/recherche_charge.jspx"> <navigation> <render view-id="/views/charge/recherche_charge.jspx"/> </navigation> </page> <page view-id="/views/charge/recherche_charge.jspx"> <restrict>#{s:hasRole('EDUWSPH CHAINT')}</restrict> <navigation from-action="#{rechercherChargeClienteleAction.reset}"> <render view-id="/views/charge/recherche_charge.jspx"/> </navigation> <navigation from-action="#{rechercherChargeClienteleAction.view}"> <begin-conversation nested="true"/> <render view-id="/views/charge/detail_charge.jspx"/> </navigation> </page>
'/global/views/charge/recherche_charge.jspx' is our virtual page.
'/views/charge/recherche_charge.jspx' is our real page.
So, looking at pages.xml, I would suppose when we call /global/charge/recherche_charge.jspx, that :
- action #{menuAction.setMenuCourant('charge')} is called (/global/views/charge/*).
- action #{conversationHelper.endAllConversationsAndBeginLongRunning} is called (/global/*)
- restrict #{s:hasRole('EDUWSPH CHAINT')} is called (/views/charge/recherche_charge.jspx)
- login-required=
true
is executed (views/*) - we render page /views/charge/recherche_charge.jspx
But : 3 and 4 is not called.
Also, if we add action elements on page view-id=/views/charge/recherche_charge.jspx
, those action are not called.
Why are we doing this ?
Because when we come from a menu link (/global/views/charge/recherche_ charge.jspx),
we want to clear all conversations whereas when we postback the page /views/charge/recherche_charge.jspx we don't want conversations to be cleared !
Putting all the cleanning stuff in one place only ('page view-id=/global/*
') appears also to be quite clean.
Alternate solutions
if not, has something a better idea for handling conversation cleanup on menu links ?
1. just adding an action element on menu s:link ?
i.e.
<s:link id="rechercheChargeH" view="/global/charge/recherche\_charge.jspx" value="Search Charge..." action="#{conversationHelper.endAllConversationsAndBeginLongRunning}"/>
cons : this scatters action code across all the menus, and we are limited to calling only one action.
2. use 'redirect' on /global virtual pages and not 'render' (smells quite bad IMO).
Thanks for your help.