<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>richfaces &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/richfaces/</link>
	<description>Feed of posts on WordPress.com tagged "richfaces"</description>
	<pubDate>Thu, 21 Aug 2008 16:38:10 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Masked Input with Richfaces]]></title>
<link>http://ahoehma.wordpress.com/?p=35</link>
<pubDate>Tue, 19 Aug 2008 13:08:21 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/?p=35</guid>
<description><![CDATA[I would like to define a input-mask for a inputfield, e.g. for a telefonnumber or number in scientif]]></description>
<content:encoded><![CDATA[<p>I would like to define a input-mask for a inputfield, e.g. for a telefonnumber or number in scientific notation (1.23 E-10). A nice way could be the usage of a special "css-class" to mark the masked-input-elements and the usage of the alt-attribute to define the mask-format. Here is my solution:</p>
<p>First of all we need a little bit Javascript, i use the <a href="http://jsfromhell.com/forms/masked-input" target="_blank">Masked Input Component from Jonas Raoni Soares Silva</a>:</p>
<p>[sourcecode language='javascript']</p>
<p>addEvent = function(o, e, f, s){<br />
var r = o[r = "_" + (e = "on" + e)] = o[r] &#124;&#124; (o[e] ? [[o[e], o]] : []), a, c, d;<br />
r[r.length] = [f, s &#124;&#124; o], o[e] = function(e){<br />
try{<br />
(e = e &#124;&#124; (window.event ? (arguments = [].slice.call(arguments)).unshift(e = event) &#124;&#124; 1 &#38;amp;amp;amp;amp;amp;amp;amp;amp;&#38;amp;amp;amp;amp;amp;amp;amp;amp; e : {})).preventDefault &#124;&#124; (e.preventDefault = function(){e.returnValue = false;});<br />
e.stopPropagation &#124;&#124; (e.stopPropagation = function(){e.cancelBubble = true;});<br />
e.target &#124;&#124; (e.target = e.srcElement &#124;&#124; null);<br />
e.key = (e.which + 1 &#124;&#124; e.keyCode + 1) - 1 &#124;&#124; 0;<br />
}catch(f){}<br />
for(d = 1, f = r.length; f; r[--f] &#38;amp;amp;amp;amp;amp;amp;amp;amp;&#38;amp;amp;amp;amp;amp;amp;amp;amp; (a = r[f][0], o = r[f][1], a.apply ? c = a.apply(o, arguments) : (o._ = a, c = o._(e), o._ = null), d &#38;amp;amp;amp;amp;amp;amp;amp;amp;= c !== false));<br />
return e = null, !!d;<br />
}<br />
};<br />
removeEvent = function(o, e, f, s){<br />
for(var i = (e = o["_on" + e] &#124;&#124; []).length; i;)<br />
if(e[--i] &#38;amp;amp;amp;amp;amp;amp;amp;amp;&#38;amp;amp;amp;amp;amp;amp;amp;amp; e[i][0] == f &#38;amp;amp;amp;amp;amp;amp;amp;amp;&#38;amp;amp;amp;amp;amp;amp;amp;amp; (s &#124;&#124; o) == e[i][1])<br />
return delete e[i];<br />
return false;<br />
};<br />
MaskInput = function(f, m){<br />
function mask(e){<br />
var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },<br />
rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};<br />
function accept(c, rule){<br />
for(var i = 1, r = rules[rule] &#124;&#124; 0; i &#38;amp;amp;amp;amp;amp;amp;amp;lt;= r; i&#38;amp;amp;amp;amp;amp;amp;amp;lt;&#38;amp;amp;amp;amp;amp;amp;amp;lt;=1)<br />
if(r &#38;amp;amp;amp;amp;amp;amp;amp;amp; i &#38;amp;amp;amp;amp;amp;amp;amp;amp;&#38;amp;amp;amp;amp;amp;amp;amp;amp; patterns[i].test(c))<br />
break;<br />
return i &#38;amp;amp;amp;amp;amp;amp;amp;lt;= r &#124;&#124; c == rule;<br />
}<br />
var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;<br />
(!k &#124;&#124; k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) &#38;amp;amp;amp;amp;amp;amp;amp;amp;&#38;amp;amp;amp;amp;amp;amp;amp;amp; (r[0] = r[2].indexOf(c) + 1) + 1 ?<br />
r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) &#124;&#124; r[0]<br />
: (l = (f.value += m.substr(l, (r = /[A&#124;9&#124;C&#124;\*]/i.exec(m.substr(l))) ?<br />
r.index : l)).length) &#38;amp;amp;amp;amp;amp;amp;amp;lt; m.length &#38;amp;amp;amp;amp;amp;amp;amp;amp;&#38;amp;amp;amp;amp;amp;amp;amp;amp; accept(c, m.charAt(l))) &#124;&#124; e.preventDefault();<br />
};<br />
for(var i in !/^(.)\^(.*)$/.test(m) &#38;amp;amp;amp;amp;amp;amp;amp;amp;&#38;amp;amp;amp;amp;amp;amp;amp;amp; (f.maxLength = m.length), {keypress: 0, keyup: 1})<br />
addEvent(f, i, mask);<br />
};<br />
[/sourcecode]</p>
<p>then we define the inputfield:</p>
<p>[sourcecode language='html']<br />
<h:inputText styleClass="maskedInput" alt="9,99 E-99"/><br />
[/sourcecode]</pre>
<p>and last a little bit JS-Code which decorates the current formulare after each rerender, but it at the end of your page:</p>
<p>[sourcecode language='html']<br />
<a4j:outputPanel ajaxRendered="true"><br />
  <script type="text/javascript">
   var maskedInput=$$(".maskedInput");
   if (Object.isArray(maskedInput)){
     maskedInput.each(function (elm){
     // input-mask is defined in the alt element
     var maskPattern = Element.readAttribute(elm, "alt");
     MaskInput(elm, maskPattern);
     });
   }
  </script><br />
</a4j:outputPanel><br />
[/sourcecode]</pre>
<p>That's it :) Every time A4J rerenders the page the decorator search all marked elements and creates a MaskInput object for the elements.</p>
<p>Try it!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ajax ReRendering - How to reRender part of your page in Myfaces using Richfaces]]></title>
<link>http://roneiv.wordpress.com/?p=31</link>
<pubDate>Thu, 07 Aug 2008 14:04:58 +0000</pubDate>
<dc:creator>roneiv</dc:creator>
<guid>http://roneiv.wordpress.com/?p=31</guid>
<description><![CDATA[If you read this post I assume you have a general knowledge about what Ajax is, and what capabilitie]]></description>
<content:encoded><![CDATA[<p>If you read this post I assume you have a general knowledge about what Ajax is, and what capabilities lies within. As a web-developer, there might be times where you would like to not do a full submit of your page, but you would actually like to just update a small part of the page. An application that achieves this gives the user a more "desktop-application"-like experience, and it will mostly also be a saver when it comes to performance, as you only load a part of the page - as well as the data going to be displayed in it.</p>
<p>For Myfaces, both 1.1 and 1.2 specification, there is a component library named RichFaces. The components there are nice to use for adding ajax-features to your application, and there are also possibilities of adding those capabilities to non-ajax components in myFaces or Tomahawk libraries.</p>
<p>You can download the libraries from here: <a href="http://www.jboss.org/jbossrichfaces/downloads/">RichFaces</a>. Depending on the version of Myfaces you use, you need to get different RichFaces version. For MyFaces 1.1 core you need the RichFaces 3.1.X libraries, for Myfaces 1.2 core you can get the 3.2.X libaries. The 3.2.X libraries does NOT support Myfaces version 1.1</p>
<p>Then, to make use of the new library you need to add the following to your web.xml:</p>
<p>[sourcecode language='xml']<br />
    <filter><br />
        <display-name>RichFaces Filter</display-name><br />
        <filter-name>richfaces</filter-name><br />
        <filter-class>org.ajax4jsf.Filter</filter-class><br />
    </filter><br />
    <filter-mapping><br />
        <filter-name>richfaces</filter-name><br />
        <servlet-name>Faces Servlet</servlet-name><br />
        <dispatcher>REQUEST</dispatcher><br />
        <dispatcher>FORWARD</dispatcher><br />
        <dispatcher>INCLUDE</dispatcher><br />
    </filter-mapping><br />
[/sourcecode]</p>
<p>On the top of your jsps you need to include the taglibraries by inserting these lines:<br />
&#60;%@ taglib uri="http://richfaces.org/rich" prefix="rich"%&#62;<br />
&#60;%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%&#62;</p>
<p>So, when it comes to the actual reRendering of components or part of your page, there are several different ways of doing this.</p>
<p>In its simplest form, you can use the a4j:support to add ajax capabilities to ordinary myfaces components. In this example we use it on an inputText. You set the event property (javascript events), give the id of the component(s) you want to reRender, and then you go. Everytime a user releases a key, the reRender will be called, and getting the outText component again:</p>
<p>[sourcecode language='xml']<br />
<h:inputText id="myInput" value="#{myBean.myProperty}"><br />
    <a4j:support event="onkeyup" reRender="outText"></a4j:support><br />
</h:inputText></p>
<p><h:outputText id="outText" value="#{myBean.myProperty}"></h:outputText><br />
[/sourcecode]</p>
<p>If you use componentBindings, and create those components programmatically, you need to do your custom modification of that component in the setter-method of this component to let the reRendering work. Let's say you have a panelGrid, and you create it java-side and add two outPutTexts to it. If the value of those outputTexts change, and you want to reRender the panelGrid to display this, then the setter of this component is invoked as long as the getter returns null. So you should do like this:</p>
<p>Jsp:</p>
<p>[sourcecode language='xml']<br />
<h:inputText id="myInput" value="#{myBean.myProperty}"><br />
    <a4j:support event="onkeyup" reRender="outPanel"></a4j:support><br />
</h:inputText></p>
<p><t:panelGrid id="outPanel" binding="#{myBean.htmlPanelGrid}"/><br />
[/sourcecode]</p>
<p>Java:</p>
<p>[sourcecode language='java']<br />
public HtmlPanelGrid getHtmlPanelGrid()<br />
{<br />
    return htmlPanelGrid;<br />
}</p>
<p>public void setHtmlPanelGrid(HtmlPanelGrid htmlPanelGrid)<br />
{<br />
    //Clean exisiting children<br />
    htmlPanelGrid.getChildren().clear();</p>
<p>    //Add your modifications<br />
    htmlPanelGrid.getChildren().add(createOutputText("out1","#{myBean.myProperty1}"));<br />
    htmlPanelGrid.getChildren().add(createOutputText("out2","#{myBean.myProperty2}"));</p>
<p>    this.htmlPanelGrid = htmlPanelGrid;<br />
}</p>
<p>private UIComponent createOutputText(String id, String valueBinding)<br />
{<br />
    HtmlOutputText out = new HtmlOutputText();<br />
    out.setId(id);<br />
    ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(<br />
    valueBinding);<br />
    out.setValueBinding("value", vb);</p>
<p>    return out;<br />
}<br />
[/sourcecode]</p>
<p>It is also possible to create the a4j:support programmatically, like this:</p>
<p>[sourcecode language='java']<br />
HtmlAjaxSupport ajaxSupport = new HtmlAjaxSupport();<br />
ajaxSupport.setEvent("onchange");<br />
ajaxSupport.setId("ajaxSupport");<br />
ajaxSupport.setFocus("myForm:theIdOfComponentIWantToFocusOnAfterAjaxSubmit");<br />
ajaxSupport.setReRender("myForm:idOFComponentIWantToReRender"); </p>
<p>myUiComponent.getChildren().add(ajaxSupport);<br />
[/sourcecode]</p>
<p>There is also a component that creates a javascript-function for you which you can use to pass properties to your bean, execute actions and finally reRender components. It's called a4j:jsFunction. Let's say I have a h:commandButton, and when I click it I want to set a value to a property in my bean, I want to run an action, and then display the results. I could have done this with an t:updateActionListener, but then I would have been forced to do a full submit of the whole page. Instead, I can do it like this:</p>
<p>[sourcecode language='xml']</p>
<p>    //Define javascriptFunction with parameter<br />
    <a4j:form><br />
        <a4j:jsFunction name="setParameterAndRerender" action="#{myBean.action}" reRender="outPanel" ><br />
             <a4j:actionparam name="param1" assignTo="#{myBean.myProperty1}"  /><br />
         </a4j:jsFunction><br />
    </a4j:form></p>
<p>    <t:panelGrid id="outPanel" binding="#{myBean.htmlPanelGrid}"/></p>
<p>    <h:commandButton value="Click me" onclick="setParameterAndRerender('MyValue');return false;"></h:commandButton><br />
[/sourcecode]</p>
<p>Notice that I set return false in the onclick of the commandButton to avoid it from submitting. I'll let ajax handle that.</p>
<p>If you create the a4j:support-object progammatically, I've experienced that it doesn't always find the id of the component you have specified to reRender. To solve this, you can use a combination of this one and the javascript function just described:</p>
<p>[sourcecode language='java']<br />
HtmlAjaxSupport ajaxSupport = new HtmlAjaxSupport();<br />
ajaxSupport.setEvent("onchange");<br />
ajaxSupport.setId("ajaxSupport");<br />
ajaxSupport.setFocus("myForm:theIdOfComponentIWantToFocusOnAfterAjaxSubmit");</p>
<p>//We don't specify reRender id here, but set a javascript function to run when completed<br />
//ajaxSupport.setReRender("myForm:idOFComponentIWantToReRender");<br />
ajaxSupport.setOncomplete("setParameterAndRerender('MyValue');");</p>
<p>myUiComponent.getChildren().add(ajaxSupport);<br />
[/sourcecode]</p>
<p>So, what about the RichFaces library? In all components the ajax capabilities are included, you don't have to use a4j:support. When using one of the components the submit will always be an ajax submit, so you can just specify which components to reRender. As a short example, instead of using a h:commandButton you can use a4j:commandButton, like this:</p>
<p>[sourcecode language='xml']<br />
    <a4j:commandButton value="Click me" action="#{myBean.action}"  reRender="outPanel"/><br />
    <t:panelGrid id="outPanel" binding="#{myBean.htmlPanelGrid}"/><br />
[/sourcecode]</p>
<p>Also, if you have a part of a page that always should be ajaxRendered, and you are tired of of writing Ids to reRender, simply wrap that part of the page inside an a4j:outputPanel and set the ajaxRendered property to true. In my a4j:commandButton, I don't have to set the reRender property as this panel is now always reRendered by ajax submits:</p>
<p>[sourcecode language='xml']</p>
<p>    <a4j:commandButton value="Click me" action="#{myBean.action}" /></p>
<p>    <a4j:outputPanel ajaxRendered="true"><br />
        <t:panelGrid id="outPanel" binding="#{myBean.htmlPanelGrid}"/><br />
    </a4j:outputPanel></p>
<p>[/sourcecode]</p>
<p>I hope this have given you a brief idea of what is possible to do with ajax/richFaces and also how to do it :)</p>
<p>I suggest you to check out the livedemo page to see all the different components that RichFaces give you: <a href="http://livedemo.exadel.com/richfaces-demo/richfaces/calendar.jsf">Live demo</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[A new hope...]]></title>
<link>http://wannabecoder.wordpress.com/?p=33</link>
<pubDate>Fri, 25 Jul 2008 07:30:06 +0000</pubDate>
<dc:creator>jollyca</dc:creator>
<guid>http://wannabecoder.wordpress.com/?p=33</guid>
<description><![CDATA[After two days of comparing two &#8220;faces&#8221; - Rich and Ice - I decided that none of them sui]]></description>
<content:encoded><![CDATA[<p>After two days of comparing two "faces" - Rich and Ice - I decided that none of them suits my needs. They both have their pros and cons but they both fail in the DataTable usability area. Features are being asked for by users, of course, but until then I really have to get those two projects going.</p>
<p>So I decided to look at it from a totally different angle - what is the first thing you think of when you want "desktop-like" functionality for your application ? Yes, unfortunately you're right - JavaScript. Now, I don't want to hear any of "JS is overhead", "JS slows down your browser"; yes, it does, but all "faces" also generates JS so STFU. Ok, maybe they generate LESS JavaScript but they also have... less features:). That's why I decided that ExtJS would make a good team with Spring. Of course there are many other JS frameworks out there but ExtJS just captured my attention. Yes, I know Dojo integrates better with Spring but i *really* hate Dojo.</p>
<p>All said and done, now I'm really trying to understand Spring. My past experience consists in coding some components for a Spring-based web application, but I didn't get the chance to "see" the whole picture so it's like learning to walk again. ExtJS is next and then some JSON because apparently that's the way you integrate ExtJS with Spring.</p>
<p>Wish me luck...</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[IceFaces 1 - RichFaces 0...]]></title>
<link>http://wannabecoder.wordpress.com/?p=28</link>
<pubDate>Wed, 23 Jul 2008 13:51:01 +0000</pubDate>
<dc:creator>jollyca</dc:creator>
<guid>http://wannabecoder.wordpress.com/?p=28</guid>
<description><![CDATA[(First of all, to those people at IceFaces that offered their support after they read my previous po]]></description>
<content:encoded><![CDATA[<p><em>(First of all, to those people at IceFaces that offered their support after they read my previous post - thank you, I really appreciate it).</em></p>
<p>Feature-to-feature both Ice and Rich faces are pretty much the same, so I decided to run a simple performance test...<!--more--></p>
<p>I coded a small application that queries an EMC Documentum repository. The query is fairly simple, just a plain "SELECT (some fields) FROM dm_document". The result set has about 90000 (yeah, ninety thousand) documents. Of course, it's a bit extreme, no one in his right mind will never run a query like this in a production application but what the heck ? life is short.</p>
<p>The implementation is really straight-forward - iterate the collection, fill some beans that put everything in an ArrayList and throw it in a dataTable (with pagination enabled). The constructor of the backing bean takes care of the query and initializes the ArrayList.</p>
<p>For RichFaces I used a ScrollableDataTable. This component is the only data table implementation that supports row selection (click, ctrl+click, shift+click... and double click... D'you hear that, IceFaces ?!?). It also features scroll bar (doh, it's a ScrollableDataTable) and you can even define a DataTableScroller  for your convenience. Running the query against all <em>dm_document</em> objects resulted in a OutOfMemory error. I increased the heap size, then re-ran the query - everything worked fine and the table displayed correctly. To my astonishment though the framework re-initiates the table every time I navigate through the pages. This means that every time I navigate through the pages the backing bean gets re-constructed, which totally sucks. Bad RichFaces, bad. Sit !</p>
<p>For IceFaces I used a DataTable with a DataPaginator. The data layer remained the same - the Documentum access layer, the backing bean... The table component in IceFaces supports row selection (single / multiple) by simply clicking the rows - no windows-like selection (ctrl+click, shift+click). I ran into the same problem here too (heap space) when I queried all <em>dm_document</em> objects, but this is not an issue. As I mentioned before, working with 90000 documents result sets it's a bit extreme. It was a pleasant surprise to see that IceFaces does not re-initialize the backing bean every time I navigated to another page, which is a good thing.</p>
<p>From a performance point of view both tables rendered in the same time (give or take a few milliseconds). Querying the repository and generating the ArrayList took about 28 seconds. A big minus for RichFaces - I don't need my bean re-initialized each time I move through the pages.</p>
<p>Ok IceFaces, how about that double-click !?</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Flipping the coin...]]></title>
<link>http://wannabecoder.wordpress.com/?p=24</link>
<pubDate>Mon, 21 Jul 2008 16:39:02 +0000</pubDate>
<dc:creator>jollyca</dc:creator>
<guid>http://wannabecoder.wordpress.com/?p=24</guid>
<description><![CDATA[Oh, the joy of sharing your time between two projects&#8230;
Both projects are big, both projects ar]]></description>
<content:encoded><![CDATA[<p>Oh, the joy of sharing your time between two projects...</p>
<p>Both projects are big, both projects are important and both projects are applications built "from scratch". No WDK, no Webtop customization just our team and the plain old java web applications. Which brings us to an interesting decision... Which framework should we use ?</p>
<p>In the past we used Struts, Spring, some Dojo, we even gave GWT a test-run. Now we are looking at more custom projects so we'll have to choose a framework and stick to it. Which brought me to the coin flipping thing...<!--more--></p>
<p>First it was IceFaces. I ran some of the <a href="http://www.icefaces.org/main/demos/" target="_blank">samples</a>, built some samples (did I mention how SHORT our research time is ?!) and took a quick-look on how our customer's expectations are met by this marvel of the brave new world. The customer needed dynamic columns in a table - no biggie, IceFaces can do that, but it's a big pain in the behind. We also needed row selection using left-click (perfectly doable) and other combination known to any "point-and-click" interface user - ctrl+right-click (no way) and shift+right-click (not a chance). Double-clicking on a row is completely out of the question. I tried fixing this by poking arount the TableRenderer and generating my own event but it turns out that I need to be a) guru or b) IceSoft. So I gave up and turned to...</p>
<p>RichFaces. <a href="http://livedemo.exadel.com/richfaces-demo/index.jsp" target="_blank">Quick demo</a> on the site, interesting things to see - contextual menus, row selection and double-clicking (sic !), full AJAX support etc. I spent a whole day trying to set up my Eclipse IDE to work with JBoss Tools and I finally managed to do it.  On the downside... documentation is either scarce or non-existant. While IceFaces had a lot of documentation floating around, a sample webapp from which you could learn some interesting things RichFaces has a "community driven" documentation with little to no examples. Just the TLD and the "references" - no tutorials, no how-to's, nothing, nada, zip, el zilcho. They have a deployable war with the demos too, but again - not documented at all.</p>
<p>I'm still flipping the coin between those two. They both do THE SAME thing and I am totally aware of the fact that using JSF + some AJAX support + a good JS/CSS/HTML professional I'd accomplish the same thing as with the two framework but you see, good JS/CSS/HTML professionals don't grow on trees and our time is slowly ticking away...</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA["process" attribute]]></title>
<link>http://imfahmi.wordpress.com/?p=29</link>
<pubDate>Wed, 09 Jul 2008 05:30:14 +0000</pubDate>
<dc:creator>Fahmi</dc:creator>
<guid>http://imfahmi.wordpress.com/?p=29</guid>
<description><![CDATA[The &#8220;process&#8221; attribute defines the ids of the components to be processed together with ]]></description>
<content:encoded><![CDATA[<p>The "process" attribute defines the ids of the components to be processed together with the<br />
component which contains this attribute. In order to define processed components you could set<br />
theirs ids into the value of the "process" attribute.<br />
The "process" attribute has two limitations:<br />
• it works only if "ajaxSingle" equals to "true" for given command component<br />
• you do not have to point this attribute to one of the own parent components to avoid processing<br />
of command component twice</p>
<blockquote><p>&#60;body&#62;<br />
&#60;f:view&#62;<br />
&#60;h:form&#62;<br />
&#60;h:inputText id="oneA" value="#{bean.tf1}"/&#62;<br />
&#60;br/&#62;<br />
&#60;h:inputText id="oneB" value="#{bean.tf2}"/&#62;<br />
&#60;br/&#62;<br />
&#60;a4j:commandButton value="Submit2" process="oneB" ajaxSingle="true"<br />
reRender="three1, three2"/&#62;<br />
&#60;br/&#62;<br />
one : &#60;h:outputText id="three1" value="#{bean.tf1}"/&#62;<br />
&#60;br/&#62;<br />
two : &#60;h:outputText id="three2" value="#{bean.tf2}"/&#62;<br />
&#60;/h:form&#62;<br />
&#60;/f:view&#62;<br />
&#60;/body&#62;</p></blockquote>
]]></content:encoded>
</item>
<item>
<title><![CDATA[a4j:status - The Status Tag ]]></title>
<link>http://imfahmi.wordpress.com/?p=27</link>
<pubDate>Tue, 08 Jul 2008 07:04:36 +0000</pubDate>
<dc:creator>Fahmi</dc:creator>
<guid>http://imfahmi.wordpress.com/?p=27</guid>
<description><![CDATA[The Status Tag can be used as a kind of Indication to the Client about the current Status of the Req]]></description>
<content:encoded><![CDATA[<p>The <strong><em>Status Tag</em></strong> can be used as a kind of Indication to the Client about the current Status of the Request, like whether the Request is still being processed by the Server or the Request has been served.</p>
<blockquote><p>&#60;body&#62;<br />
&#60;f:view&#62;<br />
&#60;h:form&#62;<br />
&#60;h:inputText value="#{bean.text}"&#62;<br />
&#60;a4j:support event="onkeyup" ajaxSingle="true"&#62;&#60;/a4j:support&#62;<br />
&#60;a4j:status startText = "S" stopText = "R"&#62;&#60;/a4j:status&#62;<br />
&#60;/h:inputText&#62;<br />
&#60;br /&#62;<br />
&#60;/h:form&#62;<br />
&#60;/f:view&#62;<br />
&#60;/body&#62;</p></blockquote>
<p style="text-align:center;">
]]></content:encoded>
</item>
<item>
<title><![CDATA[To A4J or Not to A4J?]]></title>
<link>http://rememberoneanother.wordpress.com/?p=24</link>
<pubDate>Mon, 07 Jul 2008 19:02:28 +0000</pubDate>
<dc:creator>jobber</dc:creator>
<guid>http://rememberoneanother.wordpress.com/?p=24</guid>
<description><![CDATA[For the past two weeks or so I have been frenetically learning Ajax for Java and RichFaces. The avai]]></description>
<content:encoded><![CDATA[<p>For the past two weeks or so I have been frenetically learning Ajax for Java and RichFaces. The available components shine on the view, adding speed, simplicity, and functionality to our application.</p>
<p>Unfortunately, the fact that two weeks have passed since I began work on the core page of the application signals that there are problems. Certainly, some of them are due to my lack of experience, and are to be expected. Others, however, have been caused or aggravated by implementing a4j and RichFaces.</p>
<p>While RichFaces is documented, there seem to be unmentioned complexities to the implementation of almost every component. When used in the environment for which they were designed, each component works excellently, but when we used them in conjunction with other components and other code implementations, time-consuming problems arose.</p>
<p>For instance, components such as rich:modalPanel rendered lightening fast on Internet Explorer but crawled in Firefox, while commandLinks in rich:dataTables worked on Firefox, but not IE!</p>
<p>As a detailed example of our troubles, and as today's Note for Dense Summer Inters, we spent several hours working with <a href="https://addons.mozilla.org/en-US/firefox/addon/966">Tamper Data</a> and Eclipse console to determine what exactly was failing in a rich:dataList. The list contained links with a4j:actionparams that assigned the current variable object to the bean, for purposes of reRendering a view of the object's details. It was only after wasting about a day that we discovered that the actionParam was not sending the object at all. Apparently, a4j:actionParam cannot assign as a value the variable of a rich:dataList, only properties of that variable. We switched to a rich:dataTable, and all was snazzy site design once again.</p>
<p>Today we decided that, until we got farther down the road of functionality, it was only shooting ourselves in the proverbial feet to struggle through a4j implementation and basic site design simultaneously. For now, we plan to drop RichFaces and use simple JSF until such a time as we have a functional site to which we wish to add a4j. At that point we must decide what component library to use. Among our options are first, of course, RichFaces, but also <a href="http://www.icefaces.org/main/product/product-overview.iface">IceFaces</a> and <a href="http://dojotoolkit.org/">Dojo</a> (which has an extra-impressive <a href="http://dojocampus.org/explorer/">showcase</a>!). RichFaces may be difficult to integrate with any portal other than JBoss portal, and Mr. Chandler believes we may in some future release want to implement <a href="http://www.liferay.com/web/guest/products/portal">LifeRay.</a> This would be a vote in favor of IceFaces, which supports LifeRay explicitly.</p>
<p>So we sadly bid a4j farewell, for the time being.</p>
<p>Studying (or should I say geeking out over) various a4j graphic component libraries today, I came across the phrase "Lorem ipsum dolor sit amet consectetuer" etc one several occasions. Mr. Chandler told me it is the standard filler text for graphic artists. Curious, I looked it up, and here it is as the Filler Text of the Day: First, <a href="http://support.microsoft.com/kb/114222">an article</a> article describing the history of the phrase's usage, giving a full translation of the standard text and the Cicero text it stems from, and offering to generate some random ipsum just for you!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[ajaxRendered VS reRender]]></title>
<link>http://imfahmi.wordpress.com/?p=25</link>
<pubDate>Mon, 07 Jul 2008 12:04:05 +0000</pubDate>
<dc:creator>Fahmi</dc:creator>
<guid>http://imfahmi.wordpress.com/?p=25</guid>
<description><![CDATA[&lt;a4j:outputPanel ajaxRendered=&#8221;true&#8221;&gt;
&lt;h:messages /&gt;
&lt;/a4j:outputPanel]]></description>
<content:encoded><![CDATA[<blockquote><p>&#60;a4j:outputPanel ajaxRendered="true"&#62;<br />
&#60;h:messages /&#62;<br />
&#60;/a4j:outputPanel&#62;</p></blockquote>
<p>"limitToList" attribute allows to dismiss the behavior of the &#60;a4j:outputPanel&#62; "ajaxRendered"<br />
attribute. "limitToList" = "false" means to update only the area(s) that mentioned in the "reRender"<br />
attribute explicitly. All output panels with "ajaxRendered"="true"is ignored. An example is placed<br />
below:</p>
<blockquote><p>&#60;h:form&#62;<br />
&#60;h:inputText value="#{person.name}"&#62;<br />
&#60;a4j:support event="onkeyup" reRender="test" limitToList="true"/&#62;<br />
&#60;/h:inputText&#62;<br />
&#60;h:outputText value="#{person.name}" id="test"/&#62;<br />
&#60;/form&#62;</p></blockquote>
<p><!--more--></p>
<p>Demonstration :</p>
<blockquote><p>&#60;body&#62;</p>
<p>&#60;f:view&#62;<br />
&#60;h:form&#62;</p>
<p>This value Will Render 'X' and 'Y' : &#60;h:inputText value="#{bean.text}"&#62;<br />
&#60;a4j:support event="onkeyup" reRender="y" ajaxSingle="true"&#62;&#60;/a4j:support&#62;<br />
&#60;/h:inputText&#62;<br />
&#60;br /&#62;<br />
This value Will Render only 'X' : &#60;h:inputText value="#{bean.text}"&#62;<br />
&#60;a4j:support event="onkeyup" reRender="y" ajaxSingle="true" limitToList="true"&#62;&#60;/a4j:support&#62;<br />
&#60;/h:inputText&#62;<br />
&#60;br /&#62;</p>
<p>&#60;a4j:outputPanel ajaxRendered="true"&#62;Return By Ajax &#60;br/&#62;X : &#60;h:outputText id="x" value="#{bean.text}"&#62;&#60;/h:outputText&#62;&#60;/a4j:outputPanel&#62;</p>
<p>&#60;br /&#62;<br />
Return By Ajax &#60;br/&#62;Y : &#60;h:inputText id="y"  value="#{bean.text}"&#62;&#60;/h:inputText&#62;<br />
&#60;/h:form&#62;<br />
&#60;/f:view&#62;<br />
&#60;/body&#62;</p></blockquote>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Simple RichFaces Validation]]></title>
<link>http://rememberoneanother.wordpress.com/?p=21</link>
<pubDate>Mon, 23 Jun 2008 21:48:08 +0000</pubDate>
<dc:creator>jobber</dc:creator>
<guid>http://rememberoneanother.wordpress.com/?p=21</guid>
<description><![CDATA[I began today with a long-term goal of getting the core page of the application written. This is the]]></description>
<content:encoded><![CDATA[<p>I began today with a long-term goal of getting the core page of the application written. This is the page that will allow users to create, edit, view, and manage prayer requests.</p>
<p>Before half an hour passed, I knew I needed to study <a href="http://en.wikipedia.org/wiki/Richfaces">RichFaces.</a> We hope to use a lot of rich components in the application, enabling the user to make changes large or small without refreshing the entire page, and to facilitate easy searches and selections. so I looked up the RedHat team's <a href="http://livedemo.exadel.com/richfaces-demo/index.jsp">RichFaces Live Demo</a>, and spent the better part of the morning "geeking out" over all the exciting components they offer. It was so much fun that it is the Website of the Day!</p>
<p>Then it was time for a simple test; I decided I would add rich validation to the account creation page, telling the user on screen if his or her field entries were too short or too long, saving the trouble of waiting through an entire refresh to find out.</p>
<p>This test was successfully completed approximately six hours later. Lack of RichFaces knowledge led me on a merry chase for the correct functionality. With Mr. Chandler's help, I made several useful discoveries.</p>
<p>First, in order to implement a4j and RichFaces, certain filters and context parameters are required in the web.xml, and they can be order-sensitive.</p>
<p>Second, in order to work properly, RichFaces must be allowed to access a file in the server path.<br />
Our filter was intercepting this call. We fixed it by making the filtered path one step more specific, excluding the one called by RichFaces.</p>
<p>Finally, I discovered that a functional RichFaces validation on a simple field can be accomplished using the following simple process.</p>
<p>In our xhtml page, we first added the following line inside our input box tags:</p>
<p>&#60;a4j:support event="onkeyup" reRender="passwordMsg" requestDelay="1000" /&#62;</p>
<p>This instructs a4j to wait 1000 milliseconds after the first keystroke in the input box is released, and then to reRender the component with the id 'passwordMsg'. The requestDelay is included to prevent the server from processing requests generated by every keystroke.</p>
<p>Second, we added the following code after the closing tag for the input box.</p>
<p>&#60;a4j:outputPanel id="passwordMsg"&#62;</p>
<p>         &#60;h:message for="password" showDetail="true" style="color:red;" /&#62;</p>
<p>&#60;/a4j:outputPanel&#62;</p>
<p>This is the panel reRendered by the support component. The h:message simply begins a normal validation process.</p>
<p>In conclusion, I am happy to say that today was tidy, encapsulated by the accomplishment of a single goal.</p>
<p>Today's Note for Dense Summer Interns: The solution to your RichFaces problem is probably just one webpage away. Don't keep experimenting with complicated solutions when you could be exploring more rich components!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[getting node data from rich tree on user selection]]></title>
<link>http://thomaswabner.wordpress.com/?p=13</link>
<pubDate>Fri, 13 Jun 2008 13:33:13 +0000</pubDate>
<dc:creator>thomaswabner</dc:creator>
<guid>http://thomaswabner.wordpress.com/?p=13</guid>
<description><![CDATA[I have had the problem to get node data from a richfaces tree, if the user selects a node. I have us]]></description>
<content:encoded><![CDATA[<p>I have had the problem to get node data from a richfaces tree, if the user selects a node. I have used a recursive tree adapter:</p>
<p>[sourcecode language="html"]<br />
<rich:tree switchType="server"<br />
           stateAdvisor="#{treeStateAdvisor}"<br />
           nodeSelectListener="#{treeMgrt.onSelect}"></p>
<p>   <rich:recursiveTreeNodesAdaptor roots="#{treeMgrt.roots}" var="item" nodes=" {item.nodes}"></p>
<p>     <rich:treeNode><br />
         <h:outputText value="#{item}"/><br />
     </rich:treeNode> </p>
<p>  </rich:recursiveTreeNodesAdaptor><br />
</rich:tree><br />
[/sourcecode]</p>
<p>The method in my tree manager onSelect(...) looks like this:<br />
[sourcecode language="java"]<br />
public void onSelect(final NodeSelectedEvent event) {<br />
  final UITree theTree = this.getTree(event);<br />
  if (null == theTree) {<br />
    return;<br />
  }<br />
  final Object rowKey = theTree.getRowKey();<br />
  // this works better<br />
  final Object rowData = theTree.getRowData(rowKey);<br />
  if (rowData instanceof ProductNode) {<br />
    this.selectedNode = (ProductNode) rowData;<br />
  }<br />
}<br />
[/sourcecode]</p>
<p>Normally you can use theTree.getTreeNode(); but with a recursive tree model which method returns alway null. Instead of this I have used the getRowData() method which works for me.<br />
I have filed a <a href="http://jira.jboss.com/jira/browse/RF-3699">bug</a> for richfaces. Hope the problem becomes shortly a solution.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[RichFaces plugin Released for NetBeans 6.1]]></title>
<link>http://edemmorny.wordpress.com/?p=55</link>
<pubDate>Mon, 19 May 2008 09:45:14 +0000</pubDate>
<dc:creator>Edem Morny</dc:creator>
<guid>http://edemmorny.wordpress.com/?p=55</guid>
<description><![CDATA[&lt; Seam PDF Rendering
Last week Geertjan Wielanga released a plugin he&#8217;d been working on for]]></description>
<content:encoded><![CDATA[<p><a href="http://edemmorny.wordpress.com/2008/03/31/seam-pdf-rendering-and-jpa-native-queries/">&#60; Seam PDF Rendering</a></p>
<p>Last week <a href="http://blogs.sun.com/geertjan/">Geertjan</a> Wielanga released a <a href="https://nbrichfacessupport.dev.java.net/index.html">plugin</a> he'd been working on for RichFaces tag support in NetBeans. I gave it a shot and its not bad.</p>
<p>Its meant to provide tag support as well as drag and drop of RichFaces controls on the palette. Interestingly this support is meant for both jsps and facelets. But seriously speaking, how many people are using RichFaces on jsps instead of on Facelets? Since this plugin only works with NetBeans 6.1 and the facelets support plugin does not work with 6.1, I really wonder what use it is to me and to a significant number of others.</p>
<p>This is really causing me to worry for Sun. Anyone doing anything new in JSF is not going with JSPs if they really know what is best for them, but rather with Facelets. If Sun really wants JSF to catch up (alongside using NetBeans as their preferred JSF development tool) then they should provide us developers with at least some of what JBoss Tools provides - visual editing. I've been waiting for Sun's Visual JSF to now support Facelets, cos there's no way I'm sticking with Rave. I think a lot of people share this sentiment and it is the reason why everyone is praising Seam for the good work its doing.</p>
<p>If Sun has seen it fit to bring Jacob Hookom onto the JSF 2 EG as a sign of respect for what Facelets stands for, then it should stop sitting on the sidewalk with Facelets support in NetBeans and get some decent support for it (and I mean not just tag support). Most of us NetBeans fans are in a love hate relationship with it because of such political (in)decisions. Sun should continue taking developers seriously and see how to improve on it's technologies with already proven ones instead of trying to stuff things down our throats that we don't want to swallow.</p>
<hr />
28th May 2008</p>
<p>Ah. I just came across a release of the Facelets support for NetBeans 6.0 rebuilt to work with NetBeans 6.1. Good job by <a href="http://ifnu.artivisi.com">http://ifnu.artivisi.com</a>. <a href="http://project-template.googlecode.com/files/nbfaceletssupport-6.1.zip">Here</a> is the download. And thanks to Po-Ting Wu for the <a href="http://blogs.sun.com/poting/entry/build_and_install_facelets_support">rebuild instructions</a>.</p>
<p>Thanks also to Geertjan for the work on Richfaces support. JSF development will get better and easier!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Implementing richfaces extended data model classes]]></title>
<link>http://prasun.wordpress.com/?p=4</link>
<pubDate>Mon, 19 May 2008 09:12:42 +0000</pubDate>
<dc:creator>prasun</dc:creator>
<guid>http://prasun.wordpress.com/?p=4</guid>
<description><![CDATA[RichFaces data driven components (rich:dataTable , rich:dataGrid etc.) can be used in more complicat]]></description>
<content:encoded><![CDATA[<p><strong>RichFaces</strong> data driven components (<strong>rich:dataTable</strong> , <strong>rich:dataGrid</strong> etc.) can be used in more complicated scenarios unlike standard DataTable and DataModel class. To get the new supports one needs to implement his own DataModel that extends one of ExtendedDataModel classes. But it’s not efficient every time implementing the class when needs. So here I write my own solution.</p>
<p><strong>Implementation</strong></p>
<p>I extend org.ajax4jsf.model.SerializableDataModel class as usual. But the tricks lie in overridden walk method. A general fetch list of ExtendedFetchList is used to access data instead of a specific fetch list. ExtendedFetchList interface declares all the necessary methods for dynamic data accessing. See the following codes and usage example. <!--more--> </p>
<p><em>ExtendedListDataModel:</em></p>
<p><code>public class ExtendedListDataModel extends SerializableDataModel {<br />
	private boolean detached = false;<br />
	private BigDecimal currentPk;<br />
	private Map wrappedData = new HashMap();<br />
	private List wrappedKeys = null;<br />
	private ExtendedFetchList fetchList = null;<br />
	private int rowIndex;<br />
	private static final long serialVersionUID = 1L;<br />
	/* (non-Javadoc)<br />
	 * @see org.ajax4jsf.model.SerializableDataModel#update()<br />
	 */<br />
	@Override<br />
	public void update() {<br />
		// TODO Auto-generated method stub<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()<br />
	 */<br />
	@Override<br />
	public Object getRowKey() {<br />
		// TODO Auto-generated method stub<br />
		return currentPk;<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)<br />
	 */<br />
	@Override<br />
	public void setRowKey(Object key) {<br />
		// TODO Auto-generated method stub<br />
		this.currentPk = (BigDecimal)key;<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)<br />
	 */<br />
	@Override<br />
	public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException {<br />
		int firstRow = ((SequenceRange)range).getFirstRow();<br />
		int numberOfRows = ((SequenceRange)range).getRows();<br />
		if (detached) { // Is this serialized model<br />
			// Here we just ignore current Rage and use whatever data was saved in serialized model.<br />
			// Such approach uses much more getByPk() operations, instead of just one request by range.<br />
			// Concrete case may be different from that, so you can just load data from data provider by range.<br />
			// We are using wrappedKeys list only to preserve actual order of items.<br />
			for (BigDecimal key:wrappedKeys) {<br />
				setRowKey(key);<br />
				visitor.process(context, key, argument);<br />
			}<br />
		} else { // if not serialized, than we request data from data provider<br />
			wrappedKeys = new ArrayList();<br />
			for (Object obj:fetchList.fetchList(firstRow, numberOfRows)) {<br />
				wrappedKeys.add(fetchList.getPk(obj));<br />
				wrappedData.put(fetchList.getPk(obj), obj);<br />
				visitor.process(context, fetchList.getPk(obj), argument);<br />
			}<br />
		}<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see javax.faces.model.DataModel#getRowCount()<br />
	 */<br />
	@Override<br />
	public int getRowCount() {<br />
		// TODO Auto-generated method stub<br />
		//return fetchList.getListSize();<br />
		return fetchList.getMaxListSize();<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see javax.faces.model.DataModel#getRowData()<br />
	 */<br />
	@Override<br />
	public Object getRowData() {<br />
		// TODO Auto-generated method stub<br />
		if (currentPk == null) {<br />
			return null;<br />
		} else {<br />
			Object ret = wrappedData.get(currentPk);<br />
			return ret;<br />
		}<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see javax.faces.model.DataModel#getRowIndex()<br />
	 */<br />
	@Override<br />
	public int getRowIndex() {<br />
		// TODO Auto-generated method stub<br />
		//throw new UnsupportedOperationException();<br />
		return rowIndex;<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see javax.faces.model.DataModel#getWrappedData()<br />
	 */<br />
	@Override<br />
	public Object getWrappedData() {<br />
		// TODO Auto-generated method stub<br />
		throw new UnsupportedOperationException();<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see javax.faces.model.DataModel#isRowAvailable()<br />
	 */<br />
	@Override<br />
	public boolean isRowAvailable() {<br />
		// TODO Auto-generated method stub<br />
		if (currentPk == null) {<br />
			return false;<br />
		} else {<br />
			return wrappedData.containsKey(currentPk);<br />
		}<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see javax.faces.model.DataModel#setRowIndex(int)<br />
	 */<br />
	@Override<br />
	public void setRowIndex(int arg0) {<br />
		// TODO Auto-generated method stub<br />
		//throw new UnsupportedOperationException();<br />
		rowIndex = arg0;<br />
		return;<br />
	}<br />
	/* (non-Javadoc)<br />
	 * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)<br />
	 */<br />
	@Override<br />
	public void setWrappedData(Object arg0) {<br />
		// TODO Auto-generated method stub<br />
		throw new UnsupportedOperationException();<br />
	}<br />
	public  SerializableDataModel getSerializableModel(Range range) {<br />
		if (wrappedKeys != null) {<br />
			detached = true;<br />
			// Some activity to detach persistent data from wrappedData map may be taken here.<br />
			// In that specific case we are doing nothing.<br />
			return this;<br />
		} else {<br />
			return null;<br />
		}<br />
	}<br />
	/**<br />
	 * @return the fetchList<br />
	 */<br />
	public ExtendedFetchList getFetchList() {<br />
		return fetchList;<br />
	}<br />
	/**<br />
	 * @param fetchList the fetchList to set<br />
	 */<br />
	public void setFetchList(ExtendedFetchList fetchList) {<br />
		this.fetchList = fetchList;<br />
	}<br />
}<br />
</code></p>
<p><em>ExtendedFetchList</em></p>
<p><code>public interface ExtendedFetchList {<br />
	public List fetchList(int startRow, int size);<br />
	public BigDecimal getPk(Object obj);<br />
	public void update();<br />
	public int getListSize();<br />
	public int getMaxListSize();<br />
}<br />
</code></p>
<p><strong>Usage: An Example</strong></p>
<p><em>AnExampleListModel:</em></p>
<p><code>public class AnExampleListModel implements Serializable {<br />
	private ExtendedListDataModel exampleList = new ExtendedListDataModel();<br />
	private ExtendedFetchList fetchList;<br />
	private static final long serialVersionUID = 102136548978979L;<br />
	/**<br />
	 * @return the exampleList<br />
	 */<br />
	public ExtendedListDataModel getExampleList() {<br />
		return exampleList;<br />
	}<br />
	/**<br />
	 * @param exampleList the exampleList to set<br />
	 */<br />
	public void setExampleList(ExtendedListDataModel exampleList) {<br />
		this.exampleList = exampleList;<br />
	}<br />
	/**<br />
	 * @return the fetchList<br />
	 */<br />
	public ExtendedFetchList getFetchList() {<br />
		return fetchList;<br />
	}<br />
	/**<br />
	 * @param fetchList the fetchList to set<br />
	 */<br />
	public void setFetchList(ExtendedFetchList fetchList) {<br />
		this.fetchList = fetchList;<br />
		exampleList.setFetchList(fetchList);<br />
	}<br />
}<br />
</code></p>
<p><em>AnExampleFetchList:</em></p>
<p><code>public class AnExampleFetchList implements ExtendedFetchList, Serializable {<br />
	private static final long serialVersionUID = 1L;<br />
	private int listSize;<br />
	private int maxListSize;<br />
	public List fetchList(int startRow, int size) {<br />
		List list = new Vector();<br />
		//call some method here to populate the list<br />
                //For example<br />
		RangeQueryResult rqr = foo.getBars(startRow, size);<br />
		list = rqs.getResultList();<br />
		setListSize(list.size());<br />
		setMaxListSize(rqr.getMaxResult());<br />
		return list;<br />
	}<br />
	@SuppressWarnings("unchecked")<br />
	public BigDecimal getPk(Object obj) {<br />
		Map columns = (Map) obj;<br />
		return new BigDecimal(columns.get("id").toString());<br />
	}<br />
	public void update() {}<br />
	public int getListSize(){<br />
		return listSize;<br />
	}<br />
	public int getMaxListSize(){return maxListSize;}<br />
	/**<br />
	 * @param listSize the listSize to set<br />
	 */<br />
	public void setListSize(int listSize) {<br />
		this.listSize = listSize;<br />
	}<br />
	/**<br />
	 * @param maxListSize the maxListSize to set<br />
	 */<br />
	public void setMaxListSize(int maxListSize) {<br />
		this.maxListSize = maxListSize;<br />
	}<br />
}<br />
</code>          	</p>
<p><em>Bean Definitions:</em></p>
<p><code>&#60;managed-bean&#62;<br />
	&#60;managed-bean-name&#62;exampleListModel&#60;/managed-bean-name&#62;<br />
	&#60;managed-bean-class&#62;<br />
	com.mycompany.web.model.AnExampleListModel<br />
	&#60;/managed-bean-class&#62;<br />
	&#60;managed-bean-scope&#62;request&#60;/managed-bean-scope&#62;<br />
	&#60;managed-property&#62;<br />
	&#60;property-name&#62;fetchList&#60;/property-name&#62;<br />
	&#60;property-class&#62;<br />
	com.iecb.web.model.AnExampleFetchList<br />
	&#60;/property-class&#62;<br />
	&#60;value&#62;#{exampleFetchList}&#60;/value&#62;<br />
	&#60;/managed-property&#62;<br />
&#60;/managed-bean&#62;<br />
&#60;managed-bean&#62;<br />
	&#60;managed-bean-name&#62;exampleFetchList&#60;/managed-bean-name&#62;<br />
	&#60;managed-bean-class&#62;<br />
	com.iecb.web.model.AnExampleFetchList<br />
	&#60;/managed-bean-class&#62;<br />
	&#60;managed-bean-scope&#62;session&#60;/managed-bean-scope&#62;<br />
&#60;/managed-bean&#62;<br />
</code></p>
<p><em>Example Template:</em><br />
<code>&#60;h:panelGrid id="exampleContainer" columns="1"&#62;<br />
&#60;rich:dataTable id="exampleListDT" value="#{exampleListModel.exampleList}" var="item" rows="25"  style="width:100%"&#62;<br />
 &#60;h:column&#62;<br />
     &#60;f:facet name="header"&#62;<br />
        	&#60;h:outputText value="Column1" /&#62;<br />
     &#60;/f:facet&#62;<br />
     &#60;h:outputText value="#{item['column1']}" /&#62;<br />
 &#60;/h:column&#62;<br />
 &#60;h:column&#62;<br />
     &#60;f:facet name="header"&#62;<br />
        	&#60;h:outputText value="Column2" /&#62;<br />
     &#60;/f:facet&#62;<br />
     &#60;h:outputText value="#{item['column2']}" /&#62;<br />
 &#60;/h:column&#62;<br />
&#60;/rich:dataTable&#62;<br />
 &#60;rich:spacer height="5" /&#62;<br />
 &#60;rich:datascroller align="left"  for="exampleListDT" maxPages="10" ajaxSingle="false"/&#62;<br />
&#60;/h:panelGrid&#62;<br />
</code></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[RichFaces e jQuery: tudo ao mesmo tempo agora]]></title>
<link>http://tocadocalango.wordpress.com/?p=6</link>
<pubDate>Wed, 30 Apr 2008 03:01:57 +0000</pubDate>
<dc:creator>Ricardo Wendell</dc:creator>
<guid>http://tocadocalango.wordpress.com/?p=6</guid>
<description><![CDATA[A utilização dos componentes do RichFaces facilita bastante a incorporação de características d]]></description>
<content:encoded><![CDATA[<p>A utilização dos componentes do <a href="http://www.jboss.org/jbossrichfaces/" target="_blank">RichFaces</a> facilita bastante a incorporação de características de aplicações ricas a sistemas web que utilizam <a href="http://java.sun.com/javaee/javaserverfaces/" target="_blank">JavaServer Faces</a>. A cada nova versão da biblioteca, mais e mais opções tornam-se disponíveis para incrementar sua aplicação e facilitar o desenvolvimento de interfaces mais complexas.</p>
<p>Entretanto, é bom lembrar que, por trás de todas estas maravilhas da praticidade moderna que o RichFaces oferece, ainda temos o bom e velho JavaScript por baixo dos panos. É esta incrível linguagem, que somente recentemente começou a ganhar o prestígio merecido, que move a maioria das funcionalidades mágicas dos componentes. Para tal, os desenvolvedores da biblioteca utilizaram-se de dois frameworks JavaScript bastante conhecidos: <a href="http://www.prototypejs.org/" target="_blank">Prototype</a> e <a href="http://script.aculo.us/" target="_blank">Script.aculo.us</a> (baseado no primeiro).</p>
<p>Estes dois já foram (e alguns ainda os consideram) os preferidos para auxiliar no desenvolvimento de soluções em JavaScript. Por causa disso vários outros projetos incorporaram estas bibliotecas para agregar comportamentos diversos a por exemplo: componentes JSF. E adivinha quem também fez essa escolha? o pessoal do RichFaces...</p>
<p>Muito bem, mas e o <a href="http://jquery.com/" target="_blank">jQuery</a>? Onde ele entra nessa história toda?</p>
<p>Acontece que o jQuery e seus <a href="http://plugins.jquery.com/" target="_blank">diversos plugins</a> estão cada vez mais na cabeça (e nos códigos) dos desenvolvedores web. Ele vai além do Prototype em vários aspectos: ganhou inúmeros admiradores e contribuidores, e é hoje uma opção mais conveniente para a adição de comportamentos à paginas web.</p>
<p>Resumindo então o cenário: temos os componentes prontos do RichFaces que encapsulam transparentemente códigos que utilizam Prototype e Script.aculo.us e, caso necessário, podemos adicionar outros comportamentos necessários com jQuery.</p>
<p>Qual o problema então?</p>
<p>O "problema" é que um importante método tanto do Prototype quanto do jQuery possuem nomes iguais!</p>
<p>A principal função do Prototype, e que é utilizada basicamente para reduzir o tamanho dos códigos de manipulação de elementos da árvore DOM, é a <span style="color:#229922;"> <code> <strong>$()</strong></code></span>. Esta pequena função substitui o longo método original para a busca de elementos da página por seu id: <span style="color:#229922;"> <code> <strong>document.getElementById()</strong></code></span>.</p>
<p>No jQuery, a função  <span style="color:#229922;"> <code> <strong>$()</strong></code></span> é o grande coringa: serve para buscar elementos da página através de seletores CSS, para criar novos elementos para serem adicionados à página ou para definir funções que devem ser executadas assim que a árvore de elementos tiver sido carregada pelo navegador (depois providencio um post mais detalhado sobre esta função tão versátil).</p>
<p>Então não é possível usar as duas ao mesmo tempo? E já que RichFaces utiliza Prototype, não posso usar jQuery quando empregar seus componentes? Mas é claro que pode!!</p>
<p>É possível utilizar as funcionalidades das duas bibliotecas com uma pequena adaptação: definindo um nome alternativo para a função  <span style="color:#229922;"> <code> <strong>$()</strong></code></span>do jQuery e utilizando-a sem a preocupação com conflitos com o Prototype. Veja o código abaixo como esta alternativa pode ser utilizada:</p>
<p>[sourcecode language='jscript']<br />
var $j = jQuery.noConflict();</p>
<p>$j("div").hide();<br />
$('rodape').show();</p>
<p>[/sourcecode]</p>
<p>Neste exemplo, a função <span style="color:#229922;"><code><strong>$j()</strong></code></span> irá funcionar com o comportamento desejado para o jQuery e a função <span style="color:#229922;"><code><strong>$() </strong></code></span>funciona como a sua definição original do Prototype. Simples assim!</p>
<p>Agora você pode usufruir do melhor dos dois mundos: a praticidade dos componentes prontos e a flexibilidade de definir novos comportamentos ou utilizar os plugins prontos do jQuery.</p>
<p>Acho que para um primeiro post "de verdade" este até que ficou bem longo... A idéia parecia bem simples no começo, mas a necessidade da contextualização acrescentou algumas linhas a mais...</p>
<p>E no caso de alguma dúvida, o espaço para comentários está aí para ser utilizado! :)</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ajax and J2EE or how simple things became complicated]]></title>
<link>http://razvanp.wordpress.com/?p=3</link>
<pubDate>Tue, 15 Apr 2008 18:30:23 +0000</pubDate>
<dc:creator>razvanp</dc:creator>
<guid>http://razvanp.wordpress.com/?p=3</guid>
<description><![CDATA[Last days I have started a new project. It&#8217;s about finance, budgeting and management. The UML ]]></description>
<content:encoded><![CDATA[<p>Last days I have started a new project. It's about finance, budgeting and management. The UML class diagrams have already dozen of entities, which translate in dozen of tables.</p>
<p>As a big fan of MDA, after designing the model I have immediately generated the database structure, Hibernate POJOs and EJB (at that moment, still undecided which direction should be followed). The whole work took about 30 minutes, with Apache Maven and AndroMDA.</p>
<p>But what about the user interface? AndroMDA offers something similar to "scaffolding" of Ruby on Rails. My problem with this scaffolding is that a number of files are only generated once, subsequent changes will not reflect them self on the existing generated sources. With other words, it sucks, since I am sure my model is not final, customers will perform lots of changes until it goes into production.</p>
<p>Following the speculation path (yes, I do use Agile PM), I have taken the simplest entity, which only has three columns (2 strings and a boolean) and attempted to see how easy is to have an AJAX based table to perform CRUD (create read update delete) on this table.</p>
<p>The first choice would be ZK, an open source AJAX library. Because of their GPL license, which forces me either to publish my sources or to acquire their commercial license, I have considered another AJAX engine, RichFaces.</p>
<p>RichFaces has a nice comprehensive demo and a bad written manual; as a beginner in RichFace, I find it unreadable because of cyclical definitions (such as:  "bypassUpdates attribute allows to bypass the Update Model phase" and no definition of Update Model is given) and employment of too many undefined concepts. Maybe my further contacts with RichFaces will allow me to read their manual with other eyes. I have found a nice sample explaining tables with editable cells. It looks nice, but, it doesn't store the changed data! The inquiry on the RichFaces forum had was immediately answered by some more advanced user, which acknowledged the issue and provided a solution. I was just one step away of abandoning the RichFaces track and moving to other AJAX engine, but their vibrant community convinced me indirectly not to switch.</p>
<p>After successfully building and running the web application within Maven, my approach is to connect the table to a list of EJB3 entities. The plan is to build a transaction on each change since it is not usual that users will perform a lot of changes here, and this avoids the usage of a "Commit" button people can forget to press while jumping to another page.<br />
I also plan to have a "New Item" and "Delete Item" button. Delete seems to be easy to implement, while adding a new item can be a pain - since the table has a paged scroller and after adding the new item, the scroller should jump at its page. Also, the newly inserted item has an "uncommitted" state until all of its items are filled with data.</p>
<p>Well, after reviewing the findings in this loop, I remember 18 years old technology named "FoxPro". This technology powered my first business. It didn't have funny programming features such objects, no enterprise capabilities (they were added afterwards). It doesn't run through a web interface or even within a windowing system (but on a 80x25 character screen). This tool could easily handle an editor with millions of entries on an Intel 80286 processor based machine, and this with a simple BROWSE command. Now, I read blogs of ajaxians complaining about performance of Ajax tables containing 500 entries! If FoxPro would be hypothetically transformed in a client server engine, considering an average refresh rate of the screen to one second, it would use only a 32kbit bandwidth to run through a terminal. An ajax application uses much more bandwidth, even in the context Ajax reduces the amount of data transacted (and if properly coded, the number of transactions) between server and client.</p>
<p>So, what is the direction our technology evolution follows? Do we sacrifice the simplicity of design and implied simplicity of deployment and usability to acquire some obscure targets such as "transactionability" or "service oriented architecture"? I see now more than ever web sites crashing with errors like "Invalid Transactional State" or "Session Expired" (although I didn't time it out). I try to imagine what platform did the developers of these sites use and what mistake they done and the answer is from day to day harder to find.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF, Ajax and file download]]></title>
<link>http://ahoehma.wordpress.com/?p=15</link>
<pubDate>Mon, 31 Mar 2008 12:43:08 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/?p=15</guid>
<description><![CDATA[Today i show you a example which combines Ajax (Richfaces) and a &#8220;normal&#8221; Download in a ]]></description>
<content:encoded><![CDATA[<p>Today i show you a example which combines Ajax (Richfaces) and a "normal" Download in a JSF application.<br />
The bean for the download-code is here:</p>
<p>[sourcecode language='java']<br />
public class DownloadBean {</p>
<p>  // actionListener="#{bean.execute}"<br />
  public void execute (ActionEvent event) {<br />
   download();<br />
  }</p>
<p>  // action="#{bean.download}"<br />
  public String download() {<br />
    final FacesContext facesContext = FacesContext.getCurrentInstance();<br />
    // XXX create temp. filecontent ... resultFile<br />
    writeOutContent(getServletResponse(), new File(this.resultFile), "file.xml");<br />
    facesContext.responseComplete();<br />
    // dont use jsf-navigation-rules<br />
    return null;<br />
  }</p>
<p>  void writeOutContent(final HttpServletResponse res, final File content, final String theFilename) {<br />
    if (content == null)<br />
      return;<br />
    try {<br />
      res.setHeader("Pragma", "no-cache");<br />
      res.setDateHeader("Expires", 0);<br />
      res.setContentType("text/xml");<br />
      res.setHeader("Content-disposition", "attachment; filename=" + theFilename);<br />
      fastChannelCopy(Channels.newChannel(new FileInputStream(content)), Channels.newChannel(res.getOutputStream()));<br />
    } catch (final IOException e) {<br />
    }<br />
  }</p>
<p>  void fastChannelCopy(final ReadableByteChannel src, final WritableByteChannel dest) throws IOException {<br />
    final ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024);<br />
    while (src.read(buffer) != -1) {<br />
      buffer.flip();<br />
      dest.write(buffer);<br />
      buffer.compact();<br />
    }<br />
    buffer.flip();<br />
    while (buffer.hasRemaining()){<br />
      dest.write(buffer);<br />
    }<br />
  }<br />
}[/sourcecode]<br />
Now the facelets snipplets:   Not Working - Javascript Error :-(<br />
[sourcecode language='html']<br />
<h:form><br />
 <h:commandLink actionListener="#{command.execute}" value="Download"/><br />
 <h:commandLink action="#{command.download}" value="Download"/><br />
</h:form> </p>
<p>[/sourcecode]<br />
Not Working - Download is shown in the current page - the ajax page will replaced with the download-content :-(<br />
[sourcecode language='html']</p>
<p><a4j:form><br />
 <a4j:commandLink actionListener="#{command.execute}" value="Download"/><br />
 <a4j:commandLink action="#{command.download}" value="Download"/><br />
</a4j:form>[/sourcecode]Working :-)</p>
<p>[sourcecode language='html']<br />
<a4j:form><br />
 <a4j:htmlCommandLink actionListener="#{command.execute}" value="Download"/><br />
 <a4j:htmlCommandLink action="#{command.download}" value="Download"/><br />
</a4j:form><br />
[/sourcecode] [sourcecode language='html']<br />
<h:form><br />
 <a4j:htmlCommandLink actionListener="#{command.execute}" value="Download"/><br />
 <a4j:htmlCommandLink action="#{command.download}" value="Download"/><br />
</h:form><br />
[/sourcecode]</p>
<pre></pre>
<p>The a4j:htmlCommandLink was made for this szenario.</p>
<p>Notice: the fast channel copy routine was introduced by <a href="http://thomaswabner.wordpress.com/2007/10/09/fast-stream-copy-using-javanio-channels/">waffel</a><a href="http://thomaswabner.wordpress.com/2007/10/09/fast-stream-copy-using-javanio-channels/">.</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF behind reverse proxy]]></title>
<link>http://ahoehma.wordpress.com/?p=13</link>
<pubDate>Fri, 07 Mar 2008 09:09:56 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/?p=13</guid>
<description><![CDATA[The problem &#8220;try to run a jsf application behind a reverse proxy&#8221; it will not work if yo]]></description>
<content:encoded><![CDATA[<p>The problem "try to run a jsf application behind a reverse proxy" it will not work if you change the context-path.</p>
<p>Imagine a local deployed jsf application "hello-world.war". You can start browsing at http://localhost:8080/hello-word/. The browser handles the absolute paths for css and javascript-libs correctly and all forms will work. Remeber that all resource-urls converted to a "contex-absolut-url" by the jsf-framework.</p>
<p>If you open <span style="font-style:italic;">http://localhost:8080/hello-world/index.jsf</span> the the client html will contains resources like this: <span class="attribute-value"></span></p>
<p>&#60;<span class="start-tag">link</span><span class="attribute-name"> rel</span>=<span class="attribute-value">'stylesheet'  </span><span class="attribute-name">type</span>=<span class="attribute-value">'text/css'</span><span class="attribute-name"><br />
href</span>='<span class="attribute-value">/hello-world/a4j_3_1_3.GAcss/tabPanel.xcss/DATB/eAGTWzQ.BgAD.AG8.jsf'&#62;<br />
</span>&#60;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">'text/javascript' </span><span class="attribute-name">src</span>=<span class="attribute-value">'/hello-world/a4j_3_1_3.GAorg.ajax4jsf.javascript.PrototypeScript.jsf'</span>&#62;<br />
&#60;<span class="start-tag">form</span><span class="attribute-name"> id</span>=<span class="attribute-value">"j_id14" </span><span class="attribute-name">name</span>=<span class="attribute-value">"j_id14" </span><span class="attribute-name">method</span>=<span class="attribute-value">"post" </span><span class="attribute-name">action</span>=<span class="attribute-value">"/hello-world/index.jsf"&#62;<br />
</span><br />
(Note: I use richfaces 3.1.4 in the example)</p>
<p>The browser will append each absolute url (starting with '/')  to the host to make the request. And here is the problem if you want to use this jsf-application behind a reverse proxy. Then all absolute URLs pointing to a wrong resource and nothing will work.  To try this you can install a local apache web server the following to the httpd.conf:</p>
<p>Listen 9090<br />
ProxyRequests On<br />
ProxyPreserveHost On<br />
ProxyVia full<br />
ProxyPass /external-path/hello-world http://localhost:8080/hello-world/</p>
<p>(This will start the apache at localhost:9090 to avoid port-conflicts)</p>
<p>If you open <span style="font-style:italic;">http://localhost:9090/external-path/hello-world/index.jsf</span> the the client html contains the same absolute urls and the browser try to load these resource from the "wrong server": http://localhost:9090/hello-world/. If you imagine a real world szenario then the reverse proxy will use a "real world domain" and the urls looks like this <i>http://www.mycompany.de/external-path/hello-world</i>/.</p>
<p>So whats the solution for this? I try my own ViewHandler to convert absolute to relative urls.  Two things must be done:</p>
<p>1. Implement the ViewHandler</p>
<p>2. Register the ViewHandler</p>
<p>First the code ... we extend <i>javax.faces.application.ViewHandler</i> and overwrite the two methods <i>getActionURL </i>and <i>getResourceURL</i>.</p>
<pre><span style="color:#000000;font-weight:bold;">package</span> de.<span style="color:#006600;">ahoehma</span>.<span style="color:#006600;">jsf</span>;

<span style="color:#000000;font-weight:bold;">public</span> <span style="color:#000000;font-weight:bold;">class</span> ReverseProxyViewHandler <span style="color:#000000;font-weight:bold;">extends</span> ViewHandler <span style="color:#66cc66;">{</span>

 @Override
 <span style="color:#000000;font-weight:bold;">public</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> getActionURL<span style="color:#66cc66;">(</span><span style="color:#000000;font-weight:bold;">final</span> FacesContext context, <span style="color:#000000;font-weight:bold;">final</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> viewId<span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
  <span style="color:#000000;font-weight:bold;">return</span> getRelativeURL<span style="color:#66cc66;">(</span>context, <span style="color:#000000;font-weight:bold;">this</span>.<span style="color:#006600;">defaultHandler</span>.<span style="color:#006600;">getActionURL</span><span style="color:#66cc66;">(</span>context, viewId<span style="color:#66cc66;">)</span><span style="color:#66cc66;">)</span>;
 <span style="color:#66cc66;">}</span>

 @Override
 <span style="color:#000000;font-weight:bold;">public</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> getResourceURL<span style="color:#66cc66;">(</span><span style="color:#000000;font-weight:bold;">final</span> FacesContext context, <span style="color:#000000;font-weight:bold;">final</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> path<span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
  <span style="color:#000000;font-weight:bold;">return</span> getRelativeURL<span style="color:#66cc66;">(</span>context, <span style="color:#000000;font-weight:bold;">this</span>.<span style="color:#006600;">defaultHandler</span>.<span style="color:#006600;">getResourceURL</span><span style="color:#66cc66;">(</span>context, path<span style="color:#66cc66;">)</span><span style="color:#66cc66;">)</span>;
 <span style="color:#66cc66;">}</span>

 <span style="color:#808080;font-style:italic;">/**
  * Transform the given URL to a relative URL &#60;b&#62;in the context of the current
  * faces request&#60;/b&#62;. If the given URL is not absolute do nothing and return
  * the given url. The returned relative URL is "equal" to the original url but
  * will not start with a '/'. So the browser can request the "same" resource
  * but in a relative way and this is important behind reverse proxies!
  *
  * @param context
  * @param theURL
  * @return
  */</span>
 <span style="color:#000000;font-weight:bold;">private</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> getRelativeURL<span style="color:#66cc66;">(</span><span style="color:#000000;font-weight:bold;">final</span> FacesContext context, <span style="color:#000000;font-weight:bold;">final</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> theURL<span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
  <span style="color:#000000;font-weight:bold;">final</span> HttpServletRequest request = <span style="color:#66cc66;">(</span><span style="color:#66cc66;">(</span>HttpServletRequest<span style="color:#66cc66;">)</span> context.<span style="color:#006600;">getExternalContext</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>.<span style="color:#006600;">getRequest</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span><span style="color:#66cc66;">)</span>;
  <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> result = theURL;
  <span style="color:#b1b100;">if</span> <span style="color:#66cc66;">(</span>theURL.<span style="color:#006600;">startsWith</span><span style="color:#66cc66;">(</span><span style="color:#ff0000;">"/"</span><span style="color:#66cc66;">)</span><span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
   <span style="color:#993333;">int</span> subpath = StringUtils.<span style="color:#006600;">countMatches</span><span style="color:#66cc66;">(</span>getPath<span style="color:#66cc66;">(</span>request<span style="color:#66cc66;">)</span>, <span style="color:#ff0000;">"/"</span><span style="color:#66cc66;">)</span> - <span style="color:#cc66cc;">1</span>;
   <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> pathPrefix = <span style="color:#ff0000;">""</span>;
   <span style="color:#b1b100;">if</span> <span style="color:#66cc66;">(</span>subpath &#62; <span style="color:#cc66cc;">0</span><span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
    <span style="color:#b1b100;">while</span> <span style="color:#66cc66;">(</span>subpath &#62; <span style="color:#cc66cc;">0</span><span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
     pathPrefix += <span style="color:#ff0000;">"/.."</span>;
     subpath--;
    <span style="color:#66cc66;">}</span>
    pathPrefix = StringUtils.<span style="color:#006600;">removeStart</span><span style="color:#66cc66;">(</span>pathPrefix, <span style="color:#ff0000;">"/"</span><span style="color:#66cc66;">)</span>;
   <span style="color:#66cc66;">}</span>
   result = pathPrefix + result;
  <span style="color:#66cc66;">}</span>
  <span style="color:#000000;font-weight:bold;">return</span> result;
 <span style="color:#66cc66;">}</span>

 <span style="color:#808080;font-style:italic;">/**
  * Get the url-path from the given request.
  *
  * @param request
  * @return clean path
  */</span>
 <span style="color:#000000;font-weight:bold;">private</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> getPath<span style="color:#66cc66;">(</span><span style="color:#000000;font-weight:bold;">final</span> HttpServletRequest request<span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
  <span style="color:#000000;font-weight:bold;">try</span> <span style="color:#66cc66;">{</span>
   <span style="color:#808080;font-style:italic;">// TODO handle more than two '/'</span>
   <span style="color:#000000;font-weight:bold;">return</span> StringUtils.<span style="color:#006600;">replace</span><span style="color:#66cc66;">(</span><span style="color:#000000;font-weight:bold;">new</span> URI<span style="color:#66cc66;">(</span>request.<span style="color:#006600;">getRequestURI</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span><span style="color:#66cc66;">)</span>.<span style="color:#006600;">getPath</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>, <span style="color:#ff0000;">"//"</span>, <span style="color:#ff0000;">"/"</span><span style="color:#66cc66;">)</span>;
  <span style="color:#66cc66;">}</span> <span style="color:#000000;font-weight:bold;">catch</span> <span style="color:#66cc66;">(</span><span style="color:#000000;font-weight:bold;">final</span> URISyntaxException e<span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
  <span style="color:#808080;font-style:italic;">// XXX URISyntaxException ignored</span>
  <span style="color:#000000;font-weight:bold;">return</span> StringUtils.<span style="color:#006600;">EMPTY</span>;
  <span style="color:#66cc66;">}</span>
 <span style="color:#66cc66;">}</span>
<span style="color:#66cc66;">}</span></pre>
<p>The absolute2relative-algorithm prepends for each "/" in the current request-url a "../" to the resource/action-url ... thats all :D</p>
<p>And last register the view-handler. If you use  A4J you have to add this to your web.xml:</p>
<p>&#60;context-param&#62;<br />
&#60;param-name&#62;org.ajax4jsf.VIEW_HANDLERS&#60;/param-name&#62;<br />
&#60;param-value&#62;de.ahoehma.jsf.ReverseProxyViewHandler&#60;/param-value&#62;<br />
&#60;/context-param&#62;</p>
<p>That's all :D</p>
<p>Now if you open <span style="font-style:italic;">http://localhost:9090/external-path/hello-world/index.jsf</span> the client html contains only relative urls:</p>
<p>&#60;<span class="start-tag">link</span><span class="attribute-name"> rel</span>=<span class="attribute-value">'stylesheet'  </span><span class="attribute-name">type</span>=<span class="attribute-value">'text/css'</span><span class="attribute-name"><br />
href</span>='<span class="attribute-value">../hello-world/a4j_3_1_3.GAcss/tabPanel.xcss/DATB/eAGTWzQ.BgAD.AG8.jsf'&#62;<br />
</span>&#60;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">'text/javascript' </span><span class="attribute-name">src</span>=<span class="attribute-value">'../hello-world/a4j_3_1_3.GAorg.ajax4jsf.javascript.PrototypeScript.jsf'</span>&#62;<br />
&#60;<span class="start-tag">form</span><span class="attribute-name"> id</span>=<span class="attribute-value">"j_id14" </span><span class="attribute-name">name</span>=<span class="attribute-value">"j_id14" </span><span class="attribute-name">method</span>=<span class="attribute-value">"post" </span><span class="attribute-name">action</span>=<span class="attribute-value">"../hello-world/index.jsf"&#62;<br />
</span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[AJAX Magic With JSF DataTables in Seam 2.0]]></title>
<link>http://edemmorny.wordpress.com/?p=41</link>
<pubDate>Tue, 04 Mar 2008 09:03:21 +0000</pubDate>
<dc:creator>Edem Morny</dc:creator>
<guid>http://edemmorny.wordpress.com/?p=41</guid>
<description><![CDATA[&lt;Seam 2.0 on Tomcat &#8230; | Seam Portlet Bridge Released &gt;
RichFaces 3.1.3.GA came with a so]]></description>
<content:encoded><![CDATA[<p><a href="http://edemmorny.wordpress.com/2008/02/02/setup-of-seam-20-applications-for-tomcat-60/">&#60;Seam 2.0 on Tomcat ...</a> &#124; <a href="http://edemmorny.wordpress.com/2008/03/04/seam-jboss-portlet-bridge-realeased/">Seam Portlet Bridge Released &#62;</a><br />
RichFaces 3.1.3.GA came with a some new controls, and the &#60;rich:listShuttle/&#62; was of some interest to me. However, for a particular use case I found it not sufficient for my needs, and had to roll out my own version of it with a little bit of Ajax to add.</p>
<p class="MsoNormal">Let me use this simple scenario to display what I needed to do. Assuming you were keeping a shopping cart. After users select an item they want to buy, you want them to specify the quantity of that item following which their total charge is calculated for them on the fly. This I thought of doing using two DataTables just like the &#60;rich:listShuttle/&#62; appears but on a sleeker (or is it cruder?) level.</p>
<p class="MsoNormal">I defined an interface with a simple set of methods which I felt would do the trick called InPlaceEditing.</p>
<p class="MsoNormal">public interface InPlaceEditing {</p>
<p class="MsoNormal"><span>    </span>void editSelection();</p>
<p class="MsoNormal"><span>    </span>void addSelection();</p>
<p class="MsoNormal"><span>    </span>void removeSelection();</p>
<p class="MsoNormal"><span>    </span>void cancelSelection();</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal">Here is my”shopper” Seam component which implements the interface. Notice the use of 2 DataModels “products” and “selectedItems” and their corresponding DataModelSelections. This is to enable me select from one table to another.</p>
<p class="MsoNormal">@Name("shopper")</p>
<p class="MsoNormal">@Scope(ScopeType.CONVERSATION)</p>
<p class="MsoNormal">public class Shopper implements java.io.Serializable, InPlaceEditing {</p>
<p class="MsoNormal"><span>    </span>private boolean edit;</p>
<p class="MsoNormal"><span>    </span>@In</p>
<p class="MsoNormal"><span>    </span>EntityManager entityManager;</p>
<p class="MsoNormal"><span>    </span>@In</p>
<p class="MsoNormal"><span>    </span>FacesMessages facesMessages;</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>    </span>@DataModel</p>
<p class="MsoNormal"><span>    </span>List&#60;Product&#62; products;</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>    </span>@DataModelSelection("products")</p>
<p class="MsoNormal"><span>    </span>private Product product;</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>    </span>@DataModel</p>
<p class="MsoNormal"><span>    </span>private List&#60;CartItem&#62; selectedItems;</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>    </span>@DataModelSelection("selectedItems")</p>
<p class="MsoNormal"><span>    </span>private CartItem selectedItem;</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>    </span>@Out(required = false)</p>
<p class="MsoNormal"><span>    </span>private CartItem cartItem;</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>    </span>private BigDecimal total = new BigDecimal(0.0);</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>    </span>private static int count = 0;</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>    </span>@Begin(flushMode=FlushModeType.MANUAL)</p>
<p class="MsoNormal"><span>    </span>public void beginShopping() {</p>
<p class="MsoNormal"><span>        </span>products = entityManager.createQuery("Select p from Product p").getResultList();</p>
<p class="MsoNormal"><span>        </span>selectedItems = new ArrayList&#60;CartItem&#62;();</p>
<p class="MsoNormal"><span>    </span>}</p>
<p class="MsoNormal">The beginShopping() method starts a conversation and FlushMode is set to MANUAL. This means that all changes made to entities will be made persistent only if I call flush() on entityManager. Seam defaults to AUTO which means all changes to all managed entities are merged into the persistence context after every Seam action call. Trust me, for the purposes of this trick, you DON'T want automatic persistence context merging! Anyway this action populates the “products” DataModel with products already entered into the database. The result is the table below.</p>
<p class="MsoNormal">&#60;a:outputPanel id="productPanel"&#62;</p>
<p class="MsoNormal"><span>                    </span>&#60;rich:dataTable value="#{products}" var="product"&#62;</p>
<p class="MsoNormal"><span>                        </span>&#60;h:column&#62;</p>
<p class="MsoNormal"><span>                            </span>&#60;f:facet name="header"&#62;Product&#60;/f:facet&#62;</p>
<p class="MsoNormal"><span>                 </span><span>           </span>&#60;a:commandLink value="#{product.name}" actionListener="#{shopper.editSelection}" reRender="editPanel"/&#62;</p>
<p class="MsoNormal"><span>                        </span>&#60;/h:column&#62;</p>
<p class="MsoNormal"><span>                        </span>&#60;h:column&#62;</p>
<p class="MsoNormal"><span>                            </span>&#60;f:facet name="header"&#62;Price&#60;/f:facet&#62;</p>
<p class="MsoNormal"><span>  </span><span>                          </span>#{product.price}</p>
<p class="MsoNormal"><span>                        </span>&#60;/h:column&#62;<span>                    </span></p>
<p class="MsoNormal"><span>                        </span>&#60;h:column&#62;</p>
<p class="MsoNormal"><span>                            </span>&#60;f:facet name="header"&#62;Stock&#60;/f:facet&#62;</p>
<p class="MsoNormal"><span>                            </span>#{product.stock}</p>
<p class="MsoNormal"><span>          </span><span>              </span>&#60;/h:column&#62;</p>
<p class="MsoNormal"><span>                    </span>&#60;/rich:dataTable&#62;</p>
<p class="MsoNormal"><span>                </span>&#60;/a:outputPanel&#62;</p>
<p class="MsoNormal"> <a href="http://edemmorny.wordpress.com/files/2008/03/shopping_product_edit.jpg" title="Displayed editing panel"><img src="http://edemmorny.wordpress.com/files/2008/03/shopping_product_edit.thumbnail.jpg" alt="Displayed editing panel" /></a></p>
<p class="MsoNormal">A look at the section of the shop.xhtml facelet shows an &#60;a:commandLink/&#62; - an Ajaxified version of the &#60;h:commandButon/&#62;. This supplies our “shopper” component with the selected product through the “product” data model selection through Ajax. Also take note of the “reRender” and &#60;a:outputPanel/&#62; tags, which specify which areas of our page should be Ajax refreshed after certain actions are called.<span>  </span>In the editSelection() action a new CartItem (a join entity between a product and a shopping cart) containing the selected product is created and outjected.</p>
<p class="MsoNormal"><span> </span>public void editSelection() {</p>
<p class="MsoNormal"><span>        </span>if (edit == false) {</p>
<p class="MsoNormal"><span>            </span>cartItem = new CartItem();</p>
<p class="MsoNormal"><span>          </span><span>  </span>cartItem.setId(count++);</p>
<p class="MsoNormal"><span>            </span>cartItem.setProduct(product);</p>
<p class="MsoNormal"><span>            </span>cartItem.setSelected(true);</p>
<p class="MsoNormal"><span>            </span>return;</p>
<p class="MsoNormal"><span>        </span>}</p>
<p class="MsoNormal"><span>        </span>cartItem = selectedItem;</p>
<p class="MsoNormal"><span>        </span>cartItem.setSelected(true);</p>
<p class="MsoNormal"><span>        </span>edit = true;</p>
<p class="MsoNormal"><span>    </span>}</p>
<p class="MsoNormal">I want to use the same action to represent selecting a new product (from “products”) and editing an already existing CartItem (from “selectedItems”). This is achieved with a private “edit” boolan field, which by default is false.<span>  </span>Also since proper behaviour of DataModel and DataModelSelections depends on a properly implemented equals() method (i.e. instance uniqueness) I assigned artificial ids with the static “count” to each CartItem. Note that without setting flushMode to MANUAL, doing this will cause exceptions to be thrown down the lane somewhere. Finally setting the CartItem's “selected” field to true enables the rendering of the panel in which the quantity of that product will be entered.</p>
<p class="MsoNormal"> <a href="http://edemmorny.wordpress.com/files/2008/03/shopping_product_edit.jpg" title="Displayed editing panel"><img src="http://edemmorny.wordpress.com/files/2008/03/shopping_product_edit.thumbnail.jpg" alt="Displayed editing panel" /></a></p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><a href="http://edemmorny.wordpress.com/files/2008/03/shopping_product1_edit.jpg" title="DataTable with configured product"><img src="http://edemmorny.wordpress.com/files/2008/03/shopping_product1_edit.thumbnail.jpg" alt="DataTable with configured product" /></a></p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal">Once the quantity is specified, the addSelection() action is called. Because of the boolean “edit” we are able to determine if this is a new product selection or one from the existing list and respond appropriately, calculating the total cost of the users purchases so far and modifying the corresponding DataModels appropriately. In the case of an edit, the old computed cost of a product is deducted from the total, and re-computed and added to the total. To guarantee that the change in costs will reflect properly, the edited “cartItem” is removed and re-inserted in to the “selectedItems” DataModel.</p>
<p class="MsoNormal">It is also very easy to remove an already configured CartItem, again with the combination of &#60;a:commandLink/&#62; and the “selectedItem” DataModelSelection.</p>
<p class="MsoNormal">public void removeSelection() {<span>    </span></p>
<p class="MsoNormal"><span>        </span>total.subtract(selectedItem.getCost());</p>
<p class="MsoNormal"><span>      </span><span>  </span>selectedItems.remove(selectedItem);</p>
<p class="MsoNormal"><span>    </span>}</p>
<p class="MsoNormal">Finally, the user may save their selection. This involves the creation of a new Cart object, which is persisted to get an ID and associated with the CartItems in the “selectedItems” DataModel. Note here that the fake Ids I generated for the CartItems will cause maximum trouble in the database, and so I set them to null to force the persistence context to generate proper Ids for them. Don't forget the all important “entityManager.flush()” to make all changes permanent.</p>
<p class="MsoNormal"> <a href="http://edemmorny.wordpress.com/files/2008/03/shopping_product3_edit.jpg" title="Completed Shopping"><img src="http://edemmorny.wordpress.com/files/2008/03/shopping_product3_edit.thumbnail.jpg" alt="Completed Shopping" /></a></p>
<p class="MsoNormal">Finally I raise an<span>  </span>event (“shopper.events.CartEdit”) which is being observed by the “shopList” Seam<span>  </span>component's list() action causing the “carts” DataModel to be refreshed with fresh data.</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>    </span>@Factory("carts")</p>
<p class="MsoNormal"><span>    </span>@Observer("shopper.events.CartEdited")</p>
<p class="MsoNormal"><span>    </span>public void list(){</p>
<p class="MsoNormal"><span>        </span>Contexts.getSessionContext().set("carts", null);</p>
<p class="MsoNormal"><span>        </span>carts = entityManager.createQuery("Select c from Cart c").getResultList();<span>        </span></p>
<p class="MsoNormal"><span>    </span>}</p>
<p class="MsoNormal"> <a href="http://edemmorny.wordpress.com/files/2008/03/home2_edit.jpg" title="Carts DataTable displaying products selected"><img src="http://edemmorny.wordpress.com/files/2008/03/home2_edit.thumbnail.jpg" alt="Carts DataTable displaying products selected" /></a></p>
<p class="MsoNormal">The Job Is Done. This is use of Ajax and DataTables is quite simplistic, but I've used it in some really tight corners for some advance stuff. One scenario that I can see with this example is the requirement to remove a product from the list of products once selected and configured, or to put it back once it has been removed from the configured ones. Another will be how to edit an already persisted cart to remove or add products to that cart. I've just laid the foundation. With some tricks of your own, you should be able to achieve some serious magic.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[richFaces tutorial]]></title>
<link>http://sidslog.wordpress.com/?p=3</link>
<pubDate>Sun, 02 Mar 2008 18:26:43 +0000</pubDate>
<dc:creator>sidslog</dc:creator>
<guid>http://sidslog.wordpress.com/?p=3</guid>
<description><![CDATA[http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html/inde]]></description>
<content:encoded><![CDATA[<p>http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html/index.html</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Fileupload mit Richfaces ]]></title>
<link>http://ahoehma.wordpress.com/2008/01/17/fileupload-mit-richfaces/</link>
<pubDate>Thu, 17 Jan 2008 17:59:27 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/2008/01/17/fileupload-mit-richfaces/</guid>
<description><![CDATA[This article shows the usage of a tomahawk-fileupload with richfaces and facelets. The result is a u]]></description>
<content:encoded><![CDATA[<p>This article shows the usage of a tomahawk-fileupload with richfaces and facelets. The result is a upload-formular where the upload-button is disabled until the user select a file. All this can be done without any line self hacked javascript-code :)</p>
<p>The upload-button depends on a bean-property 'uploadedFilename' which is sync via AJAX.</p>
<p>So it is possible to enabled the upload-button before the file is really uploaded to the server.<br />
We have a jsf-bean:</p>
<pre><span style="color:#000000;font-weight:bold;">public</span> <span style="color:#000000;font-weight:bold;">class</span> FileUploadBean  <span style="color:#66cc66;">{</span>

  <span style="color:#000000;font-weight:bold;">private</span> UploadedFile uploadedFile;
  <span style="color:#000000;font-weight:bold;">private</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AString+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">String</span></a> uploadedFilename;

  <span style="color:#808080;font-style:italic;">// ... setter and getter ...</span>

  <span style="color:#000000;font-weight:bold;">public</span> <span style="color:#993333;">void</span> uploadFile<span style="color:#66cc66;">(</span><span style="color:#000000;font-weight:bold;">final</span> <a href="http://www.google.com/search?hl=en&#38;q=allinurl%3AActionEvent+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#aaaadd;font-weight:bold;">ActionEvent</span></a> event<span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
    <span style="color:#b1b100;">if</span> <span style="color:#66cc66;">(</span><span style="color:#000000;font-weight:bold;">null</span> != <span style="color:#000000;font-weight:bold;">this</span>.<span style="color:#006600;">uploadedFile</span><span style="color:#66cc66;">)</span> <span style="color:#66cc66;">{</span>
      LOG.<span style="color:#006600;">debug</span><span style="color:#66cc66;">(</span><span style="color:#ff0000;">"file-size '"</span>+<span style="color:#000000;font-weight:bold;">this</span>.<span style="color:#006600;">uploadedFile</span>.<span style="color:#006600;">getSize</span><span style="color:#66cc66;">(</span><span style="color:#66cc66;">)</span>+<span style="color:#ff0000;">"'"</span><span style="color:#66cc66;">)</span>;
    <span style="color:#66cc66;">}</span>
  <span style="color:#66cc66;">}</span>
<span style="color:#66cc66;">}</span></pre>
<p>and the facelets-page:</p>
<pre><span style="color:#009900;">&#60;ui:component
  xmlns:h=<span style="color:#ff0000;">"http://java.sun.com/jsf/html"</span>
  xmlns:c=<span style="color:#ff0000;">"http://java.sun.com/jstl/core"</span>
  xmlns:ui=<span style="color:#ff0000;">"http://java.sun.com/jsf/facelets"</span>
  xmlns:rich=<span style="color:#ff0000;">"http://richfaces.org/rich"</span>
  xmlns:t=<span style="color:#ff0000;">"http://myfaces.apache.org/tomahawk"</span>
  xmlns:a4j=<span style="color:#ff0000;">"http://richfaces.org/a4j"</span><span style="color:#000000;font-weight:bold;">&#62;</span></span>

<span style="color:#009900;">&#60;c:set var=<span style="color:#ff0000;">"controlId"</span> <span style="color:#000066;">value</span>=<span style="color:#ff0000;">"controls"</span> /<span style="color:#000000;font-weight:bold;">&#62;</span></span>

<span style="color:#009900;">&#60;a4j:form&#62;</span>
  <span style="color:#009900;">&#60;a4j:jsFunction <span style="color:#000066;">name</span>=<span style="color:#ff0000;">"updateFilename"</span> reRender=<span style="color:#ff0000;">"#{controlId}"</span><span style="color:#000000;font-weight:bold;">&#62;</span></span>
   <span style="color:#009900;">&#60;a4j:actionparam <span style="color:#000066;">name</span>=<span style="color:#ff0000;">"filename"</span> assignTo=<span style="color:#ff0000;">"#{FileUploadBean.uploadedFilename}"</span> /<span style="color:#000000;font-weight:bold;">&#62;</span></span>
  <span style="color:#009900;"><span style="color:#000000;font-weight:bold;">&#60;</span>/a4j:jsFunction&#62;</span>
<span style="color:#009900;"><span style="color:#000000;font-weight:bold;">&#60;</span>/a4j:form&#62;</span>

<span style="color:#009900;">&#60;h:form <span style="color:#000066;">enctype</span>=<span style="color:#ff0000;">"multipart/form-data"</span><span style="color:#000000;font-weight:bold;">&#62;</span></span>
 <span style="color:#009900;">&#60;t:inputFileUpload <span style="color:#000066;">id</span>=<span style="color:#ff0000;">"fileupload"</span>
                    <span style="color:#000066;">size</span>=<span style="color:#ff0000;">"40"</span>
                    <span style="color:#000066;">value</span>=<span style="color:#ff0000;">"#{FileUploadBean.uploadedFile}"</span>
                    storage=<span style="color:#ff0000;">"file"</span>
                    required=<span style="color:#ff0000;">"true"</span>
                    <span style="color:#000066;">onchange</span>=<span style="color:#ff0000;">"updateFilename(this.value)"</span>/<span style="color:#000000;font-weight:bold;">&#62;</span></span>

 <span style="color:#009900;">&#60;h:panelGroup <span style="color:#000066;">id</span>=<span style="color:#ff0000;">"#{controlId}"</span><span style="color:#000000;font-weight:bold;">&#62;</span></span>
   <span style="color:#009900;">&#60;c:choose&#62;</span>
     <span style="color:#009900;">&#60;c:when test=<span style="color:#ff0000;">"#{!empty FileUploadBean.uploadedFilename}"</span><span style="color:#000000;font-weight:bold;">&#62;</span></span>
       <span style="color:#009900;"><span style="color:#808080;font-style:italic;">&#60;!-- User has selected a File - enable Upload-Control --&#62;</span></span>
       <span style="color:#009900;">&#60;h:commandLink <span style="color:#000066;">value</span>=<span style="color:#ff0000;">"Upload enabled ..."</span>
                      actionListener=<span style="color:#ff0000;">"#{FileUploadBean.uploadFile}"</span>/<span style="color:#000000;font-weight:bold;">&#62;</span></span>
     <span style="color:#009900;"><span style="color:#000000;font-weight:bold;">&#60;</span>/c:when&#62;</span>
     <span style="color:#009900;">&#60;c:otherwise&#62;</span>
       <span style="color:#009900;"><span style="color:#808080;font-style:italic;">&#60;!-- User doenst have selected a File - DISABLE Upload-Control --&#62;</span></span>
       <span style="color:#009900;">&#60;h:outputText <span style="color:#000066;">value</span>=<span style="color:#ff0000;">"Upload disabled"</span>/<span style="color:#000000;font-weight:bold;">&#62;</span></span>
     <span style="color:#009900;"><span style="color:#000000;font-weight:bold;">&#60;</span>/c:otherwise&#62;</span>
   <span style="color:#009900;"><span style="color:#000000;font-weight:bold;">&#60;</span>/c:choose&#62;</span>
 <span style="color:#009900;"><span style="color:#000000;font-weight:bold;">&#60;</span>/h:panelGroup&#62;</span>
<span style="color:#009900;"><span style="color:#000000;font-weight:bold;">&#60;</span>/h:form&#62;</span>

<span style="color:#009900;"><span style="color:#000000;font-weight:bold;"></span><span style="color:#000000;font-weight:bold;">&#60;</span>/ui:component&#62;</span></pre>
]]></content:encoded>
</item>

</channel>
</rss>
