<?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>Code3 &#187; AJAX</title>
	<atom:link href="http://www.code3.dk/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.code3.dk</link>
	<description>Techchat</description>
	<lastBuildDate>Thu, 17 Nov 2011 13:10:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Dependent dropdowns in Grails</title>
		<link>http://www.code3.dk/dependent-dropdowns-in-grails/</link>
		<comments>http://www.code3.dk/dependent-dropdowns-in-grails/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 10:46:25 +0000</pubDate>
		<dc:creator>AN</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Grails]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=324</guid>
		<description><![CDATA[It does really seem to be a very common problem with the dependend or chained drop-downs. At least it was [...]]]></description>
			<content:encoded><![CDATA[<p>It does really seem to be a <a href="http://www.code3.dk/dependent-dropdowns-in-seam-and-richfaces/">very common problem</a> with the dependend or chained drop-downs. At least it was one of the first problems I faced in the Grails app I&#8217;m working on now.</p>
<p>The solution is not really more or less elegant than the one for Seam and Richfaces. I followed <a href="http://www.grails.org/AJAX-Driven+SELECTs+in+GSP">the guide on Grails.org</a> but decided to make the solution a bit more general. So I pass the name of the select-element-to-update as a string to the update function. This way I can also put the function in a separate file for inclusion (updateselect.js).</p>
<pre class="brush: javascript">
function updateSelect(e, elemId) {
// The response comes back as a bunch-o-JSON
var values = eval(&quot;(&quot; + e.responseText + &quot;)&quot;) // evaluate JSON

if (values) {
updateSelectFromJSON(values, elemId);
}
}

function updateSelectFromJSON(values, elemId) {
var rselect = document.getElementById(elemId)
// 	Clear all previous options
rselect.options.length = 0

// Rebuild the select
for (var i=0; i &lt; values.length; i++) {
var opt = document.createElement(&#039;option&#039;);
opt.text = values[i].name
opt.value = values[i].id
try {
rselect.add(opt, null) // standards compliant; doesn&#039;t work in IE
} catch(ex) {
rselect.add(opt) // IE only
}
}
}
</pre>
<p>Which is then called like this</p>
<pre class="brush: xml">

...

&lt;form&gt;
optionKey=&quot;id&quot; optionValue=&quot;name&quot; name=&quot;country.name&quot; id=&quot;country.name&quot; from=&quot;${Country.list()}&quot;
onchange=&quot;${remoteFunction(
controller:&#039;country&#039;,
action:&#039;ajaxGetCities&#039;,
params:&#039;&#039;id=&#039; + escape(this.value)&#039;,
onComplete:&#039;&#039;&#039;updateSelect(e, &#039;city&#039;)&#039;&#039;&#039;)}&quot;
&gt;

&lt;/form&gt;</pre>
<p>One thing is missing from this solution, though. Unlike the solution on grails.org, the chained select is not updated based on the default value of the previous select. This can be fixed by inserting the following in the head element of the .gsp page.</p>
<pre class="brush: xml">

function init() {
document.cityform[&#039;country.name&#039;].onchange();
}
window.onload = init;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/dependent-dropdowns-in-grails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy web shells – ajaxgroovyshell</title>
		<link>http://www.code3.dk/groovy-web-shells-%e2%80%93-ajaxgroovyshell/</link>
		<comments>http://www.code3.dk/groovy-web-shells-%e2%80%93-ajaxgroovyshell/#comments</comments>
		<pubDate>Tue, 19 May 2009 14:16:39 +0000</pubDate>
		<dc:creator>AN</dc:creator>
				<category><![CDATA[Techchat]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[JEE]]></category>

		<guid isPermaLink="false">http://www.code3.dk/?p=298</guid>
		<description><![CDATA[For the JEE web-app I am currently working on the main audience is power users/admins. So while I can code [...]]]></description>
			<content:encoded><![CDATA[<p>For the JEE web-app I am currently working on the main audience is power users/admins. So while I can code some usecases as nice seam pages that help the user solve a task, other usecase are difficult. The most difficult are the general batch processes that take the form &#8220;select, filter, apply&#8221;.</p>
<p>Unix users (who use shell scripts) know that a small amount of programming is effective at solving these problems. So for my web-app I was contemplating how to get something &#8220;shell-like&#8221; into the project. There are several projects that present a nice AJAX based web interface to the system shell on unix machines. Eg. <a href="http://code.google.com/p/shellinabox">shellinabox</a> and <a href="http://antony.lesuisse.org/software/ajaxterm/">ajaxterm</a>. And there are several programming languages that seem suited for interacting with a Java app. Eg. <a href="http://groovy.codehaus.org/">Groovy</a>, Jython, or Beanshell.</p>
<p>So I decided to try to combine the interactive groovy shell with an ajax frontend. After looking around quite a lot I found shellinabox which has a nice GPL&#8217;ed javascript vt100 front end (I found another <a href="http://fzort.org/bi/o.php">here</a> which is LGPL&#8217;ed).</p>
<p>After a some weekend studies of shellinabox I could make a prototype with the vt100.js of shellabox and the nice little python webserver of ajaxterm. With a little more hacking I was able to hook up the groovyshell as a web-app through a java servlet. The interactive performance sucked, because of some weirdness in standard java.io.PipedInput/OutputStream classes, but fortunately I was not the first with that problem so with some small hacks to the replacement classes from <a href="http://www.live-graph.org">LiveGraph</a> the interactivity became tolerable.</p>
<p>From this working state there is actually still quite a bit of work to have something that I can deploy on a customer production server. But when Guillaume Laforge announced his cool little app <a href="http://groovyconsole.appspot.com/">&#8220;GroovyWebConsole&#8221;</a> to run a groovyshell on the Google AppEngine I figured that I might as well upload what I had and announce it as well. Here is the announcement I sent to groovy-users</p>
<blockquote><p>I have made a similar app to administer a JEE app I&#8217;m doing. It is<br />
similar but is stateful and uses a vt100 interpreter in javascript (from<br />
shellinabox).</p>
<p>You can find it here</p>
<p><a href="http://code.google.com/p/ajaxgroovyshell">http://code.google.com/p/ajaxgroovyshell</a></p>
<p>It is mostly a prototype &#8211; to be really useful for me I need to add</p>
<p>1) Access control<br />
2) A way to paste text from the system (a pop-up textarea?)<br />
3) Proper sessions<br />
4) A robust way to handle threads<br />
5) Syntax highlighting?<br />
6) Better tab completion in GroovyShell (more like ipython)<br />
Unfortunately it won&#8217;t run on the Google AppServer since I need a thread<br />
for the GroovyShell.</p>
<p>Best<br />
Anders
</p></blockquote>
<p>Since then I have noticed several java server projects that have some kind of console facility. But not as an ajax webpage (yet). I have suggested it a couple of places (like <a href="http://weblogs.java.net/blog/kohsuke/archive/2009/05/hudson_cli_and.html">for Hudson</a>, and <a href="http://in.relation.to/11439.lace">for FRESH</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.code3.dk/groovy-web-shells-%e2%80%93-ajaxgroovyshell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

