<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaWords &#187; JavaServer Faces</title>
	<atom:link href="http://javawords.com/category/web-apps/jsf/feed/" rel="self" type="application/rss+xml" />
	<link>http://javawords.com</link>
	<description>A blog about Java Programming Language. Tips and solutions for common problems, tools and resources, tutorials and guides. A window to share my Java experience with others.</description>
	<lastBuildDate>Tue, 17 Jan 2012 15:53:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Using JSF 1.2 with Facelets on Google App Engine for Java</title>
		<link>http://javawords.com/2009/06/05/using-jsf-12-with-facelets-on-google-app-engine-for-java/</link>
		<comments>http://javawords.com/2009/06/05/using-jsf-12-with-facelets-on-google-app-engine-for-java/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 16:19:40 +0000</pubDate>
		<dc:creator>Christos Fragoulides</dc:creator>
				<category><![CDATA[JavaServer Faces]]></category>
		<category><![CDATA[Web Applications]]></category>

		<guid isPermaLink="false">http://javawords.com/2009/06/05/using-jsf-12-with-facelets-on-google-app-engine-for-java/</guid>
		<description><![CDATA[On April Google announced the support for Java on Google App Engine. I became aware of this last week and rushed to create an account and check it out. Since this is an &#8216;early look&#8217; release, I had to wait until the guys at Google grant me the rights to use the service. Meanwhile I [...]]]></description>
			<content:encoded><![CDATA[<p>On April Google announced the support for <strong>Java on Google App Engine</strong>. I became aware of this last week and rushed to create an account and check it out. Since this is an &#8216;early look&#8217; release, I had to wait until the guys at Google grant me the rights to use the service. Meanwhile I downloaded the SDK and started building a test application to check if the frameworks I mostly use are supported. My minimum requirements are <strong>JSF 1.2</strong> with <strong>Facelets</strong> for templating (I also use ICEfaces but I can live without them). The results where positive while using the SDK on my computer but when I&#8217;ve uploaded the application on App Engine (my account was activated two days ago) I received a nasty error thrown during the initialization phase of JSF.<span id="more-27"></span></p>
<p>After hours of searching and debugging I finally managed to get it up and running. Now I&#8217;m going to list the steps involved. The most interesting and insightful resource I found is <a href="http://ctpjava.blogspot.com/2009/04/jboss-seam-on-google-app-engine-first.html">this post</a>, which describes how to setup JSF on App Engine as a step in configuring JBoss Seam.<br />
As the post author states, you&#8217;ll have to enable sessions in <em>appengine-web.xml</em>, then configure JSF as usually, then set it up to use JBoss&#8217;s EL implementation and finally use those <a href="http://code.google.com/p/ctpjava/source/browse/#svn/trunk/projects/google-appengine/patches">patched classes</a> in order to avoid API calls that are restricted by the security policy of App Engine. I only used the patched classes under &#8216;jboss-el&#8217; and &#8216;jsf_mojarra&#8217; since I don&#8217;t use Seam.</p>
<p>After this I added Facelets and gone through the necessary configuration steps, built the application and tried to run it on App Engine.<br />
<br />
Problems Occurred (yes, of course, <a href="http://en.wikipedia.org/wiki/Murphy%27s_law">Murphy&#8217;s Law</a> dictates it):<br />
<br />
<strong>1)</strong> <em>FacesServlet</em> was not properly initialized. This is probably because App Engine does not initialize servlets at startup, instead initialization is postponed until the first request. As a result an <em>IllegalStateException</em> was thrown. To resolve the issue I had to add the following to <em>web.xml</em>:<br />
<code>&lt;listener&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;listener-class&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;com.sun.faces.config.ConfigureListener<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/listener-class&gt;<br />
&lt;/listener&gt;</code><br />
Error Message:<br />
<strong><small><em>javax.servlet.ServletException: java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory</em></small></strong><br />
<br />
<strong>2)</strong> An error was thrown during <em>FacesServlet</em> initialization due to the use of a restricted class. After examining the stack trace I realized that JSF was trying to perform some XML validation and failed throwing a <em>NoClassDefFoundError</em>. I had no other option but to deactivate XML validation by setting the following at <em>web.xml</em>:<br />
<code>&lt;context-param&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;param-name&gt;com.sun.faces.validateXml&lt;/param-name&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;param-value&gt;false&lt;/param-value&gt;<br />
&lt;/context-param&gt;</code><br />
Error Message:<br />
<strong><small><em>java.lang.NoClassDefFoundError: com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary is a restricted class. Please see the Google App Engine developer&#8217;s guide for more details.</em></small></strong><br />
<br />
<strong>3)</strong> EL API classes were missing, had to include the <a href="https://uel.dev.java.net/download.html">EL API</a> class library to the project.<br />
<br />
Error Message:<br />
<strong><small><em>java.lang.ClassNotFoundException: javax.el.CompositeELResolver</em></small></strong><br />
&nbsp;  </p>
<p>One last upload of the application after all the above tweaks and voilà! The homepage loaded without any errors! The fact is that I didn&#8217;t have time to perform any further tests and for sure I cannot tell if all the features of JSF and Facelets will work normally. I&#8217;m waiting for your feedback on this. Good Luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://javawords.com/2009/06/05/using-jsf-12-with-facelets-on-google-app-engine-for-java/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mapping FacesServlet to URLs without extensions</title>
		<link>http://javawords.com/2007/10/02/mapping-facesservlet-to-urls-without-extensions/</link>
		<comments>http://javawords.com/2007/10/02/mapping-facesservlet-to-urls-without-extensions/#comments</comments>
		<pubDate>Tue, 02 Oct 2007 21:18:36 +0000</pubDate>
		<dc:creator>Christos Fragoulides</dc:creator>
				<category><![CDATA[JavaServer Faces]]></category>

		<guid isPermaLink="false">http://javawords.com/2007/10/02/mapping-facesservlet-to-urls-without-extensions/</guid>
		<description><![CDATA[Over the past few months, I&#8217;ve been working on JavaServer Faces, making an effort to learn the framework and ultimately use it to create a web application. Currently I&#8217;m still in the learning process and the more I&#8217;m involved with JSF, the more I&#8217;m becoming a fan of it. The last challenge I&#8217;ve faced is [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past few months, I&#8217;ve been working on JavaServer Faces, making an effort to learn the framework and ultimately use it to create a web application. Currently I&#8217;m still in the learning process and the more I&#8217;m involved with JSF, the more I&#8217;m becoming a fan of it. The last challenge I&#8217;ve faced is not directly related with JSF, but has to do with Servlets in general.</p>
<p>When you declare a Servlet in your web application&#8217;s configuration file (that&#8217;s web.xml), you also have to declare a mapping for the Servlet to make the web container forward the requests to the Servlet. There&#8217;s two types of mappings you can choose from: extension mapping and prefix mapping. Extension mapping will be of the form <em>&#8220;*.extension&#8221;</em> and path prefix mapping will be <em>&#8220;/path/*&#8221;</em>. Here&#8217;s an example:</p>
<p><code>&lt;servlet&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;<br />
&lt;/servlet&gt;<br />
&lt;servlet-mapping&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;url-pattern&gt;*.faces&lt;/url-pattern&gt;<br />
&lt;/servlet-mapping&gt;</code></p>
<p>I prefer extension mapping for JSF, because this way I&#8217;m not restricted to have a certain path for my JSF-enabled pages. The challenge I was talking about previously, has to do with my requirement to go beyond the default mapping mechanism. I want to be able to invoke JSF pages from any path, <strong>without using an extension</strong>. For example, say there is a JSF page displaying user account information, that has to be invoked using the URL <em>&#8220;/account/view.faces&#8221;</em>.  Wouldn&#8217;t it be nicer to have &#8220;/account/view&#8221; instead?</p>
<p>After a small research, I&#8217;ve found out that a Filter can do the job. All that have to be done is a check of the requested URL pattern and if it match the mapping criteria, forward the request to the FacesServlet. Here is how I&#8217;ve done it:<span id="more-17"></span></p>
<p><code>public class MappingFilter extends HttpServlet implements Filter {<br />
&nbsp;&nbsp;&nbsp;&nbsp;...<br />
&nbsp;&nbsp;&nbsp;&nbsp;public void doFilter(ServletRequest request, ServletResponse response,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FilterChain chain) throws IOException, ServletException {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpServletRequest httpReq = (HttpServletRequest) request;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Get the requested URI<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String uri = httpReq.getRequestURI();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Check if the URI matches mapping creteria.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boolean matches = uri.matches(&quot;.*/[\\w]+&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(matches){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ServletContext context = filterConfig.getServletContext();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Strip context path from the requested URI<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String path = context.getContextPath();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (uri.startsWith(path)){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;uri = uri.substring(path.length());<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Check if there is actually a file to handle the forward.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;URL url = context.getResource(uri+&quot;.jsp&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(url != null){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Generate the forward URI<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String forwardURI = uri + facesExtension;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Get the request dispatcher<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RequestDispatcher rd =<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;context.getRequestDispatcher(forwardURI);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(rd != null){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Forward the request to FacesServlet<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rd.forward(request, response);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// We are not interested for this request, pass it to the FilterChain.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chain.doFilter(request, response);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (ServletException sx) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filterConfig.getServletContext().log(sx.getMessage());<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (IOException iox) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filterConfig.getServletContext().log(iox.getMessage());<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;...<br />
}</code></p>
<p>This filter works just fine and can be used to map extension-less requests to any Servlet. In other words, you can use it to <em>map requests for plain JSP pages also</em>. But when it comes to JSF, there&#8217;s a problem: JSF will write action URLs to the forms according to the <em>servlet-mapping</em> parameter that you have set in your <em>web.xml</em> configuration file. So, even if you request using the extension-less URL, after submitting the form your web browser&#8217;s bar will have the original location (the one with the extension) -and that&#8217;s not nice. After making a huge research this time, struggling for hours to find something in javadocs and in search engines, I&#8217;ve managed to find the class responsible for the creation of the action URL. It&#8217;s name is <strong><em>ViewHandler</em></strong> and the method is <em>getActionURL()</em>. I&#8217;ve also found that you can easily make a custom <em>ViewHandler</em> that sits on top of the one the framework is using and change only part of it&#8217;s functionality.</p>
<p>All you have to do is to create a class that extends <strong><em>javax.faces.application.ViewHandler</em></strong> and specify a constructor that takes a parameter of the same type as an argument. Then you declare it in <em>faces-config.xml</em> like this:</p>
<p><code>&lt;application&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;view-handler&gt;gr.xfrag.faces.mapping.MappingViewHandler&lt;/view-handler&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&lt;/application&gt;</code></p>
<p>The JSF framework will find your declaration, and will call your implementation&#8217;s constructor, passing it the default <em>ViewHandler</em> used by the implementation you&#8217;re using(if you use JSF-RI it will pass <em>com.sun.faces.application.ViewHandlerImpl</em>). You can use this class to delegate every method you don&#8217;t want to customize from your custom ViewHandler to the default one. Using this technique, I&#8217;ve been able to strip the extension from the action URLs like this:</p>
<p><code>public class MappingViewHandler extends ViewHandler{ <br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;/**<br />
&nbsp;&nbsp;&nbsp;&nbsp; * The original handler we are customizing.<br />
&nbsp;&nbsp;&nbsp;&nbsp; */<br />
&nbsp;&nbsp;&nbsp;&nbsp;private ViewHandler prevHandler = null;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;/** Creates a new instance of MappingViewHandler. By including<br />
&nbsp;&nbsp;&nbsp;&nbsp; * a parameter of the same type, we encourage the JSF framework<br />
&nbsp;&nbsp;&nbsp;&nbsp; * to pass a reference of the previously used ViewHandler. This way<br />
&nbsp;&nbsp;&nbsp;&nbsp; * we can use all the previous functionallity and override only the<br />
&nbsp;&nbsp;&nbsp;&nbsp; * method we are interested in (in this case, the getActionURL() method).<br />
&nbsp;&nbsp;&nbsp;&nbsp; */<br />
&nbsp;&nbsp;&nbsp;&nbsp;public MappingViewHandler(ViewHandler prevHandler) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.prevHandler = prevHandler;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;/**<br />
&nbsp;&nbsp;&nbsp;&nbsp; * Delegate control to the original ViewHandler<br />
&nbsp;&nbsp;&nbsp;&nbsp; */<br />
&nbsp;&nbsp;&nbsp;&nbsp;public Locale calculateLocale(FacesContext context) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return prevHandler.calculateLocale(context);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;...<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;/**<br />
&nbsp;&nbsp;&nbsp;&nbsp; * This is the only method needed to be extended. First, we get the<br />
&nbsp;&nbsp;&nbsp;&nbsp; * normal URL form the original ViewHandler. Then we simply return<br />
&nbsp;&nbsp;&nbsp;&nbsp; * the same URL with the extension stripped of.<br />
&nbsp;&nbsp;&nbsp;&nbsp; */<br />
&nbsp;&nbsp;&nbsp;&nbsp;public String getActionURL(FacesContext context, String viewId) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String origURL = prevHandler.getActionURL(context, viewId);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int dotIdx = origURL.lastIndexOf(&quot;.&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (dotIdx &gt; 0) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return origURL.substring(0,dotIdx);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else return origURL;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;...<br />
}</code></p>
<p>This way you can have flawless extension-less mapping for JavaServer Faces. If you want to disable requests for URLs having an extension completely (they will still work even if you use my classes), you can add a few more lines of code to the <em>MappingFilter</em>.</p>
<p>To get the complete source code, use the following links:</p>
<ul>
<li><a href='http://javawords.com/wp-content/uploads/2007/10/mappingfilter.java' title='MappingFilter'>MappingFilter</a></li>
<li><a href='http://javawords.com/wp-content/uploads/2007/10/mappingviewhandler.java' title='MappingViewHandler'>MappingViewHandler</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://javawords.com/2007/10/02/mapping-facesservlet-to-urls-without-extensions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

