<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3099445132231892645</id><updated>2012-02-16T07:35:26.812-08:00</updated><category term='scala jsf myfaces'/><category term='scala jsf myfaces java codi'/><title type='text'>Werners  Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-6115325361208290981</id><published>2011-11-25T05:09:00.000-08:00</published><updated>2011-11-25T05:21:14.297-08:00</updated><title type='text'>JSF Ajax and Multiple Forms</title><content type='html'>This blogpost is about a problem which about 80% of all user problems regarding JSF Ajax in the myfaces mailinglist revolve around. Namely how do I handle the jsf ajax in a multiple form scenario.&lt;br /&gt;&lt;br /&gt;JSF Ajax and multiple forms, a standard case, which should be easy right.&lt;br /&gt;Let's have a small look at an example:&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1393406.js?file=multiform.xhtml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;As we see here, two forms each updating a component in itself via ajax.&lt;br /&gt;Now what happens if we submit the forms alternating. &lt;br /&gt;&lt;br /&gt;After a while we run into a ViewRoot cannot be found Exception on the server side. &lt;br /&gt;&lt;br /&gt;We did everything right, why do we face this issue?&lt;br /&gt;&lt;br /&gt;The answer lies in a bug in the JSF Ajax protocol, more precisely the way the ViewState is processed.&lt;br /&gt;&lt;br /&gt;Lets have a look at an Ajax response:&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1393419.js?file=response.xml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Here we see the root cause of the problem. There is a parameter defining the ViewState with the identifier javax.faces.ViewState, however it is not clear where it belongs to.&lt;br /&gt;&lt;br /&gt;Practically a viewstate must be attached to a form. So the issuing form definitely must receive it. However what about the other forms? &lt;br /&gt;&lt;br /&gt;And here is the root cause of the error. Only the issuing form is updated and the ViewState which is dependend on the viewroot not the form in the second form is not updated.&lt;br /&gt;&lt;br /&gt;This image shows exactly what happens:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-OIx_jgoPa-s/Ts-Ogtq6vhI/AAAAAAAABaU/8kd6GggjOAo/s1600/ViewStateSingleRequest.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-OIx_jgoPa-s/Ts-Ogtq6vhI/AAAAAAAABaU/8kd6GggjOAo/s1600/ViewStateSingleRequest.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;As you can see only one form is update the second form now has a viewstate which is not the current one and at one point is dropped from the ViewState history, a classical concurrency issue.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;So the solution would be to update all forms in the html document, right?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Theoretically yes, but there is one API which prevents this simple solution. Portlets.&lt;br /&gt;In a portlet environment you have multiple viewroots all belonging to different jsf session instances on the server&lt;b&gt;.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;The next logic solution would be to update all jsf elements under ViewRoot.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Again, a good idea, but the protocol prevents it. On the pure client side we do not have any marker or indicator, which tells the ajax code where the current ViewRoot begins.&lt;br /&gt;&lt;br /&gt;To ease this protocol problem an extension to the jsf spec was added under 2.1 which eases this problem. According to the spec you have to add the second form manually as render target. Something which both implementations follow. Here is a snippet which shows the solution:&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1393466.js?file=multiform2.xhtml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Here we can see, we have added the second form as render target.&lt;br /&gt;&lt;br /&gt;Now both forms will be updated and the viewstate always will be up to date.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This solution while being spec compliant is not satisfactory. Sometimes you dont know if a certain form is still present after the ajax case. Is there still a way to update all forms in the page or at least to take the form id out of the equation?&lt;br /&gt;&lt;br /&gt;Unfortunately not within the bounds of the specification. However, being aware of this issue, I have added in Apache MyFaces additionally to the spec behavior two other ways to resolve the issue.&lt;br /&gt;&lt;br /&gt;First, you don't have to define the form as render target, but you can define any element within a form as render target and the form will be updated.&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1393481.js?file=rendertargets.xhtml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Secondly, the probably best solution. A configuration parameter which forces MyFaces to update all forms in a page. &lt;br /&gt;&lt;br /&gt;With following code snippet you can enable this mechanism:&lt;br /&gt;&lt;script src="https://gist.github.com/1393476.js?file=noportlet.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Once you have added this snippet of javascript, myfaces will be in no portlet mode and will enforce an update all forms with the viewstates policy.&lt;br /&gt;&lt;br /&gt;Note: While this method wont break the code if you switch to mojarra, you will not get the benefits, because Mojarra does not yet have a similar solution to the issue.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-6115325361208290981?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/6115325361208290981/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/11/jsf-ajax-and-multiple-forms.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/6115325361208290981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/6115325361208290981'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/11/jsf-ajax-and-multiple-forms.html' title='JSF Ajax and Multiple Forms'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-OIx_jgoPa-s/Ts-Ogtq6vhI/AAAAAAAABaU/8kd6GggjOAo/s72-c/ViewStateSingleRequest.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-8096699545834151973</id><published>2011-11-24T02:05:00.000-08:00</published><updated>2011-11-24T06:23:44.961-08:00</updated><title type='text'>JSF Ajax Encoding</title><content type='html'>The entire story started when we got the request to encode everything in ISO-8859-51 including the ajax cycle. Well first I thought it was easy just change the encoding on the javascript side, let the server handle the rest. The encoding was easily detectable on the javascript side simply by checking the xhtmls encoding (the meta tag head encoding itself would have been another option, but since we are nailed down to xhtml anyway due to facelets we have an easier way)&lt;br /&gt;Easy, I thought, but then I ran into browser hell.&lt;br /&gt;&lt;br /&gt;The problem normally would be easily resolvable. The XHR object has the option of adding&lt;br /&gt;xhr header content type:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;xhr.setRequestHeader("ContentType", "application/x-www-form-urlencoded; charset=ISO-8859-15");&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;The problem now are the browsers themselves. By testing the dynamic encoding on various browsers following came out:&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;thead style="background-color: #e6e6e6;"&gt;&lt;tr&gt;  &lt;td&gt;&lt;b&gt;&lt;i&gt;Browser&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;i&gt;Actual Encoding&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;/thead&gt;  &lt;tbody&gt;&lt;tr&gt;  &lt;td&gt;&lt;i&gt;Mozilla 7&lt;/i&gt;&lt;/td&gt;&lt;td&gt;&lt;i&gt;UTF-8&lt;/i&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;&lt;i&gt;Chrome &lt;/i&gt;&lt;/td&gt;&lt;td&gt;&lt;i&gt;UTF-8&lt;/i&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;&lt;i&gt;IE &lt;/i&gt;&lt;/td&gt;&lt;td&gt;&lt;i&gt;ISO-8859-15&lt;/i&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;&lt;i&gt;Opera &lt;/i&gt;&lt;/td&gt;&lt;td&gt;&lt;i&gt;ISO-8859-15&lt;/i&gt;&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;  &lt;/table&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;So what does this mean, only opera and IE got it right. Which means the path of allowing non UTF-8 submits is blocked for now.&lt;br /&gt;&lt;br /&gt;However JSF automatically deals with the problem properly. While I implemented the most of the Ajax part of myfaces, I have to admit the actual encoding part was provided by another project, namely j4fry and its implementors worked on that part, so I never gave a second thought. However both implementations deal the same way with the issue.&lt;br /&gt;&lt;br /&gt;First ajax submits are UTF-8 encoded, this at the first look could pose problems with non UTF pages. It turns out there are none.&lt;br /&gt;&lt;br /&gt;The solution both implementations follow is to encode the actual key value pair parameters into a utf url encoded representation.&lt;br /&gt;&lt;br /&gt;Both implementations seem to apply the encodeURIComponent function of javascript-&lt;br /&gt;Now now matter what content type the page has, always a proper utf-8 representation of the original content will be passed down.&lt;br /&gt;&lt;br /&gt;Given the response type also then is UTF-8 what happens with the response. After all the page needs to handle the response properly in its own encoding.&lt;br /&gt;Well there MyFaces and Mojarra differ slightly. Both in compliance with the spec, encode the response in a XML CDATA block. However MyFaces does additional escaping of non ascii chars with their unicode representation, while Mojarra simply pushes the content byte per byte into the CDATA block.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is an example:&lt;br /&gt;&lt;br /&gt;Mojarra:&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1390972.js?file=mojarra_response.xml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Here it is clearly visible that the cdata block has a different encoding than the outer UTF-8 encoded xml. In the final page representation all the special chars are visible again as they should be.&lt;br /&gt;&lt;br /&gt;However MyFaces goes one step further and escapes the content additionally to get rid of the non utf-8 representation of the characters.&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1390987.js?file=myfaces_response.xml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;However this comes from the fact that myfaces basically also does an escape of special chars at a full page refresh, so the core behavior regarding the partial response is the same.&lt;br /&gt;&lt;br /&gt;So what happens for instance if you just tamper with the UTF header.&lt;br /&gt;You automatically will run into problems due to the uri encoded UTF-8 representation of the parameters. In the worst case you will trigger a server error because of non decodable parameters, in the best case if you pass down ascii only chars you will get it through, in the normal case you will get junk in which is wrongly decoded.&lt;br /&gt;&lt;br /&gt;See here an example on IE9 and Mojarra:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-_G6Iia1KQGw/Ts4cyvfWN_I/AAAAAAAABaI/SSyGFLq1Sms/s1600/Before_After.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-_G6Iia1KQGw/Ts4cyvfWN_I/AAAAAAAABaI/SSyGFLq1Sms/s1600/Before_After.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The question remains, are both save from a client point of view? Theoretically it should be since everything is embedded in a CDATA block.&lt;br /&gt;However I cannot say if the browsers swallow really everything within their browser engines which is embedded in a CDATA block (aka every byte combination outside of their encoding).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;It comes down again to the golden rule #1 in web programming, use UFT-8 and never bother with other encodings, if you can. If you have to, be prepared to enter the valley of tears, after all UTF-8 now has been for almost a decade the fix for all the encoding issues in the web space. &lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-8096699545834151973?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/8096699545834151973/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/11/jsf-ajax-encoding.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/8096699545834151973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/8096699545834151973'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/11/jsf-ajax-encoding.html' title='JSF Ajax Encoding'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-_G6Iia1KQGw/Ts4cyvfWN_I/AAAAAAAABaI/SSyGFLq1Sms/s72-c/Before_After.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-1500861523573046477</id><published>2011-11-08T07:34:00.000-08:00</published><updated>2011-11-08T07:44:23.907-08:00</updated><title type='text'>Introducing the MyFaces jsf.js Modular Includes</title><content type='html'>&lt;span style="font-size: large;"&gt;Introduction:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Why modular jsf.js includes, there is one &lt;i&gt;jsf.js&lt;/i&gt; file, right?&lt;br /&gt;&lt;br /&gt;Since the beginning of the introduction of &lt;i&gt;jsf.js&lt;/i&gt; in JSF there has been only one &lt;i&gt;jsf.js&lt;/i&gt; file which serves all &lt;i&gt;Ajax&lt;/i&gt; needs.&lt;br /&gt;However, at least for &lt;i&gt;Apache MyFaces&lt;/i&gt; there have been a lot of extensions added such as:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;iframe ajax fileupload&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;html5 form detection&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;client side i18n message support for various languages (including chinese)&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;legacy browser support down to blackberry 4.7 and winmobile 6.5 and ie6&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;browser optimisations for browsers supporting dom level3&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;queue control for the ajax request queue&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;timeout handling&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;better error handling&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;delay handling&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;modular structure which can be changed at runtime to replace it with your own&amp;nbsp; implementation of subparts&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;clear distinction between api and impl on codelevel&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;(More info on many of those extended features see following &lt;a href="http://werpublogs.blogspot.com/2011/07/apache-myfaces-jsfjs-queue-control.html"&gt;Link&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;Most of those extensions will make it one way or the other into the official &lt;i&gt;jsf&lt;/i&gt; spec. However different scenarii have different needs.&lt;br /&gt;While most legacy mobile browsers are now slowly phased out (and is seen as deprecated) ie6 for the time being is still supported with a burden of legacy code.&lt;br /&gt;However in a pure modern mobile environment for instance you need smaller files and no legacy code at all. Many users are also perfectly happy with a pure implementation of &lt;i&gt;jsf.js&lt;/i&gt; according to the spec without any extra features. Other users only need a subset of those features and want to leave out the other (i18n support for instance)&lt;br /&gt;&lt;br /&gt;The advantage of dropping code is smaller filesizes, faster code due to less lines which have to be processed and less fallbacks which have to be prechecked. Something worthwhile to explore given modern mobile browser environments and situations where you simply want to be as lean as possible.&lt;br /&gt;&lt;br /&gt;So what is the solution for all this&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;The MyFaces jsf.js Modular Includes&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As of &lt;i&gt;MyFaces&lt;/i&gt; &lt;i&gt;2.1.4&lt;/i&gt; a modular include system will be added. Simply by adding following parameter to your web.xml you will be able to determine what will be included&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1347917.js?file=include_param.xml"&gt;&lt;/script&gt;&lt;br /&gt;With the parameter &lt;br /&gt;&lt;br /&gt;&lt;b&gt;org.apache.myfaces.JSF_JS_MODE&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;and the allowed values of&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;normal&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt; modern&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;minimal-modern&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;you will be able to adjust which version of jsf.js is included. If you need extra functionality you can include the subparts excluded from your version as separate Javascript resources via normal jsf mechanisms.&lt;br /&gt;&lt;br /&gt;Following image shows the version of each file and the extra functionality:&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-zB_qMgvL7Ks/TrlInFmpnNI/AAAAAAAABZ0/jzDgNoJUnhw/s1600/modular-builds.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="400" src="http://1.bp.blogspot.com/-zB_qMgvL7Ks/TrlInFmpnNI/AAAAAAAABZ0/jzDgNoJUnhw/s400/modular-builds.jpg" width="335" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Modular include parts&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;As you you can see you can stack and mix all the modules you need by simply choosing a base jsf.js and then you are able to stack the extra functionality needed by adding a separate include.&lt;br /&gt;&lt;br /&gt;That way you have the choice between filesize, number of includes and features according to your needs. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Example on how to Enable the Modular Includes with Additional Features&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The following example will include the minimal-modern jsf.js and will stack all the extra functionality on top of it.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;web.xml&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1348030.js?file=web.xml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;in your page template&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1348038.js?file=includes.xhtml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;As you can see all you need to to is to reference the correct js file additionally which is hosted under the resource module myfaces and you are ready to go.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-1500861523573046477?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/1500861523573046477/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/11/introducing-myfaces-jsfjs-modular.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/1500861523573046477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/1500861523573046477'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/11/introducing-myfaces-jsfjs-modular.html' title='Introducing the MyFaces jsf.js Modular Includes'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-zB_qMgvL7Ks/TrlInFmpnNI/AAAAAAAABZ0/jzDgNoJUnhw/s72-c/modular-builds.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-1098529942319710527</id><published>2011-10-14T02:08:00.000-07:00</published><updated>2011-10-14T02:20:05.997-07:00</updated><title type='text'>Mojarra vs. MyFaces performance</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: large;"&gt;Hello and welcome.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since Andy Schwarz posted &lt;a href="https://oracleus.wingateweb.com/published/oracleus2011/sessions/24122/S24122_234496.pdf"&gt;following link&lt;/a&gt; in the MyFaces mailing list, with especially &lt;i&gt;page #73&lt;/i&gt; showing MyFaces in a relatively bad light compared to Mojarra without any further data given, I have become curious where we really stand. I could not believe the diagram shown here, because it did not resemble my personal day to day experience (the entire numbers shown also the html size etc..) seemed like a rather old build of MyFaces probably around 2.0.2-2.0.4.&lt;br /&gt;&lt;br /&gt;My personal assumption was that the implementation used was a rather old MyFaces version.&lt;br /&gt;We have made major performance improvements between 2.0.4 and the current snapshot version which is 2.1.4-SNAPSHOT and 2.0.10-SNAPSHOT and Mojarra on version 2.1.2.&lt;br /&gt;&lt;br /&gt;So here is my test setup. I basically took an &lt;a href="http://code.google.com/a/apache-extras.org/p/myfaces-js-integrationtests/"&gt;existing integration test suite&lt;/a&gt; I have had developed the last month and added client side timestamp performance measurements.&lt;br /&gt;By comparing the succeeded tests on both platforms under identical conditions you can get a good overview over the client side and server side performance numbers of both implementations.&lt;br /&gt;&lt;br /&gt;Both tests were run in Production mode which resembles  a live system under the same setup, with all optimisations on, a Maven Jetty configuration was used as servlet runner. Test browser was the latest Mozilla Firefox, but on other browsers the results are pretty similar.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;So here are the numbers:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt; &lt;td&gt;Testcase&lt;/td&gt;&lt;td&gt;MyFaces (ms)&lt;/td&gt;&lt;td&gt;Mojarra&lt;/td&gt; &lt;/tr&gt;&lt;/thead&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt;1. JSF Protocol Tests&lt;/td&gt;&lt;td&gt;239 &lt;/td&gt;&lt;td&gt;207 &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;2. Full Body Replacement &lt;/td&gt;&lt;td&gt;42 &lt;/td&gt;&lt;td&gt;35 &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;3. Multi form situation &lt;/td&gt;&lt;td&gt;4134  &lt;/td&gt;&lt;td&gt;4426  &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;4. Testing for decorated api calls  &lt;/td&gt;&lt;td&gt;24  &lt;/td&gt;&lt;td&gt;34  &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;5. Double Eval Detection  &lt;/td&gt;&lt;td&gt;2047   &lt;/td&gt;&lt;td&gt;2060   &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;6. Table Test, replacement of table elements   &lt;/td&gt;&lt;td&gt;7289    &lt;/td&gt;&lt;td&gt;9229    &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;6. Partial Page Rendering Nav Case    &lt;/td&gt;&lt;td&gt;2168     &lt;/td&gt;&lt;td&gt;2308     &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;7. Event Lifecycle test  &lt;/td&gt;&lt;td&gt;130      &lt;/td&gt;&lt;td&gt;131      &lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt; &lt;/table&gt;&lt;br /&gt;&lt;br /&gt;Tests 1 and 2 are pure servlet based tests so they give a good indication about the javascript performance differences, which are roughly in a 10% margin. (with MyFaces being somewhat slower, but that is understandable given the extra functionality provided and the testing framework influencing slightly the performance of myfaces but not Mojarra (an issue already fixed))&lt;br /&gt;&lt;br /&gt;The rest of the tests are slightly ahead of Mojarra, so the server seems to be under the same test setup conditions slightly ahead of Mojarra, here also in a 10-15% range.&lt;br /&gt;&lt;br /&gt;On the page rendering side however the generated code from Mojarra seemed to be about 5-10% smaller than MyFaces´s code. The difference used to be much bigger but some improvements have been made in this area as well on our side.&lt;br /&gt;&lt;br /&gt;To sum this up, performancewise you definitely cannot go wrong with any of both implementations.&lt;br /&gt;And none of both implementations has a significant performance advantage over the other.&lt;br /&gt;&lt;br /&gt;But back to the original article. &lt;br /&gt;&lt;br /&gt;I really would like which version the authors used to come to their conclusion on page #73 and how it would look like with the latest codebase.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-1098529942319710527?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/1098529942319710527/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/10/mojarra-vs-myfaces-performance.html#comment-form' title='3 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/1098529942319710527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/1098529942319710527'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/10/mojarra-vs-myfaces-performance.html' title='Mojarra vs. MyFaces performance'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-8124915719231629782</id><published>2011-07-14T03:27:00.000-07:00</published><updated>2011-07-15T01:47:36.861-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scala jsf myfaces java codi'/><title type='text'>Marrying JSF with Scala - Part2</title><content type='html'>&lt;h2&gt;View Controllers and Navigation &lt;/h2&gt;While &lt;a href="http://werpublogs.blogspot.com/2011/07/marrying-jsf-with-scala-part1.html"&gt;part1&lt;/a&gt; showed us how we can do managed beans in &lt;i&gt;Javascript&lt;/i&gt;, we now will go a little bit deeper. In this part we will talk about view controllers and navigation implemented in &lt;i&gt;Scala&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Short Introduction to ViewControllers&lt;/h3&gt;While &lt;i&gt;JSF&lt;/i&gt; does not know the ViewController pattern, for JSF is everything a managed bean, it makes sense to name a certain set of managed beans ViewControllers.&lt;br /&gt;Per definition in &lt;i&gt;JSF&lt;/i&gt; a &lt;i&gt;ViewController&lt;/i&gt; is a managed bean, which deals directly with the user interface interaction from the backend.&lt;br /&gt;&lt;br /&gt;Such interactions are&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Actions&lt;/li&gt;&lt;li&gt;Events&lt;/li&gt;&lt;li&gt;Listeners&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;etc...&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;A typical plain Java Viewcontroller&lt;/h3&gt;So a typical Java ViewController in a plain &lt;i&gt;JSF&lt;/i&gt; environment looks like following.&lt;br /&gt;&lt;script src="https://gist.github.com/1082171.js?file=TestViewController.java"&gt;&lt;/script&gt;  Everyone who has programmed &lt;i&gt;JSF&lt;/i&gt; is familiar with those patterns.&lt;br /&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;i&gt;Sidenote: there are frameworks which add  dedicated view controllers with dedicated callbacks for postCreate, preRender&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;      &lt;br /&gt;&lt;h3&gt;ViewController in &lt;i&gt;Scala&lt;/i&gt;&lt;/h3&gt;The question now is, how does this look in &lt;i&gt;Scala&lt;/i&gt;. &lt;script src="https://gist.github.com/1082181.js?file=TestViewController.scala"&gt;&lt;/script&gt;  Again, this code is somewhat smaller thanks to the absence of setters and getters. However the structure of this class is not 1:1 translatable to Java due to following new construct: &lt;script src="https://gist.github.com/1082186.js?file=ViewControllerSingleton.scala"&gt;&lt;/script&gt;  &lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;So what is this &lt;i&gt;object&lt;/i&gt; all about?&lt;/b&gt;&lt;br /&gt;Scala does neither know static classes nor variables, instead it has singletons in its language core as companion pattern to classes.  If a construct is defined via &lt;i&gt;object&lt;/i&gt; instead of &lt;i&gt;class&lt;/i&gt;, then the resulting object is a singleton.  To make the code tighter, &lt;i&gt;Scala&lt;/i&gt; also allows imports everywhere. Members of singletons can be imported simply by import &lt;b&gt;&amp;lt;Singleton&amp;gt;._&lt;/b&gt; so that we can call them directly in our code.&lt;br /&gt;If you notice in our action callbacks we return the members of the singleton directly, like we would do it with static variables in &lt;i&gt;Java&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;i&gt;&lt;a href="http://myfaces.apache.org/extensions/cdi/index.html"&gt;MyFaces Codi&lt;/a&gt; &lt;/i&gt;Typesave Navigation&lt;/h3&gt;&lt;i&gt;&lt;a href="http://myfaces.apache.org/extensions/cdi/index.html"&gt;MyFaces Codi&lt;/a&gt;&lt;/i&gt; has an interesting feature, the so called typesave implicit navigation.&lt;br /&gt;&lt;br /&gt;While &lt;i&gt;JSF2&lt;/i&gt; already eased the lives of developers by introducing an implicit navigation (aka return value of an action == page name if no navigation rule is given), &lt;i&gt;MyFaces Codi&lt;/i&gt; goes one step further.&lt;br /&gt;It maps pages to classes (page name must be the class name) and it allows the grouping of navigation elements in wrapper classes (follow this &lt;a href="https://cwiki.apache.org/confluence/display/EXTCDI/Documentation"&gt;link&lt;/a&gt; for further reference).&lt;br /&gt;&lt;br /&gt;While in my personal opinion, the class based navigation alone, it really shines once you add advanced codi features to it like the security handling or the View Controller extensions.&lt;br /&gt;&lt;i&gt;(For more Information please consult the &lt;a href="http://myfaces.apache.org/extensions/cdi/index.html"&gt;MyFaces Codi documentation&lt;/a&gt;)&amp;nbsp;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Here is a small example:   &lt;script src="https://gist.github.com/1082215.js?file=gistfile1.txt"&gt;&lt;/script&gt;   This is a very basic example of two navigation cases     &lt;br /&gt;&lt;ul&gt;&lt;li&gt; the first one points to /Wizard/Page1 &lt;/li&gt;&lt;li&gt; the second one points to /Wizard/Page2 &lt;/li&gt;&lt;/ul&gt;However to map this to scala we face a set of problems   &lt;br /&gt;&lt;ol&gt;&lt;li&gt;We don't have interfaces, we have mixins, but they do not map straight to the structures we need &lt;/li&gt;&lt;li&gt;the interface classes are the same problem as the interfaces &lt;/li&gt;&lt;/ol&gt;So we have to find structures which Codi can follow but are buildable in Scala.  Here we have the same example in Scala: &lt;script src="https://gist.github.com/1082219.js?file=Wizard.scala"&gt;&lt;/script&gt;  Again we are able to map everything into singletons so we work with a set of objects instead of interfaces and interface classes.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;That sums up part2 for now&lt;/h3&gt;&lt;br /&gt;Next week, I will talk about how to leverage Scalas very powerful trait feature to isolate common behavior.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-8124915719231629782?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/8124915719231629782/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/07/marrying-jsf-with-scala-part2.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/8124915719231629782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/8124915719231629782'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/07/marrying-jsf-with-scala-part2.html' title='Marrying JSF with Scala - Part2'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-8450057956471272476</id><published>2011-07-08T01:18:00.000-07:00</published><updated>2011-07-08T05:58:52.119-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scala jsf myfaces'/><title type='text'>Marrying JSF with Scala - Part1</title><content type='html'>&amp;nbsp;This is the first part of a mulitpart blogpost on how to marry JSF with Scala.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Why Scala? Java is fine&lt;/h2&gt;&lt;br /&gt;My personal opinion is, having done programs in many languages, that Scala is a huge step up from Java complexity-wise and many things are corner case fillers which probably could have been left out with a more lenient approach. &lt;br /&gt;Nevertheless Scala has lots of merits as well.&lt;br /&gt;&lt;br /&gt;The code reduction compared to Java on the average is 30-50% less thanks to better property handling and other things like closures. &lt;br /&gt;The speed if touched right is about the same as Java (one of the complaints about groovy).&lt;br /&gt;However, if you want to apply Scala you seriously have to touch it the way you would touch C++, make up your mind on what part of the language you really use and only touch others in rare cases. &lt;br /&gt;&lt;br /&gt;But lets stop the criticism here. Scala has lots of merits especially for JSF:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Absence of setters and getters&lt;/li&gt;&lt;li&gt;Tight integration with Java&lt;/li&gt;&lt;li&gt;Isolation of common constraints via Mixins instead of base classes&lt;/li&gt;&lt;li&gt;Same or almost the same performance as java&lt;/li&gt;&lt;li&gt;Closures for things like iteration&lt;/li&gt;&lt;li&gt;etc...&lt;/li&gt;&lt;/ul&gt;So lets dig into JSF and Scala&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Part 1, Managed Beans&lt;/h2&gt;The possible easiest entry into combining Scala and JSF is to create a managed bean. Every managed bean in JSF is a pojo with a handful of setters and getters. (and more depending on your functionality)&lt;br /&gt;It probably is the easiest artifact within the JSF stack you can get.&lt;br /&gt;&lt;br /&gt;Let us have a look at a simple Java managed bean:&lt;br /&gt;&lt;script src="https://gist.github.com/1071307.js?file=gistfile1.java"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;The same now would be coded in Scala&lt;br /&gt;&lt;script src="https://gist.github.com/1071316.js?file=TestBean.scala"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Note for the people who are familiar with Scala, we took two assumptions here, first we are using for familiarity &lt;br /&gt;reasons the Java mutable LinkedList and secondly we use BeanProperties &lt;br /&gt;(we could resolve that with our own el resolver as well)&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;This is tightlier written, but what about data encapsulation what about setters and getters? &lt;br /&gt;Scala follows a different route for data encapsulation. You can set properties but usually the data is public until you have overrides which cause the data encapsulation without any further code interference.&lt;br /&gt;&lt;br /&gt;Also one thing noticeable is, that the &lt;i&gt;implements Serializable&lt;/i&gt; has been replaced by a &lt;i&gt;@serializable&lt;/i&gt; annotation. The rest of the annotations is applied as is.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;So what about this @BeanProperty?&lt;/h3&gt;This is a special Scala annotation which tells the compiler to &lt;i&gt;encapsulate&lt;/i&gt; the property and generate &lt;i&gt;setters&lt;/i&gt; and &lt;i&gt;getters&lt;/i&gt; for it. &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;I want to use CDI instead of ManagedBeans&lt;/h2&gt;CDI has been the new kid on the block and given that bigger projects nowadays either use Spring or CDI it makes sense to cover the CDI integration here as well.&lt;br /&gt;To sum the CDI and Scala situation regarding managed beans, it is as seamless as it is with pure managed beans.&lt;br /&gt;&lt;br /&gt;Here is an example:&lt;br /&gt;&lt;script src="https://gist.github.com/1071331.js?file=TestBean.scala"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Of course you still can use &lt;i&gt;@Inject&lt;/i&gt; and other CDI constructs as well. &lt;br /&gt;&lt;br /&gt;&lt;h3&gt;@BeanProperties is this really needed?&lt;/h3&gt;As you have seen @BeanProperties produces the connection between our properties and the EL by encapsulating the property and providing Java like setters and getters.&lt;br /&gt;This is very inelegant, first of all, because to access those properties, you have to use the setters and getters on the Scala side as well, and the code is convoluted with annotations.&lt;br /&gt;&lt;br /&gt;Wouldn't it be nice to simply have something like:&lt;br /&gt;&lt;script src="https://gist.github.com/1071338.js?file=TestBean.scala"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;This works as expected, even the EL will pick up all properties, thanks to Scalas public per default convention. However we now face a problem, once we want to encapsulate for instance &lt;i&gt;val1&lt;/i&gt;. If we now would make it private or protected the code definitely would be broken and the EL would not pick it up anymore. As long as you stay in Scala, you can use Scala properties, however the EL is implemented in Java and expects Java setters and getters.&lt;br /&gt;&lt;br /&gt;So to make the EL scala aware we have to roll out a binding solution, but first, lets talk about Scala properties.&lt;br /&gt;&lt;br /&gt;Scala properties are a different convention. From outside they are invisible by default but they still implement full isolation.&lt;br /&gt;&lt;br /&gt;So, code like&lt;i&gt; myobj.myprop = 1 &lt;/i&gt;still would be&lt;i&gt; myobj.myprop = 1 &lt;/i&gt;after the isolation has been added&lt;i&gt;.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;So how do we do it?&lt;br /&gt;&lt;script src="https://gist.github.com/1071342.js?file=TestBean.scala"&gt;&lt;/script&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;the &lt;i&gt;def val1: Int = _val1&lt;/i&gt; is basically our new getter replacing our old val1 for read access&lt;/li&gt;&lt;li&gt;def &lt;i&gt;val1_$eq (val1: Int)&lt;/i&gt; is basically a convention to open val1 for write access via the = operator.&lt;/li&gt;&lt;/ul&gt;This works within Scala seamlessly and for &lt;i&gt;orm&lt;/i&gt; frameworks as well as long as they know the Scala convention (most do by now via plugins). But on the Java side you have to call those methods directly via &amp;lt;methodName&amp;gt; and &amp;lt;methodName&amp;gt;_eq.&lt;br /&gt;The last remaining open problem is the Expression Language. The EL relies on setters and getters for accessing the properties.&lt;br /&gt;&lt;br /&gt;Thankfully there is a way to override the ELs handling via a custom resolver tailored for Scala. Now this code would override the scope of this blog, but you can download the sources for this EL resolver &lt;a href="http://people.apache.org/%7Ewerpu/scala/scalaelresolver.zip"&gt;here&lt;/a&gt;:&lt;br /&gt;(note a link to an el resolver drop in project will be added later this month so check regularly)&lt;br /&gt;&lt;br /&gt;You just have to integrate it into your project by adding following entry into your faces-config:&lt;br /&gt;&lt;script src="https://gist.github.com/1071346.js?file=elresolverentry.xml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;End of Part1&lt;/h2&gt;We now have reached the end of part1. The next part will be about the ViewController patterns. Page navigation Codi style in Scala, and what we can do with Scala traits in a JSF context. So stay tuned.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-8450057956471272476?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/8450057956471272476/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/07/marrying-jsf-with-scala-part1.html#comment-form' title='2 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/8450057956471272476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/8450057956471272476'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/07/marrying-jsf-with-scala-part1.html' title='Marrying JSF with Scala - Part1'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-2023392024165873982</id><published>2011-07-07T03:56:00.000-07:00</published><updated>2011-07-07T04:06:50.813-07:00</updated><title type='text'>Extensive German JSF Tutorial</title><content type='html'>If you are in need for an &lt;i&gt;extensive JSF Tutorial&lt;/i&gt; and you can speak or read &lt;i&gt;german&lt;/i&gt;, than head over to following &lt;a href="http://jsfatwork.irian.at"&gt;site http://jsfatwork.irian.at&lt;/a&gt;. This is probably the most comprehensive JSF guide you can get for free currently.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-6oQXXi0e8z8/ThWTCAi7oPI/AAAAAAAABV4/VnY7K6onddo/s1600/jsfsite.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="236" width="320" src="http://3.bp.blogspot.com/-6oQXXi0e8z8/ThWTCAi7oPI/AAAAAAAABV4/VnY7K6onddo/s320/jsfsite.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-2023392024165873982?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/2023392024165873982/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/07/extensive-german-jsf-tutorial.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/2023392024165873982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/2023392024165873982'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/07/extensive-german-jsf-tutorial.html' title='Extensive German JSF Tutorial'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-6oQXXi0e8z8/ThWTCAi7oPI/AAAAAAAABV4/VnY7K6onddo/s72-c/jsfsite.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-2751279893427728524</id><published>2011-07-07T02:22:00.000-07:00</published><updated>2011-07-07T02:22:36.768-07:00</updated><title type='text'>Dynamic data definitions the Groovy way</title><content type='html'>Hello everyone did you have ever had the need to define some data which quickly can be processed? Well there are myriads of ways. There is xml, and you can roll your own parser, you can use property files. But there is another way. You could do it in a dynamic scripting language. &lt;br /&gt;&lt;br /&gt;Well we have Groovy and we could use the Groovy builders as shown &lt;a href="http://groovy.codehaus.org/GroovyMarkup"&gt;here&lt;/a&gt;. The Problem with the builders is that you might lose some realtime syntax checking, some tools already have. I want to talk about a different way to describe data. A combination of properties and closures to keep the syntax lean. Lets have a look at an example.&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1069151.js?file=gistfile1.gradle"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Normally we would have to generate the class and set the properties or we would have to define constructors with property lists. There is another way, we can use closures to set the properties dynamically at object creation&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1069154.js?file=gistfile1.gradle"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;What we do here is to generate a new object and dynamically set helloWorld which has a predefined value of "helloworld" to add. Another way to do the same would be following: &lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1069157.js?file=gistfile1.gradle"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Or like following: &lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1069160.js?file=gistfile1.gradle"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Same result different angle to the approach. What we do here is following we use the internal map semantics groovy uses to store properties to set the value of helloWorld to a new value. In the first example we do it explicitely in the second one via dynamic parameter maps for the constructor. Both cases would result in the same result! Lets have a look on how compact this approach is:&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1069163.js?file=gistfile1.gradle"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Now think how much more code you would have in xml or how much more effort this would be by rolling your own data definition language. The good thing is you can set your properties to predefined defaults and then use the closures to override the values you want to change. The best thing however is you can use all this seamlessly from java. A Java Class simply would have to call the setters and getters of the properties of the generated objects to access those values! The groovy compiler takes care of the rest!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-2751279893427728524?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/2751279893427728524/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/07/dynamic-data-definitions-groovy-way.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/2751279893427728524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/2751279893427728524'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/07/dynamic-data-definitions-groovy-way.html' title='Dynamic data definitions the Groovy way'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-3524557266245073208</id><published>2011-07-07T01:49:00.000-07:00</published><updated>2011-07-07T02:08:16.316-07:00</updated><title type='text'>Apache MyFaces jsf.js queue control</title><content type='html'>&lt;h2&gt;Introduction&lt;/h2&gt;As some people might have noticed our javascripts are bigger than Mojarras. There is a reason for it, besides our internal structures completely different we have a set of extensions which yet have to make it into the official spec (all of it has been donated to the EG)&lt;br /&gt;&lt;br /&gt;I already wrote about the fileupload via ajax, and again, I have to warn, if you use that stuff you are bound to MyFaces.&lt;br /&gt;&lt;br /&gt;But nevertheless, partial page submit and queue control are two important features which have been enabled since 2.0.1: &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Queue Control, what is it?&lt;/h2&gt;The official spec enforces following behavior: if you submit an Ajax post it is either sent directly if no other submit is running or enqueued until the running ajax submit has terminated and then the submit is issued. &lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Now this causes following problems&lt;/h3&gt;&lt;br /&gt;&lt;li&gt;The typical fast typing Ajax input.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Here typing happens on the fly and a load of submits are issued, they are either queued or simply sent to the server causing constant loads. &lt;br /&gt;&lt;br /&gt;&lt;li&gt;The long running Request&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Here a request hangs for a longer period of time, filling the client queue.&lt;br /&gt;&lt;br /&gt;For those two szenarios we introduced (thanks to the j4fryguys Ganesh and Alax who donated the code), advanced queue control.&lt;br /&gt;&lt;br /&gt;Here is the deal on how to use it (and again the obligatory you bind yourself to myfaces warning)&lt;br /&gt;&lt;br /&gt;First a short introduction to our configuration system: We are very modular all layers are bound late via configuration and also vital parts of the system can be replaced without digging into the code internals that way, this configuration system also can be used to override certain default behavior.&lt;br /&gt;Now there are to ways to override the configuration, you can do it globally under the myfaces.config namespace or locally by pushing another additional set of parameters in the options map under myfaces (example below)&lt;br /&gt;&lt;br /&gt;An example for a global configuration for instance is:&lt;br /&gt;&lt;script src="https://gist.github.com/1069101.js?file=gistfile1.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;an example for a local configuration override for a single request is: &lt;br /&gt;&lt;script src="https://gist.github.com/1069104.js?file=gistfile1.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Now we have following possibilities in our codebase:&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;timeout&lt;/b&gt;: describes a value of miliseconds upon the current request should be terminated for good and the next one be issued&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;delay&lt;/b&gt;: describes a delay period where the system waits for the next input before issuing the submitted. If an input is sent before the delay period is over the old request is canceled upfront and the new one is enqueued delayed.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;queuesize&lt;/b&gt;: This limits the queue size of the request queue to the specified number of elements, if the queue is bigger than what is provided older elements are dropped until the queue size is fulfilled. If issued locally the reduction is only done temporarily.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For a typical ajax scenario following might be a viable approach: &lt;br /&gt;&lt;script src="https://gist.github.com/1069106.js?file=gistfile1.html"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Second Part, PPS&lt;/h2&gt;&lt;br /&gt;This solves following scenario, per spec definition the entire form passed down must be submitted at each Ajax scenario. Often this is unnecessary, especially if you only execute parts of the subtree. Unnecessary data is passed down and if you have something like a textfield in the form then it is even heavy on the server.&lt;br /&gt;&lt;br /&gt;There pps helps. With pps you will just pass what is needed to be executed, you also can put the execute on a parent node and it determines which childs have to be passed down the execution chain and it only submits the parameters it really needs to pass down.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;(note this does not work in the ajax fileupload case)&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Here is an example on how to use it:&lt;br /&gt;&lt;script src="https://gist.github.com/1069114.js?file=gistfile1.html"&gt;&lt;/script&gt; &lt;br /&gt;&lt;br /&gt;again this also can be set globally via&lt;br /&gt;&lt;b&gt;myfaces.config.pps = true &lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-3524557266245073208?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/3524557266245073208/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/07/apache-myfaces-jsfjs-queue-control.html#comment-form' title='1 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/3524557266245073208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/3524557266245073208'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/07/apache-myfaces-jsfjs-queue-control.html' title='Apache MyFaces jsf.js queue control'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3099445132231892645.post-6647153504367285180</id><published>2011-07-07T01:28:00.000-07:00</published><updated>2011-07-07T02:55:34.558-07:00</updated><title type='text'>Hello and Welcome</title><content type='html'>&lt;b&gt;Hello and welcome, I have moved my blog now from jroller to Blogspot.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;As first entry I want to show how to roll an testing ssl connector from Maven 3 with the Jetty Maven Plugin:&lt;br /&gt;&lt;br /&gt;Here is the code:&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1069090.js?file=gistfile1.xml"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;As you  can see it comes down to two things, generate a temporary public key for jetty in the build and then use the ssl connectivity in the jetty plugin to open the ssl port with the generated key.&lt;br /&gt;&lt;br /&gt;If you use an older combination, you can use following code as blueprint:&lt;br /&gt;(note the keystore setup stays the same)&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/1069212.js?file=gistfile1.xml"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3099445132231892645-6647153504367285180?l=werpublogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://werpublogs.blogspot.com/feeds/6647153504367285180/comments/default' title='Kommentare zum Post'/><link rel='replies' type='text/html' href='http://werpublogs.blogspot.com/2011/07/hello-and-welcome.html#comment-form' title='0 Kommentare'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/6647153504367285180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3099445132231892645/posts/default/6647153504367285180'/><link rel='alternate' type='text/html' href='http://werpublogs.blogspot.com/2011/07/hello-and-welcome.html' title='Hello and Welcome'/><author><name>werpu</name><uri>http://www.blogger.com/profile/09375134436436666905</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
