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

<channel>
	<title>Maxa Blog &#187; JavaFX</title>
	<atom:link href="http://mkblog.exadel.com/category/ria/javafx-ria/feed/" rel="self" type="application/rss+xml" />
	<link>http://mkblog.exadel.com</link>
	<description>Just some random thoughts about technology, travel and anything else.</description>
	<lastBuildDate>Fri, 30 Jul 2010 20:45:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JavaFX&#8230; it does have a future</title>
		<link>http://mkblog.exadel.com/ria/javafx-ria/javafx-it-does-have-a-future/</link>
		<comments>http://mkblog.exadel.com/ria/javafx-ria/javafx-it-does-have-a-future/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 21:21:22 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=2110</guid>
		<description><![CDATA[In looking back at my JavaFX&#8230; does it have a future? posting, my views have been changed  by some of the comments made (here and here), in particular about JavaFX vs. Flash/Flex and Java Web Start. 
JavaFX and applets
I agree that comparing JavaFX applets vs Flash/Flex is not something we should be doing. Flash [...]]]></description>
			<content:encoded><![CDATA[<p>In looking back at my <a href="http://mkblog.exadel.com/ria/javafx-ria/javafx-does-it-have-a-future/#comments">JavaFX&#8230; does it have a future?</a> posting, my views have been changed  by some of the comments made (<a href="http://mkblog.exadel.com/ria/javafx-ria/javafx-does-it-have-a-future/#comments">here</a> and <a href="http://marxsoftware.blogspot.com/2010/07/how-much-time-to-spend-on-javafx-at.html#comments">here</a>), in particular about JavaFX vs. Flash/Flex and Java Web Start. </p>
<h3>JavaFX and applets</h3>
<p>I agree that comparing JavaFX applets vs Flash/Flex is not something we should be doing. Flash applications (deployed inside the browser in a Flash virtual machine) are years ahead of Java applets. It will take years, if at all, for applets to match Flash-like deployment. According to Adobe, Flash is already installed on 99% of Internet-enabled desktops. In case it’s not available,  installing Flash is a breeze (plus Google Chrome now ships with Flash player). Flash applications are installed very quickly, work, run smoothly inside the browser, and users are comfortable using such applications. </p>
<h3>JavaFX and Java Web Start</h3>
<p>On the other hand, deploying JavaFX applications via Java Web Start is an area where JavaFX could be successful and find a niche market.  </p>
<p>A JavaFX application started via Java Web Starts runs in its own “Java window” outside the browser. This way the application is still running inside the powerful Java virtual machine, so you get a rich and responsive user interface that is also now browser-independent.  </p>
<p>Launching via Java Web Start can be easily done by placing a link to a .jnlp file inside a Web page or even creating an icon on a desktop. Now we get the power of Java but outside the browser. However, the application still acts like a “Web application” since Java Web Start will check for any updates in the application and download them if necessary (like Adobe AIR). This way the user is always be running the latest version of the application.</p>
<p>For example, click <a href="http://demo.flamingo.exadel.com/booking/booking-fx.jsp">here</a> to launch JavaFX Seam Booking application via Java Web Start (note: the .jnlp file is generated in this case). Or click on this nice button:</p>
<p><a href="http://demo.flamingo.exadel.com/booking/booking-fx.jsp"><img src="http://mkblog.exadel.com/wp-content/uploads/2010/07/webstartsmall2.gif" alt="Launch" title="javawebstart" width="88" height="34" class="size-full wp-image-2112" style="padding:0px 0px 0px 0px"/></a></p>
<p>It launched pretty fast, has its own window, no browser freezing, pretty nice. </p>
<p>Although I don’t see many consumers-facing applications deployed using Java Web Start (even thought it’s possible and some might), the target market is enterprise applications (or Internet business applications) such as customer support applications, rich interactive dashboards, scientific applications, educational applications, and other Intranet-based applications. For example, just replacing all Swing deployments in the enterprise would give JavaFX a huge potential market opportunity. </p>
<h3>JavaFX and enterprise</h3>
<p>Connecting JavaFX Web Start applications to a server is easily done with the <a href="http://exadel.org/flamingo">Exadel Flamingo framework</a>. This framework was designed from the ground up to make it simpler to attach rich UIs like JavaFX to back ends like Seam.</p>
<p>Furthermore, a growing requirement is to make Web applications available offline or when there is no Internet connection available. As the platform for JavaFX is the Java virtual machine, the offline feature can be more easily implemented than if the browser were the platform. And, if using the Flamingo framework, it already includes offline features that enable the application to run without an Internet connection and synchronize with the server once the connection is reestablished. </p>
<h3>Future?</h3>
<p>I always believed before that running JavaFX applications inside the browser was the way to go. While it’s still possible (and easily done), I don’t believe that’s the way to go anymore. The browser is a platform; the Java virtual machine is another platform. There is no need to combine the two.</p>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/javafx-ria/javafx-it-does-have-a-future/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>New Exadel Flamingo 2.2.0 is now on exadel.org</title>
		<link>http://mkblog.exadel.com/ria/new-exadel-flamingo-2-2-0-is-now-on-exadel-org/</link>
		<comments>http://mkblog.exadel.com/ria/new-exadel-flamingo-2-2-0-is-now-on-exadel-org/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 22:00:06 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Flamingo]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=2061</guid>
		<description><![CDATA[After months of promising we have finally moved Exadel Flamingo to exadel.org and released version 2.2.0. exadel.org is our community site for hosting open source projects. Flamingo is a light weight framework for connecting rich web and mobile user interfaces to enterprise back end.  

Click on image to enlarge
Flamingo connects Seam, Spring, and Java [...]]]></description>
			<content:encoded><![CDATA[<p>After months of promising we have finally moved <a href="http://exadel.org/flamingo">Exadel Flamingo</a> to <a href="http://exadel.org">exadel.org</a> and released version 2.2.0. <a href="http://exadel.org">exadel.org</a> is our community site for hosting open source projects. Flamingo is a light weight framework for connecting rich web and mobile user interfaces to enterprise back end.  </p>
<p><a href="http://mkblog.exadel.com/wp-content/uploads/2010/07/flamingo-diagram.png"><img src="http://mkblog.exadel.com/wp-content/uploads/2010/07/flamingo-diagram-300x179.png" alt="" title="flamingo-diagram" width="300" height="179" class="alignleft size-medium wp-image-2062" /></a><br />
<em>Click on image to enlarge</em></p>
<p>Flamingo connects Seam, Spring, and Java EE 6 (soon via CDI/JSR299) with the following user interfaces:</p>
<ul style="padding:0em">
<li>JavaFX</li>
<li>Flash</li>
<li>iPhone/Android</li>
<li>Swing</li>
<li>JavaME</li>
</ul>
<p>Version 2.2.0 is updated with Hessian 4 and JavaFX 1.3 support.  </p>
<p>Server-side components, methods or services can be easily invoked from the above listed clients with minimal code.  Flamingo provides the following features:</p>
<ul style="padding:0em">
<li>CRUD tools</li>
<li>Server-side integration
<ul style="padding:0em">
<li>Calling server components/beans</li>
<li>Context variable binding/updating</li>
<li>Conversation support</li>
<li>Validation (Hibernate Validator)</li>
<li>EL support (Expression Language)</li>
</ul>
</li>
<li>Server-side push</li>
<li>Client push (off line applications)</li>
</ul>
<p><a href="http://mkblog.exadel.com/wp-content/uploads/2010/07/flamingo-diagram-details.png"><img src="http://mkblog.exadel.com/wp-content/uploads/2010/07/flamingo-diagram-details-300x179.png" alt="" title="flamingo-diagram-details" width="300" height="179" class="alignleft size-medium wp-image-2071" /></a><br />
<em>Click image to enlarge</em></p>
<p>As you can see from the image above, no matter what client you are using, invoking a method in your enterprise applications looks very similar which allows for great reuse. </p>
<p><strong>How to get started?</strong></p>
<ul style="padding:0em">
<li>Download Flamingo from <a href="http://exadel.org/flamingo">http://exadel.org/flamingo</a>. </li>
<li>The following are <a href="http://exadel.org/flamingo-docs">good resources</a> to get started or learn more about Flamingo. </li>
<li>Check out the recent <a href="http://mkblog.exadel.com/ria/javafx-ria/enterprise-javafx-with-seam-and-flamingo-complete-edition/">Enterprise JavaFX and Seam</a> series. This series shows most server integration features in separate post and easy to follow examples.</li>
<li>We want to hear your feedback, please use project <a href="http://jira.exadel.org/browse/EFL">Jira</a> or the <a href="http://exadel.org/forum/flamingo">forum</a> to report bugs or any features you would like to see. </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/new-exadel-flamingo-2-2-0-is-now-on-exadel-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enterprise JavaFX with Seam and Flamingo &#8211; complete edition</title>
		<link>http://mkblog.exadel.com/ria/javafx-ria/enterprise-javafx-with-seam-and-flamingo-complete-edition/</link>
		<comments>http://mkblog.exadel.com/ria/javafx-ria/enterprise-javafx-with-seam-and-flamingo-complete-edition/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 21:55:50 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Flamingo]]></category>
		<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=2028</guid>
		<description><![CDATA[I wrote a series of posts on how to connect JavaFX to a server running with Seam framework. Client-server communication is realized with the help of Flamingo framework. Here is the complete series: 

Calling Seam component from JavaFX
Invoking Hibernate Validator from JavaFX
Binding to server-side context variable from JavaFX
Using Expression Language (EL) in JavaFX to communicate [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a series of posts on how to connect JavaFX to a server running with Seam framework. Client-server communication is realized with the help of <a href="http://exadel.org/flamingo">Flamingo</a> framework. Here is the complete series: </p>
<ul style="padding:0em">
<li><a href="http://mkblog.exadel.com/ria/javafx-ria/calling-seam-component-from-javafx-2/">Calling Seam component from JavaFX</a></li>
<li><a href="http://mkblog.exadel.com/ria/javafx-ria/invoking-hibernate-validator-from-javafx/">Invoking Hibernate Validator from JavaFX</a></li>
<li><a href="http://mkblog.exadel.com/ria/javafx-ria/binding-to-server-side-context-variable-from-javafx/">Binding to server-side context variable from JavaFX</a></li>
<li><a href="http://mkblog.exadel.com/ria/javafx-ria/using-expression-language-el-in-javafx-to-communicate-with-server/">Using Expression Language (EL) in JavaFX to communicate with server</a></li>
<li><a href="http://mkblog.exadel.com/ria/javafx-ria/seam-conversation-from-javafx/">Seam conversations from JavaFX</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/javafx-ria/enterprise-javafx-with-seam-and-flamingo-complete-edition/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Exadel JavaFX Plug-in for Eclipse version 1.3.4 with Organize Imports</title>
		<link>http://mkblog.exadel.com/ria/javafx-ria/exadel-javafx-plug-in-for-eclipse-version-1-3-4-with-organize-imports/</link>
		<comments>http://mkblog.exadel.com/ria/javafx-ria/exadel-javafx-plug-in-for-eclipse-version-1-3-4-with-organize-imports/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 18:10:49 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[JavaFX plug-in]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=2054</guid>
		<description><![CDATA[Exadel has released Exadel JavaFX Plug-in for Eclipse version 1.3.4. The biggest feature in this release is Organize Imports (just like in Java editor). 
The class for Text node is missing, pressing Ctrl+Shift+O, will display the dialog where the correct class can be selected:

You can also invoke Organize Imports from the editor context menu (right-click [...]]]></description>
			<content:encoded><![CDATA[<p>Exadel has released <a href="http://exadel.org/javafxplugin">Exadel JavaFX Plug-in for Eclipse version 1.3.4</a>. The biggest feature in this release is Organize Imports (just like in Java editor). </p>
<p>The class for Text node is missing, pressing Ctrl+Shift+O, will display the dialog where the correct class can be selected:<br />
<img src="http://mkblog.exadel.com/wp-content/uploads/2010/07/screenshot_023.png" alt="" title="screenshot_023" width="606" height="346" class="alignleft size-full wp-image-2055" /></p>
<p>You can also invoke Organize Imports from the editor context menu (right-click anywhere in the editor and select Organize Imports). </p>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/javafx-ria/exadel-javafx-plug-in-for-eclipse-version-1-3-4-with-organize-imports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How much time to spend on JavaFX at JavaOne 2010?</title>
		<link>http://mkblog.exadel.com/ria/javafx-ria/how-much-time-to-spend-on-javafx-at-javaone-2010/</link>
		<comments>http://mkblog.exadel.com/ria/javafx-ria/how-much-time-to-spend-on-javafx-at-javaone-2010/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 16:24:10 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=2046</guid>
		<description><![CDATA[Dustin Marx references my post JavaFX&#8230; does it have a future? in his post on How much time to spend on JavaFX on JavaOne 2010?. 
]]></description>
			<content:encoded><![CDATA[<p><a href="http://marxsoftware.blogspot.com/">Dustin Marx</a> references my post <a href="http://mkblog.exadel.com/ria/javafx-ria/javafx-does-it-have-a-future/">JavaFX&#8230; does it have a future?</a> in his post on <a href="http://www.javaworld.com/community/?q=node/4742">How much time to spend on JavaFX on JavaOne 2010?</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/javafx-ria/how-much-time-to-spend-on-javafx-at-javaone-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaFX&#8230; does it have a future?</title>
		<link>http://mkblog.exadel.com/ria/javafx-ria/javafx-does-it-have-a-future/</link>
		<comments>http://mkblog.exadel.com/ria/javafx-ria/javafx-does-it-have-a-future/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 18:27:45 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=2032</guid>
		<description><![CDATA[I don’t know any other technology that has ever gotten as much of a beating as JavaFX did last week (here, here, and here). JavaFX has become a technology that developers love to hate. It’s like a pinata for developers. 
JavaFX was first announced at JavaOne 2007 (that’s 3 years ago). Many predicted its death [...]]]></description>
			<content:encoded><![CDATA[<p>I don’t know any other technology that has ever gotten as much of a beating as JavaFX did last week (<a href="http://www.google.com/url?q=http%3A%2F%2Fwww.pushing-pixels.org%2F%3Fp%3D2106&#038;sa=D&#038;sntz=1&#038;usg=AFQjCNHvUe-Sst2skzRWf0ry-lPiQWWqag">here</a>, <a href="http://www.google.com/url?q=http%3A%2F%2Fjava.dzone.com%2Fpolls%2Fhow-can-oracle-make-javafx&#038;sa=D&#038;sntz=1&#038;usg=AFQjCNHncea6LbfVvTPMWydgpuUDzfMQFw">here</a>, and <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.javaworld.com%2Fcommunity%2Fnode%2F4647&#038;sa=D&#038;sntz=1&#038;usg=AFQjCNH03WPrP-DZp4hv7TqtjES1VNKZYA">here</a>). JavaFX has become a technology that developers love to hate. It’s like a <a href="http://www.google.com/url?q=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FPi%25C3%25B1ata&#038;sa=D&#038;sntz=1&#038;usg=AFQjCNHo_KHffx-xzyUP3U-qfsVN3QBzwg">pinata</a> for developers. </p>
<p>JavaFX was first announced at JavaOne 2007 (that’s 3 years ago). Many predicted its death even before version 1.0 was released in December 2008, and many continue to call for its demise.</p>
<p>Last week also turned out to be the week where I presented <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.svjugfx.org%2Fcalendar%2F13605800%2F%3FeventId%3D13605800%26action%3Ddetail&#038;sa=D&#038;sntz=1&#038;usg=AFQjCNF1gZscJoAi7zPaeLCftypatW4AZw">Enterprise JavaFX</a> at the Silicon Valley JavaFX JUG, and also the week that Steven Chin created a petition to <a href="http://www.google.com/url?q=http%3A%2F%2Fsteveonjava.com%2Fpetition-to-open-source-javafx%2F&#038;sa=D&#038;sntz=1&#038;usg=AFQjCNEhOYy1YnD95DPf8Fv-TEyhNKXjJA">open source JavaFX</a>. </p>
<p>Don’t get me wrong, JavaFX is very far from perfect. It has it’s problems and challenges (listed below) and its future is hanging on life support right now, but let’s start with the good. </p>
<h3>The good stuff</h3>
<p>JavaFX Script is a very powerful language. In fact, it’s a DSL (Domain Specific Language) for creating rich user interfaces where the resulting application runs inside the Java virtual machine on the client. JavaFX Script might appear foreign at first (as probably any new programming language would) but after using it for a while you start realizing it’s power and ease of use. The JavaFX binding feature simplifies UI development even further by tracking model changes automatically. I have been working with JSF (JavaServer Faces) since its inception and I can tell you that using JavaFX Script to build the UI is probably simpler than using JSF. As JavaFX applications run inside the Java virtual machine which is very powerful, this allows us to build rather rich and sophisticated client applications. </p>
<h3>The ugly stuff</h3>
<p>As the mantra in real estate is: location, location, location. The mantra in JavaFX is: deployment, deployment, deployment. Unfortunately, this is where JavaFX has failed miserably. The original Java applets failed miserably in deployment and JavaFX (which was supposed to be the next applet technology or applets 2.0) has inherited the failed deployment with it. In other words, nothing has really changed since 1995. I don’t understand why Oracle (previously Sun) has allowed this to happen. I know that Oracle has some very smart people who could have fixed it a long time ago. </p>
<p>This is what happens most of the time. You click on a link to launch a JavaFX application as an applet inside the browser. Let’s assume that you already have the Java plug-in installed. The browser freezes for about 5 seconds. After the 5 or so seconds, you will see the a Java logo inside a dotted circle. The dotted circle is moving around as if to show the loading of the applet. The sad thing is that it’s just an animated GIF and doesn’t show the actual loading progress. Why is it so difficult to show some sort of progress status of the actual loading? </p>
<p>This is where it gets even more interesting. If you are lucky, you will see a rather scary security dialog (you have to click “yes”) and after that the application will appear.  If you are not lucky, you will continue seeing the moving image (with the Java logo inside) forever or until you close the browser window. Nothing else will happen. No error message. No reason why the applet was loaded. Nothing. If you want to know why the applet failed to load, you have to launch the Java plug-in console and look for the exception/error there. Launching the console is not easy either. Try to explain this to a non-developer. Good luck. It&#8217;s also not uncommon for an applet that worked just a second ago to stop working on the next run for unknown reasons.</p>
<p>What I described above is the main reason JavaFX has failed so far. Deployment is still a disaster. If Oracle needs to know how deployment should work, it’s very easy. Just look at Flash. Make it as simple and transparent as running a Flash application. That’s it.</p>
<h3>Do I have to learn a new language?</h3>
<p>Some people say they don’t like JavaFX because they need to learn a new language. Well that’s just a bunch of hot air. First of all, any decent Java developer can pick up JavaFX Script in about 2 days. And, second, no one is complaining that they have to learn a new language (or scripting language) when they use Flex or Ruby or Scala or even JSF. All require you to learn something new. If you are developer (any kind) today, you have to learn new stuff all the time. </p>
<h3>The stuff that&#8217;s getting better</h3>
<p>Look at any major Java conference for the past two years and you will see at least one session that covers JavaFX. Judging by the blogosphere and Twitter, the JavaFX community is growing.  People are posting examples, building custom components, and writing CSS tutorials. The developer community is there. People are trying JavaFX but no organization is building anything real world out there. A medal history application built with JavaFX was deployed during the <a href="http://www.vancouver2010.com/olympic-medals/geo-view/">2010 Winter Olympics in Vancouver</a> but I doubt many people remember it today. Just recently <a href="http://www.google.com/url?q=http%3A%2F%2Fwww.oracle.com%2Fus%2Fcorporate%2Fpress%2F103103&#038;sa=D&#038;sntz=1&#038;usg=AFQjCNGGU5Xr8wGtAN12oenjMTt26i2ZKQ">MLB.com deployed</a> a fantasy baseball application. That’s it. </p>
<p>The argument that JavaFX is missing tools that bridge the designer and developer is a valid one.<br />
JavaFX tooling is being developed. NetBeans has JavaFX Composer (a visual layout tool for building JavaFX applications). Exadel (my company) has been working on <a href="http://exadel.org/javafxplugin">Exadel JavaFX Plug-in for Eclipse</a>. Right now, our direction is to provide the most powerful source tools for JavaFX development. Also, IntelliJ just recently announced that it now offers <a href="http://www.google.com/url?q=http%3A%2F%2Fplugins.jetbrains.net%2Fplugin%2F%3Fidea%26id%3D5004&#038;sa=D&#038;sntz=1&#038;usg=AFQjCNHlUpwx85-F7eGeRpUQh6viy0e4wA">JavaFX support</a>.</p>
<p>The fact that JavaFX is missing many common controls is also a valid argument. New and more advanced controls are actually being developed by the Oracle JavaFX team. Furthermore, to help the community build 3rd-party components, JavaFX should be open sourced. </p>
<h3>JavaFX in the enterprise</h3>
<p>Enterprise applications such as rich and interactive dashboards and other rich graphical and content user interfaces are a very good candidates for using JavaFX. Enterprise JavaFX has been missing in action. Adobe and its community has done an excellent job demonstrating that Flex can be used to build real-world enterprise applications. The same needs to happen for JavaFX. To help enterprises adopt JavaFX, Exadel has made the <a href="http://www.exadel.com/web/portal/flamingo">Flamingo framework</a> available. Flamingo helps connect the JavaFX UI to enterprise back ends such as Java EE, Spring, and Seam. I personally tried to reach out to Sun and then Oracle on working together on enterprise JavaFX tooling, but, as you might have guessed, I never heard back. </p>
<h3>Future?</h3>
<p>There is still time to make JavaFX successful, but the time is running out. First, fix the deployment issue as soon as possible. Just start from scratch, don’t try to fix the current deployment system. Second, Oracle needs to make it very clear what its plans are for JavaFX (maybe at JavaOne 2010?). If Oracle doesn’t want or need JavaFX, then open source it and let the community drive it’s future.  I think Oracle has 6-12 months at the most to try and revive JavaFX. If nothing happens by then (which would be about 4 years since the technology was announced), we just might as well close the door on JavaFX. </p>
<p>My 2 cents.</p>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/javafx-ria/javafx-does-it-have-a-future/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Seam conversations from JavaFX</title>
		<link>http://mkblog.exadel.com/ria/javafx-ria/seam-conversation-from-javafx/</link>
		<comments>http://mkblog.exadel.com/ria/javafx-ria/seam-conversation-from-javafx/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 21:24:21 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Flamingo]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=1980</guid>
		<description><![CDATA[This post covers starting/stopping Seam conversations from JavaFX.  See other posts in this series:
Calling Seam component from JavaFX
Invoking Hibernate Validator from JavaFX
Binding to server-side context variable from JavaFX
Using Expression Language (EL) in JavaFX to communicate with server
Server side
Seam component:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@Name &#40;&#34;wizard&#34;&#41;
@Scope &#40;ScopeType.CONVERSATION&#41;
public class Wizard &#123;
   @In Conversation conversation;
&#160;
   public String info [...]]]></description>
			<content:encoded><![CDATA[<p>This post covers starting/stopping Seam conversations from JavaFX.  See other posts in this series:</p>
<p><a href="http://mkblog.exadel.com/ria/javafx-ria/calling-seam-component-from-javafx-2/" >Calling Seam component from JavaFX</a><br />
<a href="http://mkblog.exadel.com/ria/javafx-ria/invoking-hibernate-validator-from-javafx/" >Invoking Hibernate Validator from JavaFX</a><br />
<a href="http://mkblog.exadel.com/ria/javafx-ria/binding-to-server-side-context-variable-from-javafx/" >Binding to server-side context variable from JavaFX</a><br />
<a href="http://mkblog.exadel.com/ria/javafx-ria/using-expression-language-el-in-javafx-to-communicate-with-server/">Using Expression Language (EL) in JavaFX to communicate with server</a></p>
<h4>Server side</h4>
<p><strong>Seam component:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="java java" style="font-family:monospace;">@<span style="color: #003399;">Name</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wizard&quot;</span><span style="color: #009900;">&#41;</span>
@Scope <span style="color: #009900;">&#40;</span>ScopeType.<span style="color: #006633;">CONVERSATION</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Wizard <span style="color: #009900;">&#123;</span>
   @In Conversation conversation;
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> info <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Id: &quot;</span><span style="color: #339933;">+</span>conversation.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, active: &quot;</span><span style="color: #339933;">+</span>conversation.<span style="color: #006633;">isLongRunning</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;	   
   <span style="color: #009900;">&#125;</span>
   @Begin
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> start <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// do something	</span>
   <span style="color: #009900;">&#125;</span>
   @Conversational
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> nextStep <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Id: &quot;</span><span style="color: #339933;">+</span>conversation.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, active: &quot;</span><span style="color: #339933;">+</span>conversation.<span style="color: #006633;">isLongRunning</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
   @End
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> end <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
       <span style="color: #666666; font-style: italic;">// do something		</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Above is a pretty simple Seam component with conversation scope. It has method to start the conversation (@Begin) and end the conversation (@End). It also has nextStep() annotated with @Conversation, that means that the method can only be invoked within a long running conversation. </p>
<h4>Client side</h4>
<p><strong>Component interface:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> Wizard <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> end<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> start<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> nextStep <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> info <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>JavaFX script:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;">CookieHandler.<span style="color: #660066;">setDefault</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> CookieManager<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> CookiePolicy.<span style="color: #660066;">ACCEPT_ALL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
FXServiceFactory.<span style="color: #660066;">URL</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://localhost:8080/server-javafx/seam/resource/hessian/&quot;</span>;
<span style="color: #003366; font-weight: bold;">var</span> wizardService <span style="color: #339933;">=</span> WizardServiceFactory.<span style="color: #660066;">getWizardService</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
def red<span style="color: #339933;">:</span> RadialGradient <span style="color: #339933;">=</span> RadialGradient<span style="color: #009900;">&#123;</span>  
    centerX<span style="color: #339933;">:</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">,</span> centerY<span style="color: #339933;">:</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">,</span> radius<span style="color: #339933;">:</span> <span style="color: #CC0000;">12</span><span style="color: #339933;">,</span> proportional<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>   
    stops<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>  
    <span style="color: #000066;">Stop</span> <span style="color: #009900;">&#123;</span>offset<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.0</span> color<span style="color: #339933;">:</span> Color.<span style="color: #660066;">WHITE</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
    <span style="color: #000066;">Stop</span> <span style="color: #009900;">&#123;</span>offset<span style="color: #339933;">:</span> <span style="color: #CC0000;">1.0</span> color<span style="color: #339933;">:</span> Color.<span style="color: #660066;">RED</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span> 
def green<span style="color: #339933;">:</span> RadialGradient <span style="color: #339933;">=</span> RadialGradient<span style="color: #009900;">&#123;</span>  
    centerX<span style="color: #339933;">:</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">,</span> centerY<span style="color: #339933;">:</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">,</span> radius<span style="color: #339933;">:</span> <span style="color: #CC0000;">12</span><span style="color: #339933;">,</span> proportional<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>   
    stops<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>  
    <span style="color: #000066;">Stop</span> <span style="color: #009900;">&#123;</span>offset<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.0</span> color<span style="color: #339933;">:</span> Color.<span style="color: #660066;">WHITE</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
    <span style="color: #000066;">Stop</span> <span style="color: #009900;">&#123;</span>offset<span style="color: #339933;">:</span> <span style="color: #CC0000;">1.0</span> color<span style="color: #339933;">:</span> Color.<span style="color: #660066;">GREEN</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #003366; font-weight: bold;">var</span> light <span style="color: #339933;">=</span> Circle <span style="color: #009900;">&#123;</span>
    centerX<span style="color: #339933;">:</span> <span style="color: #CC0000;">10</span> centerY<span style="color: #339933;">:</span> <span style="color: #CC0000;">10</span> radius<span style="color: #339933;">:</span> <span style="color: #CC0000;">10</span> stroke<span style="color: #339933;">:</span> Color.<span style="color: #660066;">BLACK</span> 
    fill<span style="color: #339933;">:</span> bind <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>longRunning<span style="color: #009900;">&#41;</span> green <span style="color: #000066; font-weight: bold;">else</span> red    
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> infoButton<span style="color: #339933;">:</span>Button <span style="color: #339933;">=</span> Button <span style="color: #009900;">&#123;</span>
    text <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Info&quot;</span>
    style <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-fx-font-size: x-large&quot;</span>
    action<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> newInfo <span style="color: #339933;">=</span> wizardService.<span style="color: #660066;">info</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        insert newInfo into info;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> longRunningOnly<span style="color: #339933;">:</span>Button <span style="color: #339933;">=</span> Button <span style="color: #009900;">&#123;</span>
    text <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Only if active&quot;</span>
    style <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-fx-font-size: x-large&quot;</span>
    action<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> newInfo <span style="color: #339933;">=</span> wizardService.<span style="color: #660066;">nextStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            insert newInfo into info;
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>exception<span style="color: #339933;">:</span> Exception<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">Alert</span>.<span style="color: #660066;">inform</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Not active conversation&quot;</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> longRunning <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span>;
<span style="color: #003366; font-weight: bold;">var</span> convButton<span style="color: #339933;">:</span>Button <span style="color: #339933;">=</span> Button <span style="color: #009900;">&#123;</span>
    style <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-fx-font-size: x-large&quot;</span>
    text <span style="color: #339933;">:</span> bind 
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>longRunning<span style="color: #009900;">&#41;</span> <span style="color: #3366CC;">&quot;Stop&quot;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #3366CC;">&quot;Start&quot;</span>
    action<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>longRunning<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            wizardService.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            longRunning <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span>;
            <span style="color: #003366; font-weight: bold;">var</span> newInfo <span style="color: #339933;">=</span> wizardService.<span style="color: #660066;">info</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            insert newInfo into info;
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>longRunning<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            wizardService.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            longRunning <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span>;
            <span style="color: #003366; font-weight: bold;">var</span> newInfo <span style="color: #339933;">=</span> wizardService.<span style="color: #660066;">info</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            insert newInfo into info;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> info <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>wizardService.<span style="color: #660066;">info</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span>;
<span style="color: #003366; font-weight: bold;">var</span> list<span style="color: #339933;">:</span>VBox <span style="color: #339933;">=</span> VBox <span style="color: #009900;">&#123;</span>
    content<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        VBox <span style="color: #009900;">&#123;</span>
            content <span style="color: #339933;">:</span>  bind <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span> <span style="color: #000066; font-weight: bold;">in</span> info<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                Text <span style="color: #009900;">&#123;</span>
                    content<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">item</span>
                    style <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-fx-font-size: x-large&quot;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> 
Stage <span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Application&quot;</span>
    width<span style="color: #339933;">:</span> <span style="color: #CC0000;">450</span> height<span style="color: #339933;">:</span> <span style="color: #CC0000;">400</span>
    scene<span style="color: #339933;">:</span> Scene <span style="color: #009900;">&#123;</span>
        fill<span style="color: #339933;">:</span> LinearGradient <span style="color: #009900;">&#123;</span>
            endX<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.0</span>
            stops<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #000066;">Stop</span> <span style="color: #009900;">&#123;</span> offset<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.0</span> color<span style="color: #339933;">:</span> Color.<span style="color: #660066;">LIGHTGRAY</span> <span style="color: #009900;">&#125;</span>
            <span style="color: #000066;">Stop</span> <span style="color: #009900;">&#123;</span> offset<span style="color: #339933;">:</span> <span style="color: #CC0000;">1.0</span> color<span style="color: #339933;">:</span> Color.<span style="color: #660066;">GRAY</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> 
        VBox <span style="color: #009900;">&#123;</span>
            spacing <span style="color: #339933;">:</span> <span style="color: #CC0000;">4</span>
            content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            HBox <span style="color: #009900;">&#123;</span>
                spacing<span style="color: #339933;">:</span> <span style="color: #CC0000;">4</span>
                content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                infoButton<span style="color: #339933;">,</span> convButton<span style="color: #339933;">,</span> light<span style="color: #339933;">,</span> longRunningOnly
                <span style="color: #009900;">&#93;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
            list	
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>;</pre></td></tr></table></div>

<p><strong>Line 3:</strong> we get reference to WizardService and now can call all methods in the interface.<br />
<strong>Lines 23-30:</strong> info button which returns the current conversation status<br />
<strong>Lines 31-43:</strong> button that calls a method which should be called only when a long running conversation is active. If clicked outside of a long running conversation, an error dialog will be shown<br />
<strong>Lines 45-63:</strong> button that starts/stops the conversation</p>
<p>Notice that nothing special needs to be done when using conversations, it is just a simple c<a href="http://mkblog.exadel.com/ria/javafx-ria/calling-seam-component-from-javafx-2/">omponent method invocation</a>. </p>
<p><strong>No long running conversation:</strong><br />
<img src="http://mkblog.exadel.com/wp-content/uploads/2010/07/screenshot_021.png" alt="" title="screenshot_021" width="348" height="400" class="alignnone size-full wp-image-1990" /></p>
<p><strong>Long running conversation:</strong><br />
<img src="http://mkblog.exadel.com/wp-content/uploads/2010/07/screenshot_020.png" alt="" title="screenshot_020" width="348" height="400" class="alignnone size-full wp-image-1989" /></p>
<p><strong>Trying to invoke a method with @Conversation outside of a long running conversation:</strong><br />
<img src="http://mkblog.exadel.com/wp-content/uploads/2010/07/screenshot_022.png" alt="" title="screenshot_022" width="348" height="400" class="alignnone size-full wp-image-1991" /></p>
<p>That&#8217;s it. </p>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/javafx-ria/seam-conversation-from-javafx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Expression Language (EL) in JavaFX to communicate with server</title>
		<link>http://mkblog.exadel.com/ria/javafx-ria/using-expression-language-el-in-javafx-to-communicate-with-server/</link>
		<comments>http://mkblog.exadel.com/ria/javafx-ria/using-expression-language-el-in-javafx-to-communicate-with-server/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 17:39:22 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Flamingo]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=1955</guid>
		<description><![CDATA[This post shows how to use Expression Language (EL) from JavaFX to communicate with a server using Exadel Flamingo. See my previous posts on Enterprise JavaFX: calling Seam component from JavaFX, invoking Hibernate Validator from JavaFX, and binding to server-side context variable from JavaFX.
Seam component:

@Name &#40;&#34;helloAndTime&#34;&#41;
@Scope&#40;ScopeType.SESSION&#41;
public class HelloAndTime &#123;
&#160;
   private Date lastAccessTime;
&#160;
  [...]]]></description>
			<content:encoded><![CDATA[<p>This post shows how to use Expression Language (EL) from JavaFX to communicate with a server using <a href="http://exadel.com/web/portal/flamingo">Exadel Flamingo</a>. See my previous posts on Enterprise JavaFX: <a href="http://mkblog.exadel.com/ria/javafx-ria/calling-seam-component-from-javafx-2/">calling Seam component from JavaFX</a>,<a href="http://mkblog.exadel.com/ria/javafx-ria/invoking-hibernate-validator-from-javafx/"> invoking Hibernate Validator from JavaFX</a>, and <a href="http://mkblog.exadel.com/ria/javafx-ria/binding-to-server-side-context-variable-from-javafx/">binding to server-side context variable from JavaFX</a>.</p>
<p><strong>Seam component:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">@<span style="color: #003399;">Name</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;helloAndTime&quot;</span><span style="color: #009900;">&#41;</span>
@Scope<span style="color: #009900;">&#40;</span>ScopeType.<span style="color: #006633;">SESSION</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloAndTime <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Date</span> lastAccessTime;
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Date</span> getCurrentTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	lastAccessTime <span style="color: #339933;">=</span> getCurrentTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Hello &quot;</span> <span style="color: #339933;">+</span> name;
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Date</span> getLastAccessTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">return</span> lastAccessTime;
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>JavaFX script:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;">def expressionService<span style="color: #339933;">:</span> ExpressionService <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003366; font-weight: bold;">var</span> returnValue<span style="color: #339933;">:</span> ExpressionService <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span>;
   <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
      CookieHandler.<span style="color: #660066;">setDefault</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> CookieManager<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> CookiePolicy.<span style="color: #660066;">ACCEPT_ALL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
      FXServiceFactory.<span style="color: #660066;">URL</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://localhost:8080/server-javafx/seam/resource/hessian/&quot;</span>;
      returnValue <span style="color: #339933;">=</span> FXServiceFactory.<span style="color: #660066;">getService</span><span style="color: #009900;">&#40;</span>ExpressionService.<span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">,</span> 
                        ExpressionService.<span style="color: #000066;">NAME</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">as</span> ExpressionService;
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>exception<span style="color: #339933;">:</span> Exception<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">Alert</span>.<span style="color: #660066;">inform</span><span style="color: #009900;">&#40;</span>exception.<span style="color: #660066;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
    returnValue
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> userName<span style="color: #339933;">:</span> String <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Enter name&quot;</span>;
<span style="color: #003366; font-weight: bold;">var</span> serverAnswer<span style="color: #339933;">:</span> String;
<span style="color: #003366; font-weight: bold;">var</span> serverTime<span style="color: #339933;">:</span> Date;
<span style="color: #003366; font-weight: bold;">var</span> lastAccessTime<span style="color: #339933;">:</span> String;
<span style="color: #003366; font-weight: bold;">var</span> poller <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
   repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #660066;">INDEFINITE</span>;
   keyFrames<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
   KeyFrame <span style="color: #009900;">&#123;</span>
      time<span style="color: #339933;">:</span> 1s;						
      action<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          serverTime <span style="color: #339933;">=</span> expressionService.<span style="color: #660066;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;helloAndTime.currentTime&quot;</span><span style="color: #009900;">&#41;</span> 
                                   <span style="color: #000066; font-weight: bold;">as</span> Date;
      <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
poller.<span style="color: #660066;">playFromStart</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> stage<span style="color: #339933;">:</span> Stage;
stage <span style="color: #339933;">=</span> Stage <span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;EL-Expression Sample&quot;</span>
    width<span style="color: #339933;">:</span>  <span style="color: #CC0000;">420</span> 	
    height<span style="color: #339933;">:</span> <span style="color: #CC0000;">400</span>
    scene<span style="color: #339933;">:</span> Scene <span style="color: #009900;">&#123;</span>
        fill<span style="color: #339933;">:</span> LinearGradient <span style="color: #009900;">&#123;</span>
            endX<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.0</span>
            stops<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #000066;">Stop</span> <span style="color: #009900;">&#123;</span> offset<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.0</span> color<span style="color: #339933;">:</span> Color.<span style="color: #660066;">LIGHTGRAY</span> <span style="color: #009900;">&#125;</span>
            <span style="color: #000066;">Stop</span> <span style="color: #009900;">&#123;</span> offset<span style="color: #339933;">:</span> <span style="color: #CC0000;">1.0</span> color<span style="color: #339933;">:</span> Color.<span style="color: #660066;">GRAY</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        stylesheets<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> <span style="color: #3366CC;">&quot;{__DIR__}style.css&quot;</span> <span style="color: #009900;">&#93;</span>
        content<span style="color: #339933;">:</span> VBox <span style="color: #009900;">&#123;</span>
            translateX<span style="color: #339933;">:</span> <span style="color: #CC0000;">5</span>
            translateY<span style="color: #339933;">:</span> <span style="color: #CC0000;">5</span>
            spacing<span style="color: #339933;">:</span> <span style="color: #CC0000;">10</span>
            content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
               TextBox <span style="color: #009900;">&#123;</span>
                  text<span style="color: #339933;">:</span> bind userName <span style="color: #000066; font-weight: bold;">with</span> inverse
               <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
               Button  <span style="color: #009900;">&#123;</span>
                  text<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Say Hello&quot;</span>
                  style <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-fx-font-size: large&quot;</span>
                  action<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                  <span style="color: #003366; font-weight: bold;">var</span> classes<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">Class</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> String.<span style="color: #003366; font-weight: bold;">class</span>;
                  serverAnswer <span style="color: #339933;">=</span> expressionService.
                      <span style="color: #660066;">invokeMethod</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;helloAndTime.sayHello&quot;</span><span style="color: #339933;">,</span> String.<span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">,</span> classes<span style="color: #339933;">,</span> userName<span style="color: #009900;">&#41;</span> 
                         <span style="color: #000066; font-weight: bold;">as</span> String;
                  lastAccessTime <span style="color: #339933;">=</span> String.<span style="color: #660066;">valueOf</span><span style="color: #009900;">&#40;</span>expressionService.
                      <span style="color: #660066;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;helloAndTime.lastAccessTime&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">as</span> Date<span style="color: #009900;">&#41;</span>;
                  <span style="color: #009900;">&#125;</span>
               <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
               Text <span style="color: #009900;">&#123;</span>
                  content<span style="color: #339933;">:</span> bind <span style="color: #3366CC;">&quot;Server says: {serverAnswer}&quot;</span>
                  styleClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;text&quot;</span>
               <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
               Text <span style="color: #009900;">&#123;</span>
                  content<span style="color: #339933;">:</span> bind <span style="color: #3366CC;">&quot;Last access time: {lastAccessTime}&quot;</span>
                  styleClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;text&quot;</span>
               <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
               Text <span style="color: #009900;">&#123;</span>
                  content<span style="color: #339933;">:</span> bind <span style="color: #3366CC;">&quot;Current server time: {serverTime}&quot;</span>
                  styleClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;text&quot;</span>
               <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    onClose<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        poller.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        FX.<span style="color: #660066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Line 6:</strong> we get a reference to ExpressionService instance. This class gives us all the functionality to work with EL from JavaFX.<br />
<strong>Line 24:</strong> we bind to currentTime property in helloAndTime component (bean). The syntax we use is helloAndTime.currentTime. If you are have are familiar with JSF then you would expect this format: #{helloAndTime.currentTime}. Due to JavaFX syntanx we can&#8217;t use {} brackets. I think helloAndTime.currentTime is just as simple.<br />
<strong>Line 57:</strong> we invoked a method<br />
<strong>Line 60:</strong> we bind to now another property: helloAndTime.lastAccessTime</p>
<p>When using EL, we don&#8217;t have to create an interface for the remote component as we did in <a href="http://mkblog.exadel.com/ria/javafx-ria/calling-seam-component-from-javafx-2/">calling Seam component from JavaFX</a>. On the other hand, the compiler can&#8217;t check that such method actually exits. When using an interface, the compiler will complain if we try to invoke a method that&#8217;s not in the interface. </p>
<p><strong>Result:</strong><br />
<img src="http://mkblog.exadel.com/wp-content/uploads/2010/07/screenshot_0191-266x300.png" alt="" title="screenshot_019" width="266" height="300" class="alignnone size-medium wp-image-1967" /></p>
<p>That&#8217;s it. </p>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/javafx-ria/using-expression-language-el-in-javafx-to-communicate-with-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binding to server-side context variable from JavaFX</title>
		<link>http://mkblog.exadel.com/ria/javafx-ria/binding-to-server-side-context-variable-from-javafx/</link>
		<comments>http://mkblog.exadel.com/ria/javafx-ria/binding-to-server-side-context-variable-from-javafx/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 21:22:45 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Flamingo]]></category>
		<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=1942</guid>
		<description><![CDATA[In addition to calling methods and Hibernate Validator, it&#8217;s also very simple to bind to a context variable and update it from JavaFX. A context variable is any variable inside a scope on the server. 
Server
Seam component:

@Name &#40;&#34;shop&#34;&#41;
@Scope &#40;ScopeType.SESSION&#41;
public class Store &#123;
&#160;
   IceCream iceCream; // getter and setter
&#160;
   @Create
   [...]]]></description>
			<content:encoded><![CDATA[<p>In addition to <a href="http://mkblog.exadel.com/ria/javafx-ria/calling-seam-component-from-javafx-2/">calling methods</a> and <a href="http://mkblog.exadel.com/ria/javafx-ria/invoking-hibernate-validator-from-javafx/">Hibernate Validator</a>, it&#8217;s also very simple to bind to a context variable and update it from JavaFX. A context variable is any variable inside a scope on the server. </p>
<h3>Server</h3>
<p><strong>Seam component:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">@<span style="color: #003399;">Name</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;shop&quot;</span><span style="color: #009900;">&#41;</span>
@Scope <span style="color: #009900;">&#40;</span>ScopeType.<span style="color: #006633;">SESSION</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Store <span style="color: #009900;">&#123;</span>
&nbsp;
   IceCream iceCream; <span style="color: #666666; font-style: italic;">// getter and setter</span>
&nbsp;
   @Create
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	iceCream <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> IceCream<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	iceCream.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Best ice cream&quot;</span><span style="color: #009900;">&#41;</span>;
	iceCream.<span style="color: #006633;">setFlavors</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>;	
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Model:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">@<span style="color: #003399;">Entity</span>
@<span style="color: #003399;">Name</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;icecream&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> IceCream <span style="color: #000000; font-weight: bold;">implements</span> java.<span style="color: #006633;">io</span>.<span style="color: #003399;">Serializable</span><span style="color: #009900;">&#123;</span>
&nbsp;
   @Max<span style="color: #009900;">&#40;</span>value<span style="color: #339933;">=</span><span style="color: #cc66cc;">5</span>, message<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Sorry, you can't have more than {value} flavors&quot;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> flavors;
&nbsp;
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> name;
&nbsp;
   <span style="color: #666666; font-style: italic;">// getters and setters</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Client</h3>
<p><strong>Model:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> IceCream <span style="color: #000000; font-weight: bold;">implements</span> java.<span style="color: #006633;">io</span>.<span style="color: #003399;">Serializable</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> name;
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> flavors;
   <span style="color: #666666; font-style: italic;">// setters and getters</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>BindingManager interface:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> BindingManager <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> commit<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> componentName, <span style="color: #003399;">Object</span> value<span style="color: #009900;">&#41;</span>;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> getObject<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> IceCreamServiceFactory <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> BindingManager getBindingManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>BindingManager<span style="color: #009900;">&#41;</span> FXServiceFactory.<span style="color: #006633;">getService</span><span style="color: #009900;">&#40;</span>BindingManager.<span style="color: #000000; font-weight: bold;">class</span>,
		<span style="color: #0000ff;">&quot;com.exadel.flamingo.service.binding.bindingManager&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> commit <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> componentName, <span style="color: #003399;">Object</span> value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">return</span> getBindingManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">commit</span><span style="color: #009900;">&#40;</span>componentName, value<span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> IceCream getIceCream <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> componentName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>IceCream<span style="color: #009900;">&#41;</span>getBindingManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getObject</span><span style="color: #009900;">&#40;</span>componentName<span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>JavaFX script:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;">CookieHandler.<span style="color: #660066;">setDefault</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> CookieManager<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span>CookiePolicy.<span style="color: #660066;">ACCEPT_ALL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
FXServiceFactory.<span style="color: #660066;">URL</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://localhost:8080/server-javafx/seam/resource/hessian/&quot;</span>;
&nbsp;
FX.<span style="color: #660066;">println</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Getting ice cream from server&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #003366; font-weight: bold;">var</span> iceCream <span style="color: #339933;">=</span> IceCreamServiceFactory.<span style="color: #660066;">getIceCream</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'shop.iceCream'</span><span style="color: #009900;">&#41;</span>;
FX.<span style="color: #660066;">println</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;  {iceCream}&quot;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
iceCream.<span style="color: #660066;">setName</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Gelato&quot;</span><span style="color: #009900;">&#41;</span>;
iceCream.<span style="color: #660066;">setFlavors</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span>;
&nbsp;
FX.<span style="color: #660066;">println</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Starting commit&quot;</span><span style="color: #009900;">&#41;</span>;
IceCreamServiceFactory.<span style="color: #660066;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;shop.iceCream&quot;</span><span style="color: #339933;">,</span> iceCream<span style="color: #009900;">&#41;</span>;
FX.<span style="color: #660066;">println</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Getting ice cream from the server after update&quot;</span><span style="color: #009900;">&#41;</span>;
FX.<span style="color: #660066;">println</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;   {IceCreamServiceFactory.getIceCream('shop.iceCream')}&quot;</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p>Line 5: Getting ice cream from the server (binding to context variable)<br />
Line 8-9: Making changes to ice cream<br />
Line 12: Committing changes to the server<br />
Line 14: Getting the updated object from the server</p>
<p><strong>Output:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text text" style="font-family:monospace;">Getting ice cream from server
  Name: Best ice cream, flavors: 2
Starting commit
Getting ice cream from the server after update
   Name: Gelato, flavors: 4</pre></div></div>

<p>That&#8217;s it. </p>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/javafx-ria/binding-to-server-side-context-variable-from-javafx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Invoking Hibernate Validator from JavaFX</title>
		<link>http://mkblog.exadel.com/ria/javafx-ria/invoking-hibernate-validator-from-javafx/</link>
		<comments>http://mkblog.exadel.com/ria/javafx-ria/invoking-hibernate-validator-from-javafx/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 04:35:12 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Flamingo]]></category>
		<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://mkblog.exadel.com/?p=1919</guid>
		<description><![CDATA[I showed how to call a Seam component with Flamingo from JavaFX. In this post I show how to invoke Hibernate Validator from JavaFX with Flamingo:
Entity (and Seam component):

@Entity
@Name &#40;&#34;icecream&#34;&#41;
public class IceCream &#123;
&#160;
   @Id @GeneratedValue
   private Long id;
&#160;
   @Max&#40;value=5, message=&#34;Sorry, you can't have more than {value} flavors&#34;&#41;
   [...]]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://mkblog.exadel.com/ria/javafx-ria/calling-seam-component-from-javafx-2/">showed</a> how to call a Seam component with <a href="http://exadel.com/web/portal/flamingo">Flamingo</a> from JavaFX. In this post I show how to invoke Hibernate Validator from JavaFX with Flamingo:</p>
<p><strong>Entity (and Seam component):</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">@<span style="color: #003399;">Entity</span>
@<span style="color: #003399;">Name</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;icecream&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> IceCream <span style="color: #009900;">&#123;</span>
&nbsp;
   @Id @GeneratedValue
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Long</span> id;
&nbsp;
   @Max<span style="color: #009900;">&#40;</span>value<span style="color: #339933;">=</span><span style="color: #cc66cc;">5</span>, message<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Sorry, you can't have more than {value} flavors&quot;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> flavors;
&nbsp;
   <span style="color: #666666; font-style: italic;">// getters and setters</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>JavaFX script (most interesting stuff is happening lines 17-21):</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;">FXServiceFactory.<span style="color: #660066;">URL</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://localhost:8080/server-javafx/seam/resource/hessian/&quot;</span>;
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> message<span style="color: #339933;">:</span>String;
<span style="color: #003366; font-weight: bold;">var</span> textBox<span style="color: #339933;">:</span>TextBox <span style="color: #339933;">=</span> TextBox <span style="color: #009900;">&#123;</span>
    columns<span style="color: #339933;">:</span> <span style="color: #CC0000;">15</span>  
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> label<span style="color: #339933;">:</span>Label <span style="color: #339933;">=</span> Label <span style="color: #009900;">&#123;</span>
    text <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;How many flavors:&quot;</span>   
    style<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;-fx-font-weight:bold&quot;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> errorMessage<span style="color: #339933;">:</span>Label <span style="color: #339933;">=</span> Label <span style="color: #009900;">&#123;</span>
    text<span style="color: #339933;">:</span> bind message
    style <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-fx-text-fill:red; -fx-font-weight:bold&quot;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> button<span style="color: #339933;">:</span>Button <span style="color: #339933;">=</span> Button <span style="color: #009900;">&#123;</span>
    text<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Click&quot;</span>
    action <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #003366; font-weight: bold;">var</span> ev <span style="color: #339933;">=</span> FXServiceFactory.<span style="color: #660066;">getService</span><span style="color: #009900;">&#40;</span>EntityValidator.<span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">,</span> 
       		<span style="color: #3366CC;">&quot;com.exadel.flamingo.service.validator.entityValidator&quot;</span><span style="color: #009900;">&#41;</span>
       		<span style="color: #000066; font-weight: bold;">as</span> <span style="color: #009900;">&#40;</span>EntityValidator<span style="color: #009900;">&#41;</span>;      
       message <span style="color: #339933;">=</span> ev.<span style="color: #660066;">validate</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;icecream.flavors&quot;</span><span style="color: #339933;">,</span> textBox.<span style="color: #660066;">text</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span>
&nbsp;
Stage <span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Application&quot;</span>
    width<span style="color: #339933;">:</span> <span style="color: #CC0000;">250</span> height<span style="color: #339933;">:</span> <span style="color: #CC0000;">100</span>
    scene<span style="color: #339933;">:</span> Scene <span style="color: #009900;">&#123;</span>
        content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> 
        VBox <span style="color: #009900;">&#123;</span>
            spacing<span style="color: #339933;">:</span> <span style="color: #CC0000;">5</span>
            content<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>
            label<span style="color: #339933;">,</span> 
            HBox <span style="color: #009900;">&#123;</span>
                spacing<span style="color: #339933;">:</span> <span style="color: #CC0000;">5</span>
                content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                   textBox<span style="color: #339933;">,</span> 
                   errorMessage
                <span style="color: #009900;">&#93;</span> 
            <span style="color: #009900;">&#125;</span>            
            button
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>;</pre></td></tr></table></div>

<p><strong>Result:</strong><br />
<img src="http://mkblog.exadel.com/wp-content/uploads/2010/07/screenshot_013.png" alt="" title="screenshot_013" width="335" height="136" class="alignnone size-full wp-image-1929" /></p>
<p>That&#8217;s it. </p>
]]></content:encoded>
			<wfw:commentRss>http://mkblog.exadel.com/ria/javafx-ria/invoking-hibernate-validator-from-javafx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
