<?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>Exprime IT - The Blog</title>
	<atom:link href="http://blog.exprimeit.co.uk/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.exprimeit.co.uk</link>
	<description>News source for Exprime IT Ltd. and helpful articles on popular software technologies</description>
	<lastBuildDate>Fri, 16 Jul 2010 08:20:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>JSF Error &#8211; Target Unreachable, identifier &#8216;MyBacking&#8217; resolved to null</title>
		<link>http://blog.exprimeit.co.uk/?p=245</link>
		<comments>http://blog.exprimeit.co.uk/?p=245#comments</comments>
		<pubDate>Fri, 16 Jul 2010 08:20:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JEE]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[EclipseLink]]></category>
		<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[JEE6]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=245</guid>
		<description><![CDATA[My JSF application was throwing the following error message: Target Unreachable, identifier 'MyBacking' resolved to null All of my other backing beans were working so It was kind of perplexing and I could not immediately pinpoint the error source. To cut a long story short, it turns out that the ManagedBean annotation requires the name [...]]]></description>
			<content:encoded><![CDATA[<p>My JSF application was throwing the following error message:</p>
<pre><code>
Target Unreachable, identifier 'MyBacking' resolved to null
</code></pre>
<p>All of my other backing beans were working so It was kind of perplexing and I could not immediately pinpoint the error source.<br />
To cut a long story short, it turns out that the ManagedBean annotation requires the name attribute like so:</p>
<pre><code>
@ManagedBean(name = "MyBacking")
@RequestScoped
public class MyBacking {
[...]
</code></pre>
<p>This is kind of odd since the class name and the defined attribute name are equal.</p>
<p>My environment:</p>
<p>Netbeans 6.9<br />
Mojarra 2.0.2<br />
EclipseLink, version: Eclipse Persistence Services &#8211; 2.0.0.v20091127-r5931<br />
GlassFish Server 3</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=245</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to record / create a Macro in Netbeans</title>
		<link>http://blog.exprimeit.co.uk/?p=235</link>
		<comments>http://blog.exprimeit.co.uk/?p=235#comments</comments>
		<pubDate>Fri, 28 May 2010 12:11:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Netbeans]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=235</guid>
		<description><![CDATA[One of the great features of the Netbeans IDE is the ability to create a macro to simplify repetitive and tedious tasks. In my case I had a long list of country names that needed to be placed in a Java property file. I.e. turning the following: ... Armenia Australia Austria Belgium Bolivia ... into [...]]]></description>
			<content:encoded><![CDATA[<p>One of the great features of the Netbeans IDE is the ability to create a macro to simplify repetitive and tedious tasks. In my case I had a long list of country names that needed to be placed in a Java property file. I.e. turning the following:</p>
<pre>
<code>
...
Armenia
Australia
Austria
Belgium
Bolivia
...
</code>
</pre>
<p>into the following key-value pair:</p>
<pre>
<code>
...
Armenia=Armenia
Australia=Australia
Austria=Austria
Belgium=Belgium
Bolivia=Bolivia
...
</code>
</pre>
<p>This of course is a real nuisance but with the help of a little macro the work can get done in no time.</p>
<p>My first attempt to create such a macro is in using the macro recorder. I placed the curser right after the word &#8220;Armenia&#8221; and pressed the round red &#8220;Start Macro Recording&#8221; button at the top of the editor.<br />
I then moved the cursor holding the shift button (select) and using the arrow buttons to the beginning of the line. Then I pressed Ctrl-C (copy) and then moved the cursor via the mouse back to the end of the word &#8220;Armenia&#8221;. I entered a &#8220;=&#8221; symbol and pressed Ctrl-V. I then stopped recording the macro. Finally I assigned the previously unused keyboard shortcut CTRL-L to my new macro.</p>
<p>As could be expected the macro recorder has no notion of the beginning of the word or the beginning of the line. The recorder counted my backward selection steps and consequently the macro works only for countries with the same amount of letters as &#8220;Armenia&#8221; i.e. 7.</p>
<p>I opened the Macro Editor <code>Tools -> Options -> Editor -> Macros</code> and found the following code for my macro:</p>
<pre><code>
selection-backward
selection-backward
selection-backward
selection-backward
selection-backward
selection-backward
selection-backward
copy-to-clipboard
caret-forward
"="
paste-from-clipboard
</code></pre>
<p>What I need was a command that would take me to the beginning of the line. (The beginning of the word is not enough since some country names like for example &#8220;United States&#8221; consist of two words). In one of the previously defined macros I found the command &#8220;<code>caret-begin-word</code>&#8221; and I modified my macro as follows:</p>
<pre><code>
selection-begin-line
copy-to-clipboard
 caret-forward
 "="
 paste-from-clipboard
</code></pre>
<p>And sure enough when placing the cursor at the end of the country name and pressing CTRL-L you get the desired completion of the line.</p>
<p>Definitely not an advanced Netbeans topic, but getting the hang of this can be a great time saver.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=235</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to register a ServletContextListener in JSF 2.0</title>
		<link>http://blog.exprimeit.co.uk/?p=230</link>
		<comments>http://blog.exprimeit.co.uk/?p=230#comments</comments>
		<pubDate>Thu, 27 May 2010 09:58:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JEE]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[JavaEE]]></category>
		<category><![CDATA[JEE6]]></category>
		<category><![CDATA[JSF]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=230</guid>
		<description><![CDATA[In pre JSF 2.0 you were forced to use the WEB-INF/web.xml file to register your ServletContextListener &#60;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&#62; &#60;context-param&#62; &#60;param-name&#62;javax.faces.PROJECT_STAGE&#60;/param-name&#62; &#60;param-value&#62;Development&#60;/param-value&#62; &#60;/context-param&#62; &#60;listener&#62; &#60;listener-class&#62;com.mycompany.myproject.MyServletContextListener&#60;/listener-class&#62; &#60;/listener&#62; ... &#60;/web-app&#62; While you can still do this, in JSF 2.0 it is now possible to register your ServletContextListener or rather any of the following Listeners: [...]]]></description>
			<content:encoded><![CDATA[<p>In pre JSF 2.0 you were forced to use the WEB-INF/web.xml file to register your ServletContextListener</p>
<pre><code>

&lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
    &lt;context-param&gt;
        &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
        &lt;param-value&gt;Development&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;listener&gt;
        &lt;listener-class&gt;com.mycompany.myproject.MyServletContextListener&lt;/listener-class&gt;
    &lt;/listener&gt;
...
&lt;/web-app&gt;

</code></pre>
<p>While you can still do this, in JSF 2.0 it is now possible to register your ServletContextListener or rather any of the following Listeners:</p>
<p>ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, HttpSessionListener, HttpSessionAttributeListener</p>
<p>by using the <code>@WebListener</code> annotation.</p>
<p>So your listener implementation would look like the following:</p>
<pre><code>
@WebListener
public class MyServletContextListener implements ServletContextListener {
...
}
</code></pre>
<p>When registering my ServletContextListener I ran into the following error messages:</p>
<pre>
<code>
SCHWERWIEGEND: PWC1306: Startup of context /MyApp failed due to previous errors
SCHWERWIEGEND: PWC1305: Exception during cleanup after start failed
org.apache.catalina.LifecycleException: PWC2769: Manager has not yet been started
        at org.apache.catalina.session.StandardManager.stop(StandardManager.java:892)
        at org.apache.catalina.core.StandardContext.stop(StandardContext.java:5383)
        ...

SCHWERWIEGEND: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: java.lang.NullPointerException
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:5216)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
        ...

WARNUNG: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NullPointerException
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NullPointerException
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:932)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
        ...

SCHWERWIEGEND: Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NullPointerException
        at com.sun.enterprise.web.WebApplication.start(WebApplication.java:117)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
        at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
        at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)

SCHWERWIEGEND: Exception while loading the app
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NullPointerException
        at com.sun.enterprise.web.WebApplication.start(WebApplication.java:117)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
        at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
</code>
</pre>
<p>This was a simple oversight on my part. In my Listener I wanted to use an EJB to add some data to the database using JPA. I forgot to use the <code>@EJB</code> annotation when defining the EJB attribute:</p>
<pre><code><br />
@EJB<br />
private MyFacade myfacade;<br />
</code>
<pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=230</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing GET request parameters in JSF 2.0</title>
		<link>http://blog.exprimeit.co.uk/?p=217</link>
		<comments>http://blog.exprimeit.co.uk/?p=217#comments</comments>
		<pubDate>Fri, 23 Apr 2010 12:20:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JEE]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JSF]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=217</guid>
		<description><![CDATA[In JSF 2.0 &#60;h:link&#62; tags were introduced that allow users to navigate to a JSF page without using a postback request. For example: &#60;h:link value="3 Month Subscription" outcome="subscribe" /&#62; would create an HTML link similar to: &#60;a href="/MyApp/faces/subscribe.xhtml"&#62;3 Month Subscription&#60;/a&#62; The value of the &#8220;outcome&#8221; parameter utilizes JSF 2.0 implicit navigation rules that save you [...]]]></description>
			<content:encoded><![CDATA[<p>In JSF 2.0 <code>&lt;h:link&gt;</code> tags were introduced that allow users to navigate to a JSF page without using a postback request.</p>
<p>For example:</p>
<pre><code>
&lt;h:link value="3 Month Subscription" outcome="subscribe" /&gt;
</code></pre>
<p>would create an HTML link similar to:</p>
<pre><code>
&lt;a href="/MyApp/faces/subscribe.xhtml"&gt;3 Month Subscription&lt;/a&gt;
</code></pre>
<p>The value of the &#8220;outcome&#8221; parameter utilizes JSF 2.0 implicit navigation rules that save you the trouble of defining navigation cases in the faces-config.xml file.</p>
<p>Furthermore query parameters may be added to the links:</p>
<pre><code>
&lt;h:link value="3 Month Subscription" outcome="subscribe"&gt;
    &lt;f:param name="subscriptionType" value="threeMonth" /&gt;
&lt;/h:link&gt;

&lt;h:link value="6 Month Subscription" outcome="subscribe"&gt;
    &lt;f:param name="subscriptionType" value="sixMonth" /&gt;
&lt;/h:link&gt;
</code></pre>
<p>The links would look like this:</p>
<pre><code>
&lt;a href="/MyApp/faces/subscribe.xhtml?subscriptionType=threeMonth"&gt;3 Month Subscription&lt;/a&gt;
&lt;a href="/MyApp/faces/subscribe.xhtml?subscriptionType=sixMonth"&gt;6 Month Subscription&lt;/a&gt;
</code></pre>
<p>This way we are able to preset the subscription type field on the subscribe.xhtml page. In subscribe.xhtml there might be the following Radio Buttons:</p>
<pre><code>
&lt;h:selectOneRadio label="Subscription Type" value="#{BackingBean.subscriptionType}" id="subscriptionType"&gt;
    &lt;f:selectItem itemLabel="3 Month Subscription" itemValue="threeMonth" /&gt;
    &lt;f:selectItem itemLabel="6 Month Subscription" itemValue="sixMonth" /&gt;
&lt;/h:selectOneRadio&gt;
</code>
</pre>
<p>Instead of representing the subscription type value as radio buttons you could use any other input component including for example a hidden field.</p>
<p>In order for the radio button to be selected upon loading the subscribe.xhtml page you must add the following annotation to the subscriptionType field in the corresponding JSF managed bean:</p>
<pre><code>
[...]
@ManagedProperty(value="#{param.subscriptionType}")
private String subscriptionType;
[...]
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=217</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Differences between TopLink and EclipseLink</title>
		<link>http://blog.exprimeit.co.uk/?p=211</link>
		<comments>http://blog.exprimeit.co.uk/?p=211#comments</comments>
		<pubDate>Mon, 22 Mar 2010 20:01:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JEE]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[EclipseLink]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JEE6]]></category>
		<category><![CDATA[TopLink]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=211</guid>
		<description><![CDATA[The default persistence manager in Netbeans Release 6.8 has changed from TopLink to EclipseLink and I will list error messages and differences that I find as I go along. 1. ErrorMessage Exception [EclipseLink-8034] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.JPQLException Exception Description: Error compiling the query [findUserByEmail: SELECT u FROM theuser u WHERE u.email = :email]. [...]]]></description>
			<content:encoded><![CDATA[<p>The default persistence manager in Netbeans Release 6.8 has changed from TopLink to EclipseLink and I will list error messages and differences that I find as I go along. </p>
<p>1.<br />
<b>ErrorMessage</b><br />
<code><br />
Exception [EclipseLink-8034] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.JPQLException<br />
Exception Description: Error compiling the query [findUserByEmail: SELECT u FROM theuser u WHERE u.email = :email]. Unknown entity type [theuser].<br />
        at org.eclipse.persistence.exceptions.JPQLException.entityTypeNotFound(JPQLException.java:483)<br />
</code><br />
<b>Solution</b><br />
EclipseLink is case sensitive. If your entity is named &#8220;TheUser&#8221; (yes, it is a dumm name for an entity) your named query should be:<br />
<code>@NamedQueries({<br />
  @NamedQuery(<br />
    name="findUserByEmail",<br />
    query="SELECT u FROM TheUser u WHERE u.email = :email"<br />
  )<br />
})</code><br />
and not <code>...SELECT u FROM theuser...</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=211</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Problems Updating Ubuntu 9.10 (postfix could not be installed)</title>
		<link>http://blog.exprimeit.co.uk/?p=206</link>
		<comments>http://blog.exprimeit.co.uk/?p=206#comments</comments>
		<pubDate>Fri, 19 Feb 2010 16:05:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=206</guid>
		<description><![CDATA[Recently (early February) a bunch of new updates to Ubuntu 9.10 appeared in the Ubuntu Update Center and without giving them much attention I simply pressed &#8220;Install&#8221;. So far nothing unusual. But this time I ended up with a request for &#8220;postfix&#8221; to be configured, which I ignored, I do not need postfix on my [...]]]></description>
			<content:encoded><![CDATA[<p>Recently (early February) a bunch of new updates to Ubuntu 9.10 appeared in the Ubuntu Update Center and without giving them much attention I simply pressed &#8220;Install&#8221;. So far nothing unusual. But this time I ended up with a request for &#8220;postfix&#8221; to be configured, which I ignored, I do not need postfix on my system, and two broken packages: bsd-mailx and lsb-core.</p>
<p>Here are my error messages:</p>
<p><code>E: /var/cache/apt/archives/postfix_2.6.5-3_i386.deb: subprocess new pre-installation script returned error exit status 1</code></p>
<p>and from the update manager</p>
<p><code>An error occurred, please run Package Manager from the right-click menu or apt-get in a terminal to see what is wrong. The error message was:<br />
'Error: BrokenCount > 0' This usually means that your installed packages have unmet dependencies</code></p>
<p>I searched and removed bsd-mailx and lsb-core with Synaptic package manager, and by checking the packages dependencies found out that Google Chrome beta was responsible for the installation in the first place.</p>
<p>In fact there were a whole bunch of packages newly installed when I checked:<br />
/var/log/apt/term.log<br />
(lines starting with: Selecting previously deselected package&#8230;)</p>
<p>All of these packages where listed as &#8220;new install&#8221; in the update manager under a section misleadingly called &#8220;Distribution Upgrade&#8221;.</p>
<p>This is no severe issue (except maybe by mistakenly opening up your system by an imprudent postfix configuration) but rather an annoyance. Personally I resolved the issue by deinstalling the superfluous packages mentioned above and by deinstalling Google Chrome and removing the Google repository from my list of repositories. It is an unfortunate choice, since despite some issues with the Flash plugin, Chrome is a really nice and fast browser. I will try it again with an upcoming release when the package issue has hopefully been resolved.</p>
<p>Of course if you cannot live without Chrome you might resolve this issue differently.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=206</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preview Release of JavaFX Composer</title>
		<link>http://blog.exprimeit.co.uk/?p=195</link>
		<comments>http://blog.exprimeit.co.uk/?p=195#comments</comments>
		<pubDate>Thu, 17 Dec 2009 21:25:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JavaEE]]></category>
		<category><![CDATA[JavaFX Composer]]></category>
		<category><![CDATA[Netbeans]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=195</guid>
		<description><![CDATA[Just this week marked the release of Netbeans 6.8. Another release that has been worth waiting for with many great new features including full support of Java EE 6. One of the things that followed after the release was the announcement in Netbeans newsletter Issue # 420 &#8211; Dec 15, 2009 that a preview release [...]]]></description>
			<content:encoded><![CDATA[<p>Just this week marked the release of Netbeans 6.8. Another release that has been worth waiting for with many great new features including full support of Java EE 6.</p>
<p>One of the things that followed <i>after</i> the release was the announcement in <a href="http://www.netbeans.org/community/news/newsletter/2009-12-15.html">Netbeans newsletter Issue # 420 &#8211; Dec 15, 2009</a> that a preview release of JavaFX Composer was made. The release has been made very silently since none of the other major JavaFX blogs we are following has picked up the news. JavaFX Composer is a visual design tool or RAD (rapid application development) tool that has been much anticipated and will make the development of &#8220;business&#8221; applications using JavaFX more compelling for businesses.</p>
<p>We are very excited about the release and our first impression is very good. We hope to give the composer a more thorough test ride soon. </p>
<p>The JavaFX Composer is a Netbeans plugin and you can get it like this:</p>
<p>&#8220;The JavaFX Composer is a preview release and is available for NetBeans IDE 6.8 as a plugin from the NetBeans Update Center. (From the NetBeans IDE, go to Tools &#8211;> Plugins &#8211;> Available Plugins &#8211;> JavaFX.) &#8221; (source Netbeans newsletter issue #420)</p>
<p>More information can be found <a href="http://wiki.netbeans.org/JavaFXComposer">here</a>.</p>
<p>The other tool Sun is working on is the JavaFX Authoring Tool where no release date has yet been made public.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=195</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use Inkscape&#8217;s new JavaFX export functionality</title>
		<link>http://blog.exprimeit.co.uk/?p=188</link>
		<comments>http://blog.exprimeit.co.uk/?p=188#comments</comments>
		<pubDate>Wed, 16 Dec 2009 14:11:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Inkscape]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=188</guid>
		<description><![CDATA[With the release of Inkscape 0.47, Inkscape now offers its users to save their work as JavaFX *.fx files. This is how it works for you. Create a graphic in Inkscape for example: Choose File -> Save As&#8230; -> Select file type as JavaFX *.fx The file name you have chosen for your JavaFX file [...]]]></description>
			<content:encoded><![CDATA[<p>With the release of Inkscape 0.47, <a href="http://www.inkscape.org">Inkscape</a> now offers its users to save their work as JavaFX *.fx files. This is how it works for you.<br />
Create a graphic in Inkscape for example:</p>
<p><img src="wp-content/img0006.jpg" alt="img in inkscape" /></p>
<p>Choose File -> Save As&#8230; -> Select file type as JavaFX *.fx</p>
<p>The file name you have chosen for your JavaFX file is the name of the JavaFX class. We named our file MyShape.fx<br />
So in a JavaFX Project you can call <code>new MyShape</code> and your graphic should appear. </p>
<p><img src="wp-content/img0007.jpg" alt="img in javafx" /></p>
<p>Unfortunately there were three bugs that we encountered in this simple example.<br />
Number one, the text of our Inkscape drawing does not show up in the JavaFX export (<a href="https://bugs.launchpad.net/inkscape/+bug/489364">Inkscape Bug 489364</a>). </p>
<p>Number two, in the create Method of the JavaFX export file a method named path4117-5() is called (<a href="https://bugs.launchpad.net/inkscape/+bug/439270">Inkscape Bug 439270</a>). This is not only incorrect syntax but the method does not exist. It was called path4117_5() and changes had to be made to the JavaFX file.</p>
<p>And number three, as you can see the stroke width of the line is not the same. Going into the code you can see that the width is set to 0.0 in Inkscape&#8217;s JavaFX file, when in fact it should be set to 6.0. (<a href="https://bugs.launchpad.net/inkscape/+bug/497416">I filed bug 497416</a>).</p>
<p>If you would like to avoid names such as path4117 etc. in your JavaFX files, select any one of your objects in Inkscape, press the right mouse button and select &#8220;object properties&#8221;. Here you can change the Id to something that is easier to remember.</p>
<p>There are of course more things to discover in collaboratively working with JavaFX and Inkscape, some of which we might focus on in the near future.</p>
<p>While these three bugs are unfortunate, they will probably be easy to resolve. Let us also not forget, that JavaFX support is new to Inkscape. What counts for now is that it is great that Inkscape offers an open source alternative to creating graphics for JavaFX.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=188</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Not available in the current data &#8211; Ubuntu Software Center</title>
		<link>http://blog.exprimeit.co.uk/?p=181</link>
		<comments>http://blog.exprimeit.co.uk/?p=181#comments</comments>
		<pubDate>Sun, 01 Nov 2009 20:27:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=181</guid>
		<description><![CDATA[One thing thing that has been an issue, is that on using the new Ubuntu Software Center, I get the following error messages:

<em>Not available in the current data</em>
and
<em>Not available for your hardware architecture</em>]]></description>
			<content:encoded><![CDATA[<p>I just installed the Karmic Koala (Ubuntu 9.10) on all three of my machines and at first sight everything seems to be working great. I am especially pleased with the new look of the Ubuntu Desktop and of the Ubuntu Netbook Remix releases.</p>
<p>One thing thing that has been an issue, is that on using the new Ubuntu Software Center, I get the following error messages:</p>
<p><em>Not available in the current data</em><br />
and<br />
<em>Not available for your hardware architecture</em></p>
<p>So in case anyone else is running into this try running:<br />
<code>sudo apt-get update</code><br />
in  a terminal.</p>
<p>From the man page:<br />
&#8220;update is used to resynchronize the package index files from their sources.&#8221;</p>
<p>After that everything worked fine. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=181</wfw:commentRss>
		<slash:comments>105</slash:comments>
		</item>
		<item>
		<title>Creating a Simple Game in JavaFX (Part 7)</title>
		<link>http://blog.exprimeit.co.uk/?p=159</link>
		<comments>http://blog.exprimeit.co.uk/?p=159#comments</comments>
		<pubDate>Tue, 27 Oct 2009 08:26:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Netbeans]]></category>

		<guid isPermaLink="false">http://blog.exprimeit.co.uk/?p=159</guid>
		<description><![CDATA[Final Thoughts We have created a simple game in JavaFX and my personal experience with JavaFX is very positive. I find it very intuitive to create graphical objects and timeline objects for animation. This is a great time saver and leads to better structured code and better looking graphics when comparing the code to the [...]]]></description>
			<content:encoded><![CDATA[<p><script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script> <script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script><br />
<strong>Final Thoughts</strong></p>
<p>We have created a simple game in JavaFX and my personal experience with JavaFX is very positive. I find it very intuitive to create graphical objects and timeline objects for animation. This is a great time saver and leads to better structured code and better looking graphics when comparing the code to the initial JavaSE implementation (please see <a href="http://blog.exprimeit.co.uk/?p=105">Part 1</a>).</p>
<p>Of course this game is only somewhat fun to play. Things that I would like to change are:</p>
<ul>
<li>Introduce Levels: Each Level would speed up the balls or add new balls</li>
<li>Introduce bonus objects: Extra lives, things that make your ball or the enemy balls smaller or larger, etc.</li>
<li>Tidy up the graphics: Think of a real game theme, instead of playing with balls</li>
<li>Introduce sound effects</li>
<li>Persist Highscore beyond the application life cycle</li>
<li>&#8230;and many other things</li>
</ul>
<p>If someone reading this article is interested in further developing this game, leave me a comment and I could check the sources into a public repository like kenai or sourceforge. Any other comments would also be appreciated.</p>
<p><strong>Game Applet</strong></p>
<p><script src="http://dl.javafx.com/1.2/dtfx.js"></script><br />
<script>
    javafx(
        {
              archive: "http://blog.exprimeit.co.uk/wp-content/MyBallGame.jar",
              draggable: true,
              width: 440,
              height: 410,
              code: "myballgame.Main",
              name: "MyBallGame"
        }
    );
</script></p>
<p>You can drag the game onto your desktop by pressing the &#8220;Alt&#8221; key while you are dragging the game with your mouse.</p>
<p>And here is the <a href="wp-content/MyBallGame.jnlp">webstart version</a>.</p>
<p><strong>Complete Tutorial Code</strong></p>
<p><i>Main.fx</i></p>
<pre><code>
/*
 * Main.fx
 *
 * Created on 15.10.2009, 17:36:19
 */

package myballgame;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.Group;

import javafx.scene.shape.Rectangle;

import javafx.scene.shape.Circle;

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;

import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;

import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.layout.Tile;
import javafx.geometry.HPos;

/**
 * @author Alexander Gnodtke
 */
def PLAYER_BALL_STEP = 4;

def MODE_GAME_OVER: String = "GAME_OVER";
def MODE_RUNNING:   String = "RUNNING";

var mode:String = MODE_RUNNING;

var moveUp = false;
var moveDown = false;
var moveLeft = false;
var moveRight = false;

var scoreTime = 0;
var scoreMoves = 0;
var scoreBonus = 0;
var scoreTotal = 0;
var scoreHigh = 0;

var scoreArea: Group = Group {

    content : [
        Rectangle {
            arcWidth: 20  arcHeight: 20
            x: 290 y: 0
            width: 120, height: 200
            fill: Color.LIGHTGOLDENRODYELLOW
            stroke: Color.DARKORANGE
            strokeWidth: 3
        },
        Text {
            font : Font {
                size: 24
            }
            layoutX: 320 layoutY: 30
            content: "Score"
        },
        Tile {
            columns: 2
            rows: 5
            hgap: 5
            vgap: 5
            tileWidth: 50
            hpos: HPos.LEADING
            layoutX: 290 layoutY: 50
            content: [
                Text {
                    font : Font {
                        size: 12
                    }
                    content: "Time:"
                },
                Text {
                    font : Font {
                        size: 12
                    }
                    content: bind scoreTime.toString()
                },
                Text {
                    font : Font {
                        size: 12
                    }
                    content: "Moves:"
                },
                Text {
                    font : Font {
                        size: 12
                    }
                    content: bind scoreMoves.toString()
                },
                Text {
                    font : Font {
                        size: 12
                    }
                    content: "Bonus:"
                },
                Text {
                    font : Font {
                        size: 12
                    }
                    content: bind scoreBonus.toString()
                },
                Text {
                    font : Font {
                        size: 12
                    }
                    content: "Total:"
                },
                Text {
                    font : Font {
                        size: 12
                    }
                    content: bind scoreTotal.toString()
                },
                Text {
                    font : Font {
                        size: 12
                    }
                    content: "High:"
                },
                Text {
                    font : Font {
                        size: 12
                    }
                    content: bind scoreHigh.toString()
                }
            ]
        }
    ]
}

var playingField: Rectangle = Rectangle {
    arcWidth: 20  arcHeight: 20
    width: 280, height: 380
    fill: Color.ANTIQUEWHITE
    stroke: Color.DARKORANGE
    strokeWidth: 3
}

var gameOverScreen: Group = Group{
    visible:false
    var r:Rectangle = Rectangle {
        arcWidth: playingField.arcWidth  arcHeight: playingField.arcHeight
        width: playingField.width, height: playingField.height
        fill: Color.ROSYBROWN
        stroke: Color.DARKRED
        strokeWidth: playingField.strokeWidth
    }
    content: [
        r,
        Text {
            font : Font {
                size: 24
            }
            x: 10, y: 50
            content: "Game Over"
        },
        Text {
            font : Font {
                size: 20
            }
            x: 10, y: 80
            content: "(press Enter to restart)"
        }
   ]
}

var player: Circle = Circle {
    translateX: 250, translateY:250
    radius: 10
    fill: Color.BLACK
}

var enemies : Enemy[] = for (i in [0..3]) {
    var enemy:Enemy = Enemy {
        translateX : randomEnemyInitPosition(), translateY:randomEnemyInitPosition()
    }
    enemy
};

var bonusTimeline: Timeline = Timeline {
    repeatCount: 1
    keyFrames : [
        KeyFrame {
            time : 3s
            canSkip: false
        }
    ]
}

var timeline: Timeline = Timeline {
    repeatCount: Timeline.INDEFINITE
    keyFrames : [
        KeyFrame {
            time : 30ms
            canSkip: false
            action: function() {
                var playerMoved = false;

                calculateBonusEnemy();

                // Enemy
                for (enemy in enemies)
                    enemy.calcPosition(playingField.boundsInLocal.minX,playingField.boundsInLocal.maxX,playingField.boundsInLocal.minY,playingField.boundsInLocal.maxY);

                // Player
                if (moveRight) {
                    var newX = player.translateX + PLAYER_BALL_STEP;
                    if (newX &#060; playingField.boundsInLocal.maxX - player.radius - playingField.strokeWidth) {
                        playerMoved = true;
                        player.translateX = newX
                    }
                }
                if (moveLeft) {
                    var newX = player.translateX - PLAYER_BALL_STEP;
                    if (newX > playingField.boundsInLocal.minX + player.radius + playingField.strokeWidth) {
                        playerMoved = true;
                        player.translateX = newX
                    }
                }
                if (moveUp) {
                    var newY= player.translateY - PLAYER_BALL_STEP;
                    if (newY &#062; playingField.boundsInLocal.minY + player.radius + playingField.strokeWidth) {
                        playerMoved = true;
                        player.translateY = newY
                    }
                }
                if (moveDown) {
                    var newY= player.translateY + PLAYER_BALL_STEP;
                    if (newY &#060; playingField.boundsInLocal.maxY - player.radius - playingField.strokeWidth) {
                        playerMoved = true;
                        player.translateY = newY
                    }
                }
                // checkCollision
                for (enemy in enemies) {
                    if (checkCircleCollision(player.translateX,player.translateY,player.radius,enemy.translateX,enemy.translateY,10.0)) {
                        if (not enemy.bonusMode) {
                            gameOver();
                        } else {
                            calculateNewScore(playerMoved,true);
                        }
                    } else {
                        calculateNewScore(playerMoved);
                    }
                }
            }
        }
    ]
}

function calculateNewScore(addMoveScore:Boolean,addBonusScore:Boolean) {
    scoreBonus += 1000;
    calculateNewScore(addMoveScore);
}

function calculateNewScore(addMoveScore:Boolean) {
    scoreTime += 5;
    scoreMoves = if (addMoveScore) scoreMoves+5 else scoreMoves-10;
    scoreTotal = scoreTime + scoreMoves + scoreBonus;

}

function calculateBonusEnemy() {
    var bEnemy:Enemy = null;
    for (enemy in enemies) {
        if (enemy.bonusMode) {
            bEnemy = enemy;
        }
    }

    // None Bonus
    if (bEnemy==null) {
        if (javafx.util.Math.random()>0.95) {
            // Change one to bonus
            var i = (javafx.util.Math.ceil( enemies.size()*javafx.util.Math.random() )).intValue();
            println("changing to bonus {i}");
            enemies[i].fill(Color.CYAN);
            enemies[i].bonusMode = true;
            bonusTimeline.playFromStart();
        }
    } else {
        // One Bonus
        if (not bonusTimeline.running) { // min 3s in Bonus
            if (javafx.util.Math.random()>0.5) { // Turn off bonus
                bEnemy.fill(Enemy.DEFAULT_FILL);
                bEnemy.bonusMode = false;
                if (not bEnemy.bonusWasHit) {
                    scoreBonus -= 5000
                }
                bEnemy.bonusWasHit = false
            } else {
                // prolong bonus
                bonusTimeline.playFromStart();
            }

       }
    }
}

// Function called after collision
function gameOver():Void {
    timeline.stop();
    mode = MODE_GAME_OVER;
    gameOverScreen.visible = true;
    if (scoreTotal > scoreHigh)
        scoreHigh = scoreTotal;
}

function initGame():Void {
    initActors();
    initScore();
    mode = MODE_RUNNING;
    gameOverScreen.visible = false
}

function initScore() {
    scoreBonus = scoreMoves = scoreTime = scoreTotal = 0
}

// Function is used to initialize the actors i.e. player and enemies
// on the playing field
function initActors() {
    player.translateX = 250;
    player.translateY = 250;
    for (enemy in enemies) {
        enemy.translateX = randomEnemyInitPosition();
        enemy.translateY = randomEnemyInitPosition();
    }
}
// http://gpwiki.org/index.php/C:Collision_detection_between_two_circles
function checkCircleCollision(c1X:Number,c1Y:Number,c1R:Number,c2X:Number,c2Y:Number,c2R:Number):Boolean {
    var distanceSquared = ((c1X - c2X) * (c1X - c2X)) +  ((c1Y - c2Y) * (c1Y - c2Y));
    var radiiSquared = (c1R + c2R) * (c1R + c2R);

    if (radiiSquared > distanceSquared) {
        return true
    }

    return false
}

function randomEnemyInitPosition():Integer {
    var r = javafx.util.Math.random();
    var r2 = javafx.util.Math.random();
    ((r  * 100)+(r2*100)) as Integer
}

Stage {
    title: "Ballgame"
    scene: Scene {
        fill: Color.CHOCOLATE;
        width: 430, height: 400
        content: Group {
            focusTraversable: true
            translateX: 10, translateY:10
            content: [
                playingField,
                player,
                enemies,
                gameOverScreen,
                scoreArea
            ]
            onKeyPressed : function (e: KeyEvent){
              if (mode==MODE_GAME_OVER) {
                if (e.code == KeyCode.VK_ENTER) {
                    initGame();
                    timeline.playFromStart();
                }
              }
              if (e.code == KeyCode.VK_LEFT) {
                    moveLeft = true;
              }
              if (e.code == KeyCode.VK_RIGHT) {
                    moveRight = true;
              }
              if (e.code == KeyCode.VK_UP) {
                    moveUp = true;
              }
              if (e.code == KeyCode.VK_DOWN) {
                    moveDown = true;
              }
            }
            onKeyReleased : function (e: KeyEvent){
              if (e.code == KeyCode.VK_LEFT) {
                    moveLeft = false;
              }
              if (e.code == KeyCode.VK_RIGHT) {
                    moveRight = false;
              }
              if (e.code == KeyCode.VK_UP) {
                    moveUp = false;
              }
              if (e.code == KeyCode.VK_DOWN) {
                    moveDown = false;
              }
            }
        }
    }
}

// Start game
timeline.playFromStart();
</code></pre>
<p><i>Enemy.fx</i></p>
<pre><code>
/*
 * Enemy.fx
 *
 * Created on 03.10.2009, 13:59:33
 */

package myballgame;

import javafx.scene.CustomNode;
import javafx.scene.Node;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;

/**
 * @author Alexander Gnodtke
 */

public static def DEFAULT_FILL = Color.CRIMSON;

public class Enemy extends CustomNode {

    public var bonusMode = false;
    public var bonusWasHit = false; // Player hit in Bonus Mode

    var radius = 10;
    var moveUp = false;
    var moveLeft = false;
    var speedX = 0;
    var speedY = 0;

    var enemy:Circle;

    override function create():Node {

        // Enemy Speed
        speedX = calcSpeed();
        speedY = calcSpeed();

        // Enemy initial Direction
        moveUp = calcRandomBoolean();
        moveLeft = calcRandomBoolean();

        // Enemy figure
        enemy = Circle {
            radius: radius
            fill: Color.CRIMSON
        }
        return enemy
    }

    public function fill(color:Color) {
        enemy.fill = color;
    }

    function calcSpeed():Integer {
       var r = javafx.util.Math.random();
       if (r>0.66){
            return 3
        } else if (r<0.33) {
            return 2
        } else {
            return 1
        }
    }

    function calcRandomBoolean():Boolean {
        if (javafx.util.Math.random()>0.5)
            return true
        else
            return false
    }

    public function calcPosition(xMin:Integer,xMax:Integer,yMin:Integer,yMax:Integer) {
        if (moveUp) {
            var newY= translateY - speedY;
            if (newY > yMin + radius)
                translateY = newY
            else
                moveUp = false
        } else {
            var newY= translateY + speedY;
            if (newY &#060; yMax - radius)
                translateY = newY
            else
                moveUp = true
        }
        if (moveLeft) {
            var newX = translateX - speedX;
            if (newX &#062; xMin + radius)
                translateX = newX
            else
                moveLeft = false
        } else {
            var newX = translateX + speedX;
            if (newX &#060; xMax - radius)
                translateX = newX
            else
                moveLeft=true
        }
    }
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.exprimeit.co.uk/?feed=rss2&amp;p=159</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
