<?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>Spackos62-Java Blog &#187; EL</title>
	<atom:link href="http://java.randgestalten.de/index.php/tag/el/feed/" rel="self" type="application/rss+xml" />
	<link>http://java.randgestalten.de</link>
	<description>java related stuff</description>
	<lastBuildDate>Fri, 02 Oct 2009 02:08:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>BeansBinding ELProperty as simple template engine</title>
		<link>http://java.randgestalten.de/index.php/2008/10/beansbinding-elproperty-as-simple-template-engine/</link>
		<comments>http://java.randgestalten.de/index.php/2008/10/beansbinding-elproperty-as-simple-template-engine/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 00:55:55 +0000</pubDate>
		<dc:creator>Thasso</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[BeansBinding]]></category>
		<category><![CDATA[EL]]></category>

		<guid isPermaLink="false">http://java.randgestalten.de/?p=77</guid>
		<description><![CDATA[I just read an article about using adding EL support on your projects and I was looking for a nice alternative to Velocity anyways.
I know EL basics from BeansBinding, which I use in most of my UI projects. EL itself looks pretty interesting, but, well, sort of complicated. Even finding the proper jar files seems [...]]]></description>
			<content:encoded><![CDATA[<p>I just read an article about using <a href="http://weblogs.java.net/blog/felipeal/archive/2008/10/adding_el_suppo.html">adding EL support on your projects</a> and I was looking for a nice alternative to Velocity anyways.</p>
<p>I know EL basics from <a href="https://beansbinding.dev.java.net/">BeansBinding</a>, which I use in most of my UI projects. EL itself looks pretty interesting, but, well, sort of complicated. Even finding the proper jar files seems to be a problem, or at least <em>&#8220;another of life&#8217;s obscure mysteries&#8221;</em> and using EL for a simple search and replace example implies implementing some  <em>internals</em>. I was looking for something that I can just use.</p>
<p>Luckily, the first comment mentions the ELProperty class from BeansBinding, and that jar is just a few mouse clicks away, so I thought I give it a try&#8230;and&#8230;well&#8230;it works <img src='http://java.randgestalten.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span id="more-77"></span></p>
<pre class="code"><code>public static void main(String[] args) {
    Person mom = new Person("Ann", null);
    Person son = new Person("Dave", mom);
    Dog dog = new Dog("Foxy");

    ELProperty el = ELProperty
            .create("${name}'s mom is ${mother.name}");
    System.out.println(el.getValue(son));

    ELProperty mapEL = ELProperty
            .create("${mother.name}'s dog is ${dog.name}");
    Map map = new HashMap();
    map.put("mother", mom);
    map.put("dog", dog);
    System.out.println(mapEL.getValue(map));
}</code></pre>
<p>ELProperty.create() creates a new instance from a template string. You can fill the template with values using getValue() method. This one takes either an Object with proper getter methods or a Map to resolve variables. And this is the result of the simple example:</p>
<pre><code>Dave's mom is Ann
Ann's dog is Foxy</code></pre>
<p><a href="http://java.randgestalten.de/files/ELBeansTest.java">Full Sample Code</a> ( You need the beansbinding jar in the classpath)</p>
]]></content:encoded>
			<wfw:commentRss>http://java.randgestalten.de/index.php/2008/10/beansbinding-elproperty-as-simple-template-engine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
