Kwa Kil On Swa

Friday, January 18, 2008

Test post

This is a test post to see what has happened to the blogger layout.

It doesn't display in firefox properly - only 2 posts displayed in firfox - all posts displayes in IE6

Wednesday, October 10, 2007

Windows remote desktop connecting to console

normally remote desktop connects to a terminal session and not to the console. However if you run it from the command line tho you can specify that you want to connect to the console.

C:> %SystemRoot%\system32\mstsc.exe /console /v:

If you leave out the /v it will come up with the normal prompt for a server name.

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

Monday, January 22, 2007

JSP Errors

This is a nasty error to debug- all I got was this:

org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
Type mismatch: cannot convert from null to int
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)


To debug it, try setting

<property name="jsp.precompile" value="false"/>

(UPDATE: Did I mean <property name="precompile.jsp" value="true"/>)

and then rebuild

I got an error message telling me exactly where the problem was

Monday, January 15, 2007

Diff tools for PostgreSQL database schemas

From files:
apgdiff.sourceforge.net

from DB or files:
pgdiff.sourceforge.net

Saturday, January 13, 2007

Running fimsship with derby on another machine

On remote machine (lets call it "shuttle")

Put the derby db in C:\apps\apache-tomcat-5.5.20\bin\fims_dev_ship

SET DERBY_HOME=C:\apps\db-derby-10.2.2.0-bin
SET DERBY_OPTS=-Dderby.system.home=C:\apps\apache-tomcat-5.5.20/bin

Modify C:\apps\db-derby-10.2.2.0-bin\startNetworkServer.bat to read

:runNoClasspath
"%_JAVACMD%" %DERBY_OPTS% -Dderby.drda.host=0.0.0.0 -classpath "%LOCALCLASSPATH%" org.apache.derby.drda.NetworkServerControl start
goto end

:runWithClasspath
"%_JAVACMD%" %DERBY_OPTS% -Dderby.drda.host=0.0.0.0 -classpath "%CLASSPATH%;%LOCALCLASSPATH%" org.apache.derby.drda.NetworkServerControl start
goto end



Note: Do NOT be termpted to add "-Dderby.drda.host=0.0.0.0" to DERBY_OPTS or otherwise you cannot stop the server with stopNetworkServer.bat (it will say can't connect to 0.0.0.0)

On the remote machine run
startNetworkServer.bat (and stop it with stopNetworkServer.bat)

On the development machine use this to build a version of fimsship that works with remote derby

ant -f build-ship-dev.xml clean deploy

but make sure that the host is correct in properties-ship-dev.xml

Note: I have had some problems starting the server. "Cannot listen on port 1527 on interface 0.0.0.0. Note sure why, but the fix is to run stopNetworkServer a couple of times and try again.




Friday, January 12, 2007

IE dev Tools ... in a toolbar

see
http://blogs.msdn.com/ie/archive/2007/01/09/ie-developer-toolbar-beta-3-now-available.aspx

download at
http://www.microsoft.com/downloads/details.aspx?FamilyID=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en

Wednesday, January 10, 2007

fims proto calendar

language of calendar is defined by the lang library imported:
<script src="'inc_cmn/lang/calendar-fr.js'" type="'text/javascript'" language="'JavaScript1.2'"></script>
[16:36:50] ROCHE Laurent says: at the moment we have the FR for Les Douanes and the en-uk (my own version from a en-us) for the prototype.
In this file, the language but also order (month, day) is defined ... and good knows what ! ;)

Sunday, January 07, 2007

Struts Tips

When selecting the ajax/dojo theme on a page you can specify debug=true to get dojo debug messages.
<s:head theme="ajax" debug=true/>

Thursday, January 04, 2007

Struts tags -using the after parameter and custom freemarker templates

<fims:textfieldequipment fieldName="stockManagementQueryCriteria.equipmentNm" template="textequipmentwithpopup"/>

replaced

<fims:textfieldequipment fieldName="stockManagementQueryCriteria.equipmentNm">
<s:param name="after">
<img title="<fmt:message key='equipment.image.title'/>" alt="<fmt:message key='equipment.image.alt'/>"
src='<c:url value="/images/equip_plus.gif"/>' width='21' height='21'
style='vertical-align: top'
onClick='DSopenPopup("popupEditEquipmentSearch.html", "DS_equip", 900,800,30,30);'
/>
</s:param>
</fims:textfieldequipment>

which replaced


<s:textfield label="%{getText('equipmentNm.label')}" name="equipmentSearchQuery.equipmentNm">
<s:param name="after">
<img title="<fmt:message key='equipment.image.title'/>" alt="<fmt:message key='equipment.image.alt'/>"
src='<c:url value="/images/equip_plus.gif"/>' width='21' height='21'
style='vertical-align: top'
onClick='DSopenPopup("popupEditEquipmentSearch.html", "DS_equip", 900,800,30,30);'
/>
</s:param>
</s:textfield>



The custom ftl template used is:

<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
<#include "/${parameters.templateDir}/simple/text.ftl" />
<img
src='<@s.url value="/images/equip_plus.gif"/>'
title='<@s.text name="equipment.image.title"/>'
alt='<@s.text name="equipment.image.alt"/>'
width='21' height='21'
style='vertical-align: top'
onClick='DSopenPopup("popupEditEquipmentSearch.html", "DS_equip", 900,800,30,30);'
/>
<#include "/${parameters.templateDir}/xhtml/controlfooter.ftl" />

Tuesday, January 02, 2007

Raw dwr vesselId->Location List before refactoring

<script type='text/javascript'>
var reply1 = function(data)
{
if (data != null && typeof data == 'object') {
// alert(DWRUtil.toDescriptiveString(data, 2));
var headerValue = $("stockManagementQueryCriteria.locationId").options.item(0).text;
DWRUtil.removeAllOptions("stockManagementQueryCriteria.locationId")
DWRUtil.addOptions("stockManagementQueryCriteria.locationId", [{ name:headerValue, id:''}], "id", "name");
DWRUtil.addOptions("stockManagementQueryCriteria.locationId", data, "id", "name");
}
}
</script>
<s:select
label="%{getText('vesselId.label')}"
name="stockManagementQueryCriteria.vesselId"
id="stockManagementQueryCriteria.vesselId"
list="#application.vessels"
value="%{stockManagementQueryCriteria.vesselId}"
required="false"
listKey="id"
listValue="name"
headerKey=""
headerValue="%{getText('dropdown.header')}"
onchange="
/* Or LocationDao.getLocations(eval($('stockManagementQueryCriteria.vesselId').value), reply1);
$() is a DWRUtil function copied from prototype
*/
var vesselId = DWRUtil.getValue('stockManagementQueryCriteria.vesselId');
// Make sure its not the '- All -' option
if (vesselId != parseInt(vesselId)) {
// If its not a number then get an empty list of locations
vesselId = -1;
}
LookupDao.getLocationsByVesselId(vesselId, reply1);
"
/>

Friday, December 29, 2006

Setup P6spy for an(y) application(s)

see http://www.p6spy.com/documentation/install.htm#unspec for more info

- set CLASSPATH=C:\apps\p6spy\p6spy.jar;%CLASSPATH%
- set CLASSPATH=.;%CLASSPATH%
- make sure C:\apps\p6spy\spy.properties use the correct native driver
realdriver=...
- COPY C:\apps\p6spy\spy.properties .
- change the driver class use in software connection (e.g. in ant for DDL Utils)

Saturday, December 16, 2006

wacky characters in webwork struts

%{}
===============================================

<s:textfield label="%{getText('eqnm.label')}" name="query.equipmentNm" value="%{query.equipmentNm}" />

See also page 234 in web work in action

The %{} allows you to put in an ongl expression between the baces embedded within a string.
(ognl is in struts2/webwork).


From: http://cwiki.apache.org/WW/tag-syntax.html
Using an expression to set the label
<s:textfield label="%{getText("postalCode.label")}" name="postalCode"/>
The expression language (OGNL) lets us call methods and evaluate properties.
The method getText is provided by ActionSupport, which is the base class for most Actions.
Since the Action is on the stack, we can call any of its methods from an expression, including getText.


#parameters.size
==============================================


<%= %>
==============================================
Standard Jsp expressions (not used in appfuse)
<%= ((ShoppingCart) session.get("cart")).getId() %>




Velocity uses $member.firstName.
Freemarker uses ${member.firstName}

Wednesday, December 13, 2006

Javascript object dump

USeful to look inside an object:

alert(DWRUtil.toDescriptiveString(someObject,2));

If there is too much info to fit inside the alert box then use
function popitup2(s) {
newwindow2=window.open("",'name','height=600,width=850');
var tmp = newwindow2.document;
tmp.write('<html><head><title>popup</title>');
tmp.write('<link rel="stylesheet" href="js.css">');
tmp.write('</head><body><p>this is once again a popup.</p>');
tmp.write('<p>' + s + '</p>');
tmp.write('</body></html>');
tmp.close();
}
popitup2(DWRUtil.toDescriptiveString(someObject, 2));

Friday, December 08, 2006

appfuse - tip for modifying css stuff

(From http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuseEclipse)

Quote:
For major design changes, I usually run the app, view source on a page and save it to a "sandbox" folder in the same directory as my project. Then I do a find/replace and change all "/appfuse/" references to "../web/". This allows me to change CSS and JS files and just refresh the file in the sandbox.

Tim: I tried this it works beautifully with the aptana html editor.

Labels:

Thursday, November 30, 2006

exports in config and ant test-all working again

moved the exports table context into the spring config file, so we don't need an exports table.
got ant test-all working again (against postgres)

Wednesday, November 29, 2006

Stock management - suppliers, makers and zones

Added Company dao for suppliers and makers
Added Zone dao for ... zones
Zones is complicated because when the user picks a zone its that zones and all its child zones and other descendant zones that should be selected.

Tuesday, November 21, 2006

appfuse iBatis SQL maps - no need for semicolons

appfuse standard sql maps such as defined in UserSQL.xml have semicolons ; on the end of every bit of SQL, this is unecessary/optional for postgres and illegal for derby. So its better to remove semicolons from the SQL in the iBatis sql maps.

Monday, November 20, 2006

ibatis caching configuration

http://www.jugsardegna.org/vqwiki/jsp/Wiki?action=action_view_attachment&attachment=Spring_iBatisJug28012006.pdf

See this bit

cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="false"
maxRequests="64"
maxSessions="20"
maxTransactions="8"
useStatementNamespaces="false"
/>

derby network server starup in embeddded mode in a tomcat application

To startup the derby network server you can put
set JAVA_OPTS=-Dderby.drda.startNetworkServer=true
at the top of catalina.bat

or put this code in the top of StartupListener.setupContext()
NetworkServerControl server;

try {
server = new NetworkServerControl();
server.start (null);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

or put derby.properties in %TOMCAT_HOME%\bin (which is also where the database created by the embedded derby goes)
# When derby is started in embedded mode by the tomcat web application, this
# flag will cause the network server to start too in another thread.
# This allows other clients such as "ij" to connect to the same database.
derby.drda.startNetworkServer=true
#derby.drda.portNumber=1110
#derby.drda.host=myhost
#derby.connection.requireAuthentication=true
#derby.authentication.provider=BUILTIN
#derby.user.judy=no12see
This is currently my preffered solution.
(Unfortunately its not being picked of the classpath, but from the current directory.)

I think that this directory could be changed by setting derby.system.home, possibly in StartupListener.setupContext(), but I haven't tried it.

Friday, November 17, 2006

scratch

<suppliers_for_parts supplier_id="3" part_id="4" currency_cd="EUR" supplier_ref="ENG-B12-AC-2.04" last_price="54000.00" last_price_dttm="2006-06-18 00:00:00.0"/>

Thursday, November 16, 2006

appfuse libraries

  • oscache - made for caching snippets of jsp - half enabled in appfuse (need to uncomment cacheFilter filter-mapping), but not used anyway apart from the flush cache page . Simple example
    • <cache:cache key="foobar" scope="session">
      <%= myBean.getTitle() %>
      </cache:cache>
  • ehcache- made for caching java objects - enabled in appfuse, but not used (I think!). I think it can generally be used more easily with hibernate, although it can be used as a general purpose cache. There is a spring bean called "userCache" that can be used to access ehcache functionality. Slightly annoying is each time you start tomcat you get a new empty directory in C:\Documents and Settings\azzoti\Local Settings\Temp c called for example ehcache_auto_created_1161994081609 etc.
  • ibatis - has caching

appfuse and ibatis dynamic queries

for some reason appfuse defines the iBatis queries in a CDATA section.

<select id="getStockMaintenanceQueryCriterias" resultMap="stockMaintenanceQueryCriteriaResult">
<!-- Can say also say part_nm like '%$partNm$%', but partNm will need to have escape processing carried out -->
<![CDATA[
select * from stock_maintenance_query
where 1=1
<isNotEmpty prepend="and" property="partNm" >
part_nm like '%' || #partNm# || '%'
</isNotEmpty>
]]>
</select>
but if you want to use the dynamic sql then you have to remove the CDATA. Not sure why the CDATA was there in the first place in appfuse.

<select id="getStockMaintenanceQueryCriterias" resultMap="stockMaintenanceQueryCriteriaResult">
<!-- Can say also say part_nm like '%$partNm$%', but partNm will need to have escape processing carried out -->
select * from stock_maintenance_query
where 1=1
<isNotEmpty prepend="and" property="partNm" >
part_nm like '%' || #partNm# || '%'
</isNotEmpty>
</select>

There is a good reason for the CDATA - its

3.3.3.1. Escaping XML symbols

Because you are combining SQL and XML in a single document, conflicts can occur. The most common conflict is the greater-than and less-than symbols (><). SQL statements use these symbols as operators, but they are reserved symbols in XML. A simple solution is to escape the SQL statements that uses XML reserved symbols within a CDATA element. Example 3.6 demonstrates this.
Example 3.6. Using CDATA to "escape" SQL code

<statement id="SelectPersonsByAge" parameterClass="int" resultClass="Person">
<![CDATA[
SELECT * FROM PERSON WHERE AGE > #value#
]]>
</statement>

Last Identity value in Derby

ij> create table t1(c1 int generated always as identity, c2 int);
0 rows inserted/updated/deleted
ij> insert into t1(c2) values (8);
1 row inserted/updated/deleted
ij> values IDENTITY_VAL_LOCAL();
1
-------------------------------

(cf. Derby Reference Doc: CREATE TABLE statement and IDENTITY_VAL_LOCAL funtion ).

We actually need to use this form which allows rows to be inserted that include an id already.
CREATE TABLE role
(
id int generated by default as identity,
name varchar(20) NOT NULL,
description varchar(64),
CONSTRAINT role_pkey PRIMARY KEY (id)
);

derby auto generated keys identity autoincrement

ij> create table t1(c1 int generated always as identity, c2 int);
0 rows inserted/updated/deleted
ij> insert into t1(c2) values (8);
1 row inserted/updated/deleted
ij> values IDENTITY_VAL_LOCAL();

Wednesday, November 15, 2006

appfuse displaytag

displaytag http://displaytag.sourceforge.net/11/ gives you sortable pagable tables

the messages can be set either in displaytag.properties (and overriden in displaytag_fr.properties)


or the default values in displaytag.properties can be overridden in each jsp

<display:table name="stockMaintenanceQueryList" cellspacing="0" cellpadding="0" requestURI=""
id="stockMaintenanceQueryList" pagesize="4" class="table" export="true">

<display:setProperty name="basic.msg.empty_list_row">
<tr class="empty"><td colspan="5"><fmt:message key="stockMaintenanceQueryCriteria.noMatch"/></td></tr>
</display:setProperty>

<display:setProperty name="paging.banner.no_items_found" value="no items"/>

note the value of stockMaintenanceQueryCriteria.noMatch can be set in ApplicationResources.properties

appfuse tomcat setup

C:\apps\apache-tomcat-5.5.20\conf\tomcat-users.xml

new bits in red

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
</tomcat-users>


In appfuse properties.xml

<!-- Application options that will likely vary between applications -->
<property name="http.port" value="80"/>
<property name="dao.type" value="ibatis"/>
<property name="jsp.precompile" value="false"/>

<!-- Properties for running unit tests with tomcat -->
<property name="tomcat.server" value="localhost"/>
<property name="tomcat.manager.url" value="http://${tomcat.server}:${http.port}/manager"/>
<property name="tomcat.username" value="tomcat"/>
<property name="tomcat.password" value="tomcat"/>

todo

  • search labels on top
  • merge user and app_user

unit and web tests
manager classes overkill
dojo - anjuta integration
eclipse setup (laurent)
selenium!


understanding different ways of specifying values in jsp/webwork
list="#application.availableRoles"
value="%{boat.name}"

derby boolean/smallint

Tuesday, November 14, 2006

appfuse disable hibernate in build

As i'm usng appgen still, I can't uninstall hibernate yet (as appgen requires it), but I think i can disable the hibernatedoclet task in the main build.

I'm doing this because I started getting xdoclet.XDocletException on the hibernate generation, which, I think that we don't care about. This happened because I removed the dummyId primary key field from StockMaintenanceQueryCriteria and I think that hibernate must have a primary key. (But this is not a real table).

This is one way of stopping the build doing the hibernate generation.
<!-- tim replaced depends="hibernatedoclet" with depends="prepare" -->
<target name="compile-dao" depends="prepare" description="Compile dao module">
<compile module="dao"/>
</target>

but actually i fixed it by removing all the hibernate comments from StockMaintenanceQueryCriteria.java

Monday, November 13, 2006

appfuse webwork tags classes and themes???

<ww:checkbox name="stockMaintenanceQueryCriteria.stockAlert" id="stockMaintenanceQueryCriteria.stockAlert" value="%{stockMaintenanceQueryCriteria.stockAlert}" fieldValue="true" theme="simple"/>
<label for="stockMaintenanceQueryCriteria.stockAlert" class="choice"><fmt:message key="stockMaintenanceQueryCriteria.stockAlert"/></label>

Thursday, November 09, 2006

appfuse appgen tips creating a seach by criteria screen

create search fields screen using appgen on a dummy table and use the generated "add" functionality to capture the fields.

0. Hot tip for using appgen - go into middlegen first and do an "ant clean" otherwise your pojos will get overwritten.

1. appgen needs a primmary key to generate properly which is why dummy_id is defined in the table create below

2. appgen does not like postgres domains (user defined types) and will not generate some of the files properly if there is a single column with a domain type.

3. Unless you have at least one NOT NULL column in your table, then the MyTable-validation.xml is not a legal webwork validation file.

4. If using appgen on a postgres table with "boolean" columns, the generate MyTable class needs to have all occurrences of "Boolean" replaced by "boolean". Otherwise you get a very confusing error when webwork validates: The content of element type "validators" is incomplete, it must match (field|validator)+"



drop table stock_maintenance_query_criteria;

select
p.part_id as dummy_id,
f.fleet_id, vt.type_id, v.vessel_id,
ec.class_cd, e.equipment_nm,
p.part_nm,
c.company_id as maker_company_id, p.maker_ref,
c.company_id as supplier_company_id, sp.supplier_ref,
l.zone_id, l.location_id, true as stock_alert,
p.drawing_ref
into stock_maintenance_query_criteria
from
fleets f,
vessels_types vt,
vessels v,
vessels_in_fleets vf,
equipments_classes ec,
equipments e,
companies c,
parts p,
suppliers_for_parts sp,
locations l
where 1=1
and f.fleet_id = -1
and vt.type_id = -1
and v.vessel_id = -1
and vf.vessel_id = -1
and ec.class_cd = -1
and e.equipment_id = -1
and c.company_id = -1
and p.part_id = -1
and sp.part_id = -1
and l.location_id = -1;

alter table stock_maintenance_query_criteria add CONSTRAINT pk PRIMARY KEY (dummy_id);

postgress unicode and latin-1 - Moral use unicode !

http://archives.postgresql.org/pgsql-jdbc/2004-11/msg00075.php

1. Create the database with the proper encoding.
In our experience, the best thing to do is simply choose Unicode as the database's character encoding if you think there's a chance of storing Latin1 or other characters. You could choose Latin1, and this should work in most cases. However, there are times when normal-looking characters refuse to be stored in a Latin1 database, such as character 239, which is the same in Latin1 as it is is Utf-8. Rather than attempt to beat our heads against this wall, we went with Unicode because it will hold whatever we need to hold.

Wednesday, November 08, 2006

appfuse webwork drop down

for struts dropdown see
http://raibledesigns.com/wiki/Wiki.jsp?page=HibernateRelationshipsUI#ref-HibernateRelationshipsUI-7

for webwork drop down see:
http://www.nabble.com/Using-ww%3Aselect-for-Lists-set-in-StartupListener-tf2198175s2369.html#a6084253
http://www.nabble.com/webwork-type-conversion-question-tf2352778s2369.html#a6552629

See LookupManager beans, initialized in StartupListener#setupContext()

context.setAttribute(Constants.AVAILABLE_ROLES, mgr.getAllRoles());

Had this in boatForm.jsp to test drop downs
<ww:select
label="getText('boat.name')"
name="'boat.name'"
id="boat.name"
list="#application.availableRoles"
value="%{boat.name}"
required="true"
listKey="value"
listValue="label"
emptyOption="true"/>

appfuse sample data

rebuild your sample-data.xml file using ant db-export and then cp db-export.xml metadata/sql/sample-data.xml.

Labels:

Tuesday, November 07, 2006

appfuse 1.9.4 p6spy integration

1. Download p6spy (google it!)

2. Put the unaltered spy.properties in C:\apps\myappfuseapp\web\WEB-INF\classes
update the logfile entry to point to somewhere sensible: for example
logfile = C:/spy.log

3. put the p6spy.jar in C:\apps\apache-tomcat-5.5.20\common\lib
(may not be the best place but it works)

4. Find applicationContext-resources.xml and change (blog rules mean I have to put a space after every less than sign otherwise the xml will not display on the blog entry)
Change
bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
to read
bean id="dataSourceTarget" class="org.apache.commons.dbcp.BasicDataSource"


5. Add the following bean defintion
{bean id="dataSource" class="com.p6spy.engine.spy.P6DataSource"
{destroy-method="close">
{constructor-arg>
{ref local="dataSourceTarget">
{/constructor-arg>
{/bean>


Please note that I can't put the xml tags properly in this blog, otherwise it will not display properly. So I have used { in stead of a less than sign - Grrrrr!


Labels:

postgres primary key generation and fetch

CREATE TABLE boat
(
id serial NOT NULL,
name varchar(40) NOT NULL,
built timestamp NOT NULL,
CONSTRAINT id PRIMARY KEY (id)
)
WITHOUT OIDS;

insert into boat (name,built) values ( 'bigboat', '1965-08-11' );
-- get the generated key back
select currval(pg_get_serial_sequence('boat', 'id'));
-- or better still
select lastval();

apache-tomcat-5.5.20 appfuse

tomcat-users.xml


< ?xml version='1.0' encoding='utf-8'?>
< tomcat-users>
< role rolename="tomcat"/>
< role rolename="role1"/>
< user username="tomcat" password="tomcat" roles="tomcat"/>
< user username="both" password="tomcat" roles="tomcat,role1"/>
< user username="role1" password="tomcat" roles="role1"/>
< /tomcat-users>

Thursday, November 02, 2006

Appfuse and DWR quickstart

Appfuse 1.9.4 already has dwr included:

web.xml is already configured (sear for dwr to see where)

edit dwr.xml and uncomment the commented out xml and restart tomcat:

go to http://localhost:8080/myapp/dwr/ which is a sort of "see whats available" list of the dwr javascript proxies to java objjects.

Tuesday, August 29, 2006

Block / Closures: Java, C#, Ruby



Java version

public EmployeeList managers(EmployeeList emps) {
return emps.findAll(
new EmployeeFinder() {
boolean find(Employee emp) { return e.isManager; }
}
);
}
// Supporting EmployeeList class and EmployeeFinder interface required

C# 2.0 finder (Less verbose than Java and no supporting classes)


public List Managers(List emps) {
return emps.FindAll(delegate(Employee e) { return e.IsManager; } );
}

Ruby finder

def managers(emps)
return emps.select {|e| e.isManager}
end

=======================================================================

C# 2.0

int total = 0;
order.EachItem(delegate(Item item) {
total += item.Price;
}

Java

final int[] total = { 0 };
order.eachItem(new OrderBlock() {
public void handle(Item item) {
total[0] += item.getPrice();
}
});


Sunday, July 30, 2006

Cobertura vs Emma

I've used the java coverage tools emma and cobertura before although not in any great depth. JCoverage currently has way prettier reports, and Elliotte Rusty Harold seems to prefer cobertura over emma. So when I was looking to set up test coverage reports for JRuby, I thought I would try cobertura and forget all about emma.

I have just submitted a patch to JRuby complete with a unit test, and I wanted to make sure that my unit test was covering the code properly. However, cobertura showed confusing results for the bit of code I was interested in.

Here it is:


The two iterator methods are showing three lines not being executed by the test, which I was pretty sure was wrong. (And a single commented line not being executed.)

So I tried the same in Emma, and I got the correct code coverage:



Give me ugly but correct, every time! Ok, so maybe this is a nasty corner case, with two embedded anonymous inner types which are created and returned in one statement. But its real code, that I happen to be interested in.

So now a little later cobertura is working fine... and I'm not sure what I did to fix it.