Note that there are some explanatory texts on larger screens.

plurals
  1. POOverwriting DefaultFaceletFactory (SessionScoped viewid)
    primarykey
    data
    text
    <p><strong>Problem</strong><br> A viewId is applicationwide resolved. The Resolve happens only once and not every Time</p> <p><strong>Task</strong><br> Migrating a JSF 1.2 (Sun.RI) application to JSF2.0(Myfaces). This Application has an overwritten FacesViewHandler with custom FacletContext, DefaultFaceletFactory, DefaultFactory and a custom ResourceResolver.<br> We serve custom content for a viewId based on session data<br> Example:<br> The browser wanted viewId order.jsf and the app resolves this viewId to order_advanced.jsf. But in the browser there is only order.jsf visible. </p> <p>This was easy to achieve. We use a MappingBean for mapping the viewIds. This MappingBean is instantiated when the session starts, and the Resolver use this Mapping Bean.</p> <p><strong>What we have:</strong> </p> <ol> <li>Our Mapping Beans are in place and fully functional.</li> <li><p>Custom ResourceResolver</p> <pre><code>@Override public URL resolveUrl(final String path) { final PageMappingBean pmb = (PageMappingBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get( "pageMappingBean"); URL returnURL = _resolver.resolveUrl(pmb != null ? pmb.mapUrl(path) : path); return returnURL; } </code></pre></li> </ol> <p><strong>Observation</strong><br> Accessing a viewid, which is mapped, works for the first session. It is mapped and resolved.<br> Starting a new session with a different mapping does not resolve the viewid any more. </p> <p>This is due to the method (From Myfaces)</p> <pre><code>public Facelet getFacelet(String uri){ URL url = (URL) _relativeLocations.get(uri); if (url == null) { url = resolveURL(_baseUrl, uri); if (url != null) { Map&lt;String, URL&gt; newLoc = new HashMap&lt;String, URL&gt;(_relativeLocations); newLoc.put(uri, url); _relativeLocations = newLoc; } else { throw new IOException("'" + uri + "' not found."); } } return this.getFacelet(url); } </code></pre> <p>in class 'DefaultFaceletFactory'</p> <p><strong>Question</strong><br> How can we override the above method in <strong>Myfaces</strong> (Productive and testing environment). As mentioned above we had done this for JSF1.2 but in JSF 2.0 there is the additional VDL layer.</p> <p>Or is there an other way to solve the problem?</p> <p><strong>Note</strong><br> FacesFlow could possibly be a solution for our problem, but it can not be used in WAS8.0 application server, we are not allowed to:-(<br> For Mojarra(RI) we have a solution. There it is possible to set the context-param com.sun.faces.faceletFactory. This solution is working for us but can only be used in developing environment. Production and Testing is based on Myfaces.</p> <p>For now we have dropped the idea of having an applicationscoped FaceletFactory. We are using dynamic resolution of facelets: </p> <pre><code>&lt;ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"&gt; &lt;ui:include src="#{faceletMapper.map('/pagetoload.xhtml')}"/&gt; &lt;/ui:component&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload