<?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/"
	>

<channel>
	<title>mind the content</title>
	<atom:link href="http://jan.kuzniak.pl/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://jan.kuzniak.pl</link>
	<description>jan kuźniak - the content guy</description>
	<pubDate>Sun, 18 Jul 2010 21:14:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>vibrant ink textmate theme for eclipse</title>
		<link>http://jan.kuzniak.pl/?p=155</link>
		<comments>http://jan.kuzniak.pl/?p=155#comments</comments>
		<pubDate>Wed, 09 Jun 2010 22:55:55 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[dev]]></category>

		<category><![CDATA[eclipse]]></category>

		<category><![CDATA[textmate]]></category>

		<category><![CDATA[theme]]></category>

		<category><![CDATA[vibrant ink]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=155</guid>
		<description><![CDATA[The first time I&#8217;ve seen a MacBook was the first time I&#8217;ve seen the Textmate editor. On that day I fell in love with the Vibrant Ink colour theme it&#8217;s owner was using.

It was aesthetic, it was colourful, it didn&#8217;t tire my eyes as much as my default black-on-white Eclipse editor. On that day I [...]]]></description>
			<content:encoded><![CDATA[<p>The first time I&#8217;ve seen a MacBook was the first time I&#8217;ve seen the <a href="http://macromates.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/macromates.com');">Textmate editor</a>. On that day I fell in love with the Vibrant Ink colour theme it&#8217;s owner was using.</p>
<p><a href="downloads/vibrantink/helios-vibrant-ink-1.0.zip"><img src="img/vibrantink.png" alt="vibrant ink" /></a></p>
<p>It was aesthetic, it was colourful, it didn&#8217;t tire my eyes as much as my default black-on-white Eclipse editor. On that day I found an <a href="http://blog.codefront.net/2006/09/28/vibrant-ink-textmate-theme-for-eclipse/" onclick="javascript:pageTracker._trackPageview('/outbound/article/blog.codefront.net');">Eclipse version</a> of the theme which, with some small modifications, I&#8217;ve been using since then.</p>
<p>The mentioned Eclipse version, while nice, had some problems. Colouring wasn&#8217;t consistent between editors, some of them were not configured and code was unreadable on a black background, also some colours were different than the original. It was slightly irritating, but not enough to do something about it. Until today.</p>
<p>I took the <a href="http://alternateidea.com/blog/articles/2006/01/03/textmate-vibrant-ink-theme-and-prototype-bundle" onclick="javascript:pageTracker._trackPageview('/outbound/article/alternateidea.com');">original theme</a>, merged with what I got before and applied consistently across editors. What I got is much closer to the original: the only things I changed deliberately are background (greyish - to reduce contrast) and keyword colour (a bit less saturated). Also the 11px <a href="http://en.wikipedia.org/wiki/Monaco_%28typeface%29" onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');">Monaco font</a> is much better than the Eclipse&#8217;s default Courier New used in the original Eclipse version. I configured all the editors I had, i.e.: text, structured text, ant, java, javascript, php, css, html, dtd, xml, xsl. The configuration was tested on Eclipse 3.6 (Helios) RC 2, but should work well with both earlier and future releases.</p>
<p>To install the theme you need to install the font (if you don&#8217;t have it yet) and then import the eclipse preferences file (File -&gt; Import -&gt; Preferences). The file is stripped and contains only syntax colouring configuration, but anyway, I recommend making a backup of your preferences before applying the theme (File -&gt; Export -&gt; Preferences).</p>
<p>Download <a href="downloads/vibrantink/helios-vibrant-ink-1.1.zip">here</a> and enjoy!</p>
<p><strong>update (2010-07-18):</strong><br />
I added the support for CDT editors (C&nbsp;/&nbsp;C++ and Makefile)!</p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=155</wfw:commentRss>
		</item>
		<item>
		<title>photo day 5.0 - teatr polski</title>
		<link>http://jan.kuzniak.pl/?p=147</link>
		<comments>http://jan.kuzniak.pl/?p=147#comments</comments>
		<pubDate>Sat, 24 Oct 2009 13:18:48 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[gallery]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=147</guid>
		<description><![CDATA[
Today I decided to dust off my trusty camera and join a jolly company of photographers visiting Teatr Polski. The event was organised by mmpoznan.pl and we were allowed to visit the deepest recesses of the theatre. Which we did.
As usual I tried to do something out of ordinary rather than run around and take [...]]]></description>
			<content:encoded><![CDATA[<div class="gallery"><a href="gallery/photo_day_5.0/"><img src="gallery/photo_day_5.0/thumbs/DSC_4477.jpg" alt="photo day 5.0" /></a></div>
<p>Today I decided to dust off my trusty camera and join a jolly company of photographers visiting Teatr Polski. The event was organised by <a href="http://www.mmpoznan.pl/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.mmpoznan.pl');">mmpoznan.pl</a> and we were allowed to visit the deepest recesses of the theatre. Which we did.</p>
<p>As usual I tried to do something out of ordinary rather than run around and take dozens of pictures. Yet  another picture of the scene is boring, plus I don&#8217;t have either an adequate lens or a proper tripod to take one. I&#8217;ve focused on some details I&#8217;ve dug up and did one good close up by the entrance. The gallery is <a href="gallery/photo_day_5.0/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=147</wfw:commentRss>
		</item>
		<item>
		<title>communiqué as a windows service</title>
		<link>http://jan.kuzniak.pl/?p=130</link>
		<comments>http://jan.kuzniak.pl/?p=130#comments</comments>
		<pubDate>Sun, 22 Mar 2009 19:31:39 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[communiqué]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=130</guid>
		<description><![CDATA[When running CQ on Windows there is a common issue everyone runs into: how to install it as a Windows service? There are basically two ways: the built-in (automatic) and the manual.
built-in way
This one is available for CQ 4 only - one has to open Communiqué Manager and click File -&#62; Register Service. The Service [...]]]></description>
			<content:encoded><![CDATA[<p>When running CQ on Windows there is a common issue everyone runs into: how to install it as a Windows service? There are basically two ways: the built-in (automatic) and the manual.</p>
<h2>built-in way</h2>
<p>This one is available for CQ 4 only - one has to open Communiqué Manager and click <strong>File</strong> -&gt; <strong>Register Service</strong>. The Service will appear in Window&#8217;s administrative tools -&gt; services</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-133" title="register service" src="http://jan.kuzniak.pl/wp-content/uploads/2009/03/register_service_small.png" alt="register service" width="450" height="176" /></p>
<p>Ta-da-da, but&#8230; we&#8217;ve encountered multiple issues with this approach. The most serious is that <strong>all</strong> instances are starting up / stopping with the service - one can no choose to start/stop single instance. If you need this functionality: you have to do it manually.</p>
<h2>installing service manually</h2>
<p>First thing you need is a <tt>cqsvc.exe</tt> tool located in CQ 4 installation directory under <tt>opt\helpers\cqsvc.exe</tt>. To install a service, you execute it with the following arguments:</p>
<ul>
<li><tt>-i</tt></li>
<li><tt>-n <em>&lt;service name&gt;</em></tt></li>
<li><tt>-e <em>&lt;full path to </em></tt><tt><em>java</em></tt><tt><em>.exe&gt;</em></tt></li>
<li><tt>-w <em>&lt;workdir&gt;</em></tt></li>
<li><tt>-a <em>&lt;arguments&gt;</em></tt></li>
<li><tt>-o <em>&lt;outfile (log)&gt;</em></tt></li>
<li><tt>-t <em>&lt;timeout&gt;</em></tt></li>
</ul>
<p>example:<br />
<tt>cqsvc -i -n &#8220;communique4401&#8243;<br />
-e &#8220;C:\Program Files\Java\jdk1.5.0_16\bin\java.exe&#8221;<br />
-w &#8220;D:\Day\CQ-4.2.1\server&#8221;<br />
-a &#8220;-Xrs -Xms512m -Xmx768m -XX:PermSize=256m<br />
-XX:MaxPermSize=256m -jar bin/bootstrap.jar&#8221;<br />
-o &#8220;D:\Day\CQ-4.2.1\server\outfile.log&#8221;<br />
-t 180</tt></p>
<p>Ta-da-da - your service appeared under the name you selected. Now you can install instances as a separate services - each one with a different name. Note that this tool can be used for CQ 5 as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=130</wfw:commentRss>
		</item>
		<item>
		<title>writing mvc framework in cq4 (part 3)</title>
		<link>http://jan.kuzniak.pl/?p=94</link>
		<comments>http://jan.kuzniak.pl/?p=94#comments</comments>
		<pubDate>Sun, 15 Mar 2009 19:18:39 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[communiqué]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=94</guid>
		<description><![CDATA[ photo credit: Brian Auer
In the first part of this little tutorial I&#8217;ve shown three major problems I encountered when building a CQ 4 framework. Two of them were solved in the previous post, leaving the persistence one for today. Once again, what it&#8217;s about: let&#8217;s assume you&#8217;ve got your shiny new project with Java [...]]]></description>
			<content:encoded><![CDATA[<div class="gallery"><a href="http://www.flickr.com/photos/29814800@N00/2249169858/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.flickr.com');" title="Tonka" target="_blank"><img src="http://farm3.static.flickr.com/2023/2249169858_8300a11906_t.jpg" alt="Tonka" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by-nc-nd/2.0/" onclick="javascript:pageTracker._trackPageview('/outbound/article/creativecommons.org');" title="Attribution-NonCommercial-NoDerivs License" target="_blank"><img src="http://jan.kuzniak.pl/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.photodropper.com');" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/29814800@N00/2249169858/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.flickr.com');" title="Brian Auer" target="_blank">Brian Auer</a></small></div>
<p>In the <a href="http://jan.kuzniak.pl/?p=29" >first part</a> of this little tutorial I&#8217;ve shown three major problems I encountered when building a CQ 4 framework. Two of them were solved in the previous post, leaving the persistence one for today. Once again, what it&#8217;s about: let&#8217;s assume you&#8217;ve got your shiny new project with Java controller and JSP view, the data you&#8217;re about to use to create your model are stored in pages as a set of atoms, containers and container lists. The simplest way of accessing them is by using e.g.:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Container</span> pageContent <span style="color: #339933;">=</span> page.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
ContainerList list <span style="color: #339933;">=</span> pageContent.<span style="color: #006633;">getContainerList</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;myData&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Container</span> content <span style="color: #339933;">=</span> list.<span style="color: #006633;">getContainer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Single&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Atom atom <span style="color: #339933;">=</span> content.<span style="color: #006633;">getAtom</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;myAtom&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> data <span style="color: #339933;">=</span> atom.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Though it&#8217;s scary, it works just fine. Though it works, it&#8217;s too damn easy to hide an error here. For pages storing multiple containers with many atoms inside, managing such a mapping has proven to be really tricky.</p>
<p>We at Cognifide have been struggling with this one for quite a while. The credit for the solution I am about to present goes mainly to Albert Cenkier who invented an automated mapper from a CQ container to a Java object. In order to build it we did the following assumptions:</p>
<ul>
<li>one CQ container is mapped to one java object (DTO),</li>
<li>an atom is mapped to the object field of the same name as atom&#8217;s label (case insensitive),</li>
<li>the above requires that all labels used are valid Java identifiers - we use camel case names.</li>
</ul>
<p>The mechanism we came up with uses reflection mechanism to find all the properties of a DTO class. It then tries to fetch atoms with the same labels as the fields from the given container. This approach is called &#8220;standard over configuration&#8221; - instead of the excessive layer enabling the most flexible and elaborate mapping (that you&#8217;re not ever going to use anyway) it introduces a standard solution at the cost of a few restrictions (that you most often abide to already).</p>
<p>Time for more implementation details. Here are some example code listings - not a complete solution, but should be enough to get you started. First - get all setters of a given class:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">Collection</span><span style="color: #666666; font-style: italic;">/* &lt;Method&gt; */</span>getSetters<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">Class</span> clazz<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">Method</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> methods <span style="color: #339933;">=</span> clazz.<span style="color: #006633;">getMethods</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Pattern pattern <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(set)([A-Z_]<span style="color: #000099; font-weight: bold;">\\</span>w+)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">Collection</span><span style="color: #666666; font-style: italic;">/* &lt;Method&gt; */</span>setters <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #666666; font-style: italic;">/* &lt;Method&gt; */</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> methods.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">String</span> methodName <span style="color: #339933;">=</span> methods<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>matcher.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      setters.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>methods<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now, to get those from a container and execute the setter:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">Object</span> mapContainerToObject<span style="color: #009900;">&#40;</span><span style="color: #003399;">Container</span> content, <span style="color: #003399;">Collection</span><span style="color: #666666; font-style: italic;">/* &lt;Method&gt; */</span>setters<span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
  Pattern pattern <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(get|set)([A-Z_]<span style="color: #000099; font-weight: bold;">\\</span>w+)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">Object</span> result <span style="color: #339933;">=</span> clazz.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> setters.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">Method</span> setter <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Method</span><span style="color: #009900;">&#41;</span> setters.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Matcher matcher <span style="color: #339933;">=</span> pattern.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>method.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> propertyName <span style="color: #339933;">=</span> matcher.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    propertyName <span style="color: #339933;">=</span> propertyName.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">+</span> propertyName.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>content.<span style="color: #006633;">hasElement</span><span style="color: #009900;">&#40;</span>propertyName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003399;">String</span> value <span style="color: #339933;">=</span> content.<span style="color: #006633;">getAtom</span><span style="color: #009900;">&#40;</span>propertyName<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      setter.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span>result, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> value <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Note - the above doesn&#8217;t implement case insensitivity and assumes that every value is a string. The implementation of those complicates the code significantly and I wanted to show the basic idea here. From this point however, it shouldn&#8217;t be much of a challenge to implement the following:</p>
<ul>
<li>mapping to any basic data type (string, integer, boolean, floating-point, date, etc.) based on Java field type and pre-defined parsing rules,</li>
<li>mapping container label to one specific field (essential for list&#8217;s parNum),</li>
<li>mapping a container list to a list of objects.</li>
</ul>
<p>In fact, it is possible to implement a complete hibernate-like solution for Communiqué. Just remember - do not over-complicate. This piece of code lies at the very basis of all your projects. If it&#8217;s clean and simple, anything built on it will be so as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=94</wfw:commentRss>
		</item>
		<item>
		<title>writing mvc framework in cq4 (part 2)</title>
		<link>http://jan.kuzniak.pl/?p=55</link>
		<comments>http://jan.kuzniak.pl/?p=55#comments</comments>
		<pubDate>Sun, 01 Mar 2009 12:17:50 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[communiqué]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=55</guid>
		<description><![CDATA[
 photo credit: The Talented Mr. Nimo
Recently we discussed the Communiqué framework concept in general.  Today let&#8217;s focus on those little details that will allow us to create such a framework.
First issue I encountered is: how to remove logic from the view? In the simplest cases one could use the &#60;cfc:atom&#62; tag to simply [...]]]></description>
			<content:encoded><![CDATA[<div class="gallery"><a title="Old Train Interior 5" href="http://www.flickr.com/photos/34639903@N03/3570423468/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.flickr.com');" target="_blank"><img src="http://farm4.static.flickr.com/3558/3570423468_da0ae98555_t.jpg" border="0" alt="Old Train Interior 5" /></a><br />
<small><a title="Attribution-NonCommercial-NoDerivs License" href="http://creativecommons.org/licenses/by-nc-nd/2.0/" onclick="javascript:pageTracker._trackPageview('/outbound/article/creativecommons.org');" target="_blank"><img src="http://jan.kuzniak.pl/wp-content/plugins/photo-dropper/images/cc.png" border="0" alt="Creative Commons License" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.photodropper.com');" target="_blank">photo</a> credit: <a title="The Talented Mr. Nimo" href="http://www.flickr.com/photos/34639903@N03/3570423468/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.flickr.com');" target="_blank">The Talented Mr. Nimo</a></small></div>
<p>Recently we discussed the Communiqué framework concept in general.  Today let&#8217;s focus on those little details that will allow us to create such a framework.</p>
<p>First issue I encountered is: how to remove logic from the view? In the simplest cases one could use the <code>&lt;cfc:atom</code>&gt; tag to simply output a stored value. Once the value has to be transformed, or fetched from other page, it gets complicated, and more and more logic tends to be introduced in the view. What we need here is a way for <strong>Controller</strong> to output his data on the page.</p>
<p>Let&#8217;s assume we&#8217;ve got this controller already as a Java class that hides all the business logic and persistence from us. We could output data from it using <code>&lt;%= controller.getValue() %&gt;</code> but that still won&#8217;t deliver us from putting logic in there<code>:<br />
&lt;%= controller.getValue().replaceAll("foo", "bar") %&gt;</code>.</p>
<p>Fortunatelly, there is salvation - provided by Day in the JSTL integration package.  Using JSTL c:out tag one can output any value that was previously set as a request attribute.</p>
<h2>example</h2>
<p>Now, exactly what does it mean for us? Let&#8217;s assume we&#8217;ve got the simplest controller:</p>
<pre name="code" class="java">

package pl.kuzniak.jan.myapp.controller;

import java.util.HashMap;
import java.util.Map;

import pl.kuzniak.jan.myapp.model.MyData;

import com.day.cq.delivery.DeliveryHttpServletRequest;

public class MyController {
public MyController(DeliveryHttpServletRequest cqRequest) {
protected final Map/* &lt;String, Object&gt; */model;
model = new HashMap/* &lt;String, Object&gt; */();
MyData data = new MyData();
data.setIndex(&quot;1&quot;);
model.put(&quot;myData&quot;, data);
cqRequest.setAttribute(&quot;model&quot;, model);
}
}
</pre>
<p>We can now use it in the JSP file just like that:</p>
<pre name="code" class="xml">

&lt;%@page pageEncoding=&quot;UTF-8&quot; contentType=&quot;text/html; charset=UTF-8&quot;

%&gt;&lt;%@taglib uri=&quot;/cfc&quot; prefix=&quot;cfc&quot;
%&gt;&lt;%@taglib uri=&quot;http://java.sun.com/jstl/core&quot; prefix=&quot;c&quot;

%&gt;&lt;%@page import=&quot;pl.kuzniak.jan.myapp.controller.MyController&quot;

%&gt;&lt;cfc:defineObjects/&gt;&lt;%
new MyController(cqRequest);
%&gt;

&lt;p&gt;&lt;c:out value=&quot;${model.myData.index}&quot; /&gt;&lt;/p&gt;
</pre>
<p>As you can see - we&#8217;ve got a read-only way of accessing values here. Except for the line with controller&#8217;s constructor, there is no business logic here. The only part of Java code is in fact a mapping between the view and the controller - something you could find as obfuscated XMLs in some popular Java frameworks.</p>
<h2>conclusion</h2>
<p>So, here we&#8217;ve got solution to the first problem:</p>
<ul>
<li> use cqRequest.setAttribute to pass a value to the view</li>
<li> use JSTL to output the value in a read-only manner</li>
</ul>
<p>Pros:</p>
<ul>
<li> it&#8217;s easy this way - developers will like it and won&#8217;t be searching ways around,</li>
<li> it&#8217;s clean - keeps Java code away from the markup,</li>
<li> it&#8217;s standard - utilises well known JSTL and Expression Language,</li>
<li> it&#8217;s easy to extend - it&#8217;s easy to write custom tags that support EL and can e.g. externalise links or format values while outputting them.</li>
</ul>
<p>Cons:</p>
<ul>
<li> often requires extra effort to write a proper taglib instead of creating HTML markup from the controller itself.</li>
<li> reduced plain code readability (it&#8217;s slightly better with syntax highlighting, but still&#8230;); example:
<pre>&lt;body class="&lt;c:out value="${model.body.htmlClass}"; /&gt;"&gt;</pre>
</li>
</ul>
<p>If something is unclear - please comment. Next time I will talk about data persistence in CQ 4.</p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=55</wfw:commentRss>
		</item>
		<item>
		<title>writing mvc framework in cq4 (part 1)</title>
		<link>http://jan.kuzniak.pl/?p=29</link>
		<comments>http://jan.kuzniak.pl/?p=29#comments</comments>
		<pubDate>Sun, 22 Feb 2009 09:49:15 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[communiqué]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=29</guid>
		<description><![CDATA[
 photo credit: kairin
In the next few articles I would like to give you some guidance in writing a MVC framework for Communiqué 4.2. Why 4.2 you ask - good question. With the version 5.1 finally out, I should probably be concentrating on it. The main reason is that clients still like CQ4, and most [...]]]></description>
			<content:encoded><![CDATA[<div class="gallery"><a title="25 most randomnest things as tagged by my friend shan" href="http://www.flickr.com/photos/57433821@N00/3243711366/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.flickr.com');" target="_blank"><img src="http://farm4.static.flickr.com/3107/3243711366_2ec4f65fc2_t.jpg" border="0" alt="25 most randomnest things as tagged by my friend shan" /></a><br />
<small><a title="Attribution-NonCommercial-NoDerivs License" href="http://creativecommons.org/licenses/by-nc-nd/2.0/" onclick="javascript:pageTracker._trackPageview('/outbound/article/creativecommons.org');" target="_blank"><img src="http://jan.kuzniak.pl/wp-content/plugins/photo-dropper/images/cc.png" border="0" alt="Creative Commons License" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.photodropper.com');" target="_blank">photo</a> credit: <a title="kairin" href="http://www.flickr.com/photos/57433821@N00/3243711366/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.flickr.com');" target="_blank">kairin</a></small></div>
<p>In the next few articles I would like to give you some guidance in writing a MVC framework for Communiqué 4.2. Why 4.2 you ask - good question. With the version 5.1 finally out, I should probably be concentrating on it. The main reason is that clients still like CQ4, and most likely in 2009 there will still be a lot of new projects written on the old version of the platform, while we will be learning how to write in CQ5 and how to do it right.</p>
<p>Why would I want to write this framework? The default approach presented in examples provided with the default installation is lightweight, easy and quick - that&#8217;s true. In the long term, however, I&#8217;ve found it hard to scale and manage. It&#8217;s hard to force standards and QA Ecma scripts, plus, they tend to get complicated while developers hack they way through issues. Separation of concepts and putting them into layers simplifies architecture, and the cost of creating bloated codebase is compensated by the ease of supporting such a project. And the only way I know to help development team avoid messy projects is to create a framework.</p>
<p>Before I continue let me explain what I understand by framework. A framework is a solution to a high-level problem (here - creating web sites in CQ). This solution is provided incomplete but it can easily be extended and adapted to a given case (web site X in CQ). The spots that will be extended / overriden by the developer are clearly specified by the framework. Framework must be general enough to be reusable across the projects, while strictly enforcing solving similar problems in the same way, it must be easy to learn and hard to bypass.</p>
<p>Now, let&#8217;s have a look at CQ and see if we can define Model, View and Controller here.</p>
<ul>
<li>Model - data displayed on the page. These data are probably persistent somewhere, have some business rules, are associated with default values  and will be displayed somewhere - but the model is unaware of all that. It just stores plain data - no logic, no formatting - it&#8217;s raw.</li>
<li>View - a JSP page generating HTML, CSS, JavaScript and so on. It is responsible for formatting data and displaying them correctly. View doesn&#8217;t care about where the data came from and has as little logic inside as possible.</li>
<li>Controller - A Java class responsible for calling the persistence layer to retrieve the model, applying business rules and default values to it and passing it to the view. It doesn&#8217;t care what the view is - it just creates the model and exposes it so that it is visible to the view.</li>
</ul>
<p>The problems that lie ahead are:</p>
<ul>
<li>How to combine controller and view? In Communiqué the page is associated with the template, and template defines one entry point - the JSP script (view). How to define a controller while keeping the logic away from the view?</li>
<li>How to pass the model to the view? How to expose Java objects to the JSP file so that it would be impossible (or at least hard) to modify them from the view?</li>
<li>How to solve persistence in an easy and effective way? Most of the data will be stored in the Content Bus. How to enforce a standard but flexible mechanism for mapping them to model objects? This operation seems easy but is very error-prone when done manually (especially when refactoring).</li>
</ul>
<p>In the next article I will answer those questions and try to provide some examples for improved readability, so keep reading!</p>
<p><em>Cheers,<br />
Jan</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=29</wfw:commentRss>
		</item>
		<item>
		<title>karpacz</title>
		<link>http://jan.kuzniak.pl/?p=46</link>
		<comments>http://jan.kuzniak.pl/?p=46#comments</comments>
		<pubDate>Sun, 01 Feb 2009 10:32:24 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[gallery]]></category>

		<category><![CDATA[trip]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=46</guid>
		<description><![CDATA[
Some time ago I went mountain hiking with my friends. We left Friday afternoon and left on Sunday so it was short, but intense. Snow had just fallen making the nature pure and beautiful - heaven for a man with his camera. Once again - thanks mates for taking me away from my computer and [...]]]></description>
			<content:encoded><![CDATA[<div class="gallery"><a href="gallery/karpacz08/"><img src="gallery/karpacz08/thumbs/DSC_2933_hdr.jpg" alt="hdr" /></a></div>
<p>Some time ago I went mountain hiking with my friends. We left Friday afternoon and left on Sunday so it was short, but intense. Snow had just fallen making the nature pure and beautiful - heaven for a man with his camera. Once again - thanks mates for taking me away from my computer and running me ragged over the hills.</p>
<p>See what I&#8217;ve seen <a href="gallery/karpacz08/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=46</wfw:commentRss>
		</item>
		<item>
		<title>hdr revisited</title>
		<link>http://jan.kuzniak.pl/?p=22</link>
		<comments>http://jan.kuzniak.pl/?p=22#comments</comments>
		<pubDate>Sun, 07 Sep 2008 23:11:15 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[gallery]]></category>

		<category><![CDATA[hdr]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=22</guid>
		<description><![CDATA[
It still takes me a while to get a good HDR picture. Not only because of a large space of parameters I have to search to make sure I produced the best result, but mostly because I cannot tell for sure if the picture I am taking at the moment will be a good source [...]]]></description>
			<content:encoded><![CDATA[<div class="gallery"><a href="gallery/hdr2/"><img src="gallery/hdr2/thumbs/DSC_2386_hdr_crop2.jpg" alt="hdr" /></a></div>
<p>It still takes me a while to get a good HDR picture. Not only because of a large space of parameters I have to search to make sure I produced the best result, but mostly because I cannot tell for sure if the picture I am taking at the moment will be a good source for the algorythm when I sit in front of my monitor. Maybe it will come with time&#8230;</p>
<p>Look at <a href="gallery/hdr2/">what I&#8217;ve done</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=22</wfw:commentRss>
		</item>
		<item>
		<title>my first hdr</title>
		<link>http://jan.kuzniak.pl/?p=19</link>
		<comments>http://jan.kuzniak.pl/?p=19#comments</comments>
		<pubDate>Sun, 22 Jun 2008 17:18:20 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[gallery]]></category>

		<category><![CDATA[hdr]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=19</guid>
		<description><![CDATA[
Ok, after some experiments and with my friend Albert I think I nailed the whole HDR thing down. I take under exposed (exposure: -2.0) picture, store it in RAW format and then create 9 exposures (from -2.0 to 2.0) out of it. Merging those into one is the hardest part because I have to play [...]]]></description>
			<content:encoded><![CDATA[<div class="gallery"><a href="gallery/hdr/"><img alt="hdr" src="gallery/hdr/thumbs/DSC_1981_hdr3.jpg" / /></a></div>
<p>Ok, after some experiments and with my friend Albert I think I nailed the whole <a href="http://en.wikipedia.org/wiki/High_dynamic_range_imaging" onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');">HDR</a> thing down. I take under exposed (exposure: -2.0) picture, store it in RAW format and then create 9 exposures (from -2.0 to 2.0) out of it. Merging those into one is the hardest part because I have to play with rather nonintuitive parameters of the algorithm, but the result is worth it. It might not be the best HDR images I&#8217;ve seen, and they might look a little bit artificial, but still the result is better than I expected. <a href="about:gallery/hdr/">Check it out!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=19</wfw:commentRss>
		</item>
		<item>
		<title>dance photos</title>
		<link>http://jan.kuzniak.pl/?p=18</link>
		<comments>http://jan.kuzniak.pl/?p=18#comments</comments>
		<pubDate>Wed, 18 Jun 2008 20:05:17 +0000</pubDate>
		<dc:creator>jan</dc:creator>
		
		<category><![CDATA[gallery]]></category>

		<guid isPermaLink="false">http://jan.kuzniak.pl/?p=18</guid>
		<description><![CDATA[
That&#8217;s the first time I took photos of dancing people. I didn&#8217;t before because it always was too dark for my old camera. Even now with a Nikon D80 and a f/2 fast lens I had problems and the pictures are not TAC sharp nor the white balance is perfect (hence many b&#38;w images). Still [...]]]></description>
			<content:encoded><![CDATA[<div class="gallery"><a href="gallery/dance/"><img alt="dance" src="gallery/dance/thumbs/DSC_2046_g.jpg" / /></a></div>
<p>That&#8217;s the first time I took photos of dancing people. I didn&#8217;t before because it always was too dark for my old camera. Even now with a Nikon D80 and a f/2 fast lens I had problems and the pictures are not TAC sharp nor the white balance is perfect (hence many b&amp;w images). Still I am happy with those, especially that I made them with fixed 35mm lens. <a href="gallery/dance/">Have a look</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jan.kuzniak.pl/?feed=rss2&amp;p=18</wfw:commentRss>
		</item>
	</channel>
</rss>
