Kwa Kil On Swa

Thursday, March 15, 2007

Debugging struts action configuration

Not tried it yet, but looks interesting
http://struts.apache.org/2.x/docs/config-browser-plugin.html

dojo "failed loading" problems

If you get a problem like this

DEBUG: failed loading /fims/struts/dojo/src/__package__.js with error: [SyntaxError: syntax error,

First thing to try is to DELETE the cache in IE or FIREFOX cache. This fixed the problem for me.
(After an upgrade of struts, which upgraded dojo).

Logging all access in tomcat

conf/server.xml has the following section, which can be uncommented to provide full access logging to all files (can be useful for debugging dojo problems etc.)

<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>

But be careful -- starting tomcat from eclipse can *recomment* the valve. (I switched off all publishing in the eclipse tomcat server configuration "Automatic Publishing" and the "edit" link

Saturday, March 10, 2007

appfuse window.onload defined in global.js

Appfuse defines window.onload in global.js and as this is usually includes by all jsps, its NOT a good idea to define <body onload="myOnLoadFunction()"> as this overrides the window.onload function set up by global.js

So what does the appfuse window.onload function do?

3 things:
1) highlightFormElements() - this gives you the yellow background when you mouseover form fields
2) Scriptaculous effect to highlight the appfuse standard success and failure messages
3) Installs handlers for the mouseover on the top level menus (not important for popups)

So rather than a <body onload="myOnLoadFunction()">

you should say,

var previousWindowOnLoadFn = window.onload

window.onload = function() {
myOnLoadFunction();
previousWindowOnLoadFn();
}

Thursday, March 01, 2007

javascript fun, copying table rows with innerHTML or cloneNode()

I discovered two ways of copying a row from one html table to another.

One way is by using the innerHTML attribute of each cell, to copy across the content of each cell.

The other way is to use cloneNode() which is supposedly more standards compliant as there is no spec for w3c innerHTML spec.

But there are problems with the innerHTML approach in firefox 1.5 (See comp.lang.javascript " Preserving input values in innerHTML with Mozilla" http://groups.google.co.uk/group/comp.lang.javascript/browse_thread/thread/ee1d0533b9abda48/bda10d752dfdd215?lnk=st&q=firefox+innerHTML+input+value&rnum=2&hl=en#bda10d752dfdd215)

The problem is that once you set set the target row content with innerHTML, any changes the user makes to any input fields in the table row are not retrievable using innerHTML. Its remains a sort of snapshot of when it was first set. (Firefox 1.5 (not sure about 2.0))

The cloneNode(true) does a deep clone of a dom tree and is decribed here http://www.pxl8.com/cloneNode.html. The problem is that in IE6 it will not copy between windows which is the scenario, that I am trying to use it in. The problem is described here (look for IE cannot handle cross-window DOM node manipulation): http://www.codingforums.com/showthread.php?p=342582