Saturday, January 31, 2004

WSAD: Creating a "View" in Websphere and DB2

So there I was trying to emulate the functionality of what was a view in the previous Notes version of my application. All the view had to do was list out the eReports from the system by date. Easy:

1. Create a mapping the the STRUTS configuration file for eReportsByDate.
2. Add a "Forward" to this mapping to the view display JSP called /eReports/eReportsByDate.jsp.
3. Create an action command object class to process this mapping called com.spuggy.sampler.eReports.action.viewBydateAction
4. Add this action to the STRUTS configuration.
5. The Action will create a Business Facade Object called eReportManager and call its menthod findAll().
6. The findAll method will create a Data Access Object FindAllEreportsDAO and call the execute function.
7. The execute function will then create a DBBeans object and execute a select statement.
8. The eReportManager will then loop through the result set using another Data Access Object called FindAllEreportsDAORow.
9. When looping around the result set the eReportManager will populate a vector of Data Transfer Objects called EreportsViewDTO.
10. If everything is rosey then eReportManager.findAll() will return the vector of EreportsViewDTOs back to the Action (see 5).
11. The Action will then shove the EreportsViewDTO back into the request object like so - request.setAttribute("eReportVectorDTO", eReportsVector).
12. Then the action object will use the forward mapping to send the user onto the correct JSP page to display the vector of the results.
13. In the JSP Page the STRUTS logic tag library will be used to iterate over the vector of DTO objects: <logic:iterate id="eReport" name="eReportVectorDTO">.
14 Finally open the URL eReportsByDate.do (all *.do URLs are mapped to the main ActionServelt of STRUTS) and voila the table of eReports appears.

Oh

Then you go and refresh the page and the second viewing won't work giving a 500 error. Looking at the server test environment console you see:

[IBM][CLI Driver][DB2/NT] SQL0405N  The numeric literal "0" is not valid
because its value is out of range. SQLSTATE=42820

Then you go and search Google's Websphere Newsgroups for that string and after a bit of clicking around find:

To answer my own question, I have since found out that the cache is
broken in certain scenarios and that IBM are aware of it.

If your SQL contains the following...
FETCH FIRST n ROWS ONLY
where n = the number of rows you want returned, the cache attempts to
replace n with a ? parameter.
When the statement is executed a second time, it expects to be passed
a number as you would do with any other ? substitution. It doesn't get
one so substitutes it with 0, which then causes the statement to fail.

Good eh!!


So then you back into WSAD and alter the Prepared Statement Cache size to 0 on the Datasource
configuration in the test server configuration. Then it finally works.

After that you think, now I need to do the forward and back links and you realise that DB2 does not support MYSQL's Limit function, so you have to do some jiggery-pokery with a second sorted column and passing url strings.

Finally after powering down for the day you have a little think and wonder: "How did all this catch on?"

Thursday, January 29, 2004

J2ME: It's a woolly wireless world out there

I went to a Wireless groover love-in at a secret location in London last night. Wow what an eye-opener. Lots of fascinating stuff about over-the-air provisioning, J2ME, Bulk SMS, Mobile domains, WAP Push, WAP Pull; not to mention the Locomotion, the mashed potato and hand-jive.

It wouldn't be an exaggeration to say that I felt like a stone-age man walking into Los Angeles. As Manuel would say "Ahh no naathing".

Wednesday, January 28, 2004

Monkey Programmer Boy: Trapped in castle grey skull ...

Trapped in castle grey skull, fixing notes client applications for the Hooded Claw. If only the Ant Hill mob would arrive. Hey-yelp! Hey-yelp!


Monday, January 26, 2004

Monkey Programmer Boy: A Fixin' Those Old Notes Apps Blues

Yes, we're fixin' them old Notes applications.

Saturday, January 24, 2004

ATOM: Oooo new thing

When publishing my blog I noticed Blogger had produced a new file for me: atom.xml. On further investigation it turns out that the Blogging community have produced a new syndication and content creation system called Atom.

Apparently:

"AtomEnabled finally makes it possible for developers to have a consistent, tightly specified, well-documented XML format for both syndication and authoring of content. Using one data format for both reading and writing, with a growing library of components supporting Atom development in almost any major scripting or programming language, means your application, site, or device can benefit from the network effect of a large community while spending less time developing core data exchange functionality."

Oooo. This new format is supported by all the popular newsreaders, so they say.

Blogger has rolled out beta support for the Atom Api, which is a SOAP/REST based web service, groovy. All the blogger developments can be tracked at the "Blogger Developer Network".

Here's a link to my Atom feed: "Can I get Down now Dad?"

[Valid Atom]

Friday, January 23, 2004

DB2: Certification

DB2 appears to be rather well served for free on-line training and certification preparation. No really, check this out. It's worth a look, particularly as there is a fair chance that a relational database, of some description, will loom large in our lives in the near future. Well, that is unless I get the boy-band back together of course. I want you back for gooood.

Thursday, January 22, 2004

Monkey Programmer Boy: Teenage Romance

Tuesday, January 20, 2004

J2ME: Enterprise Mobile Groovy Doo Dahs

If I am going to write groovy mobile applications for mobile phones, then I am sure going to need an XML parser. The well known ones, apaches for instance, are huge, (1.7mb) rendering them useless for the constrained world of the phone. The article: "Build Your Own Lightweight XML DOM Parser" describes how to build your own tiny DOM parser in less than 4K! Tippity top or what?

I read this and it sounds like one of those ads:

"Build you own matchstick DOM parser in less than 4 weeks $2.99, first edition free" .... at all good news agents. Who buys those mags?

THINKS: must get out more, must get out more, must get out more, must .........................

UKULELE: My Favourite Site

The internet is full of many splendid and wonderful things. None more so that Rick Marsh's Beatles Ukulele site. "Lucy in the Sky with Diamomds" for instance.

It's a wonderful world.

Friday, January 16, 2004

Monkey Programmer Boy Episode 5 - The Search for Spock


Authors Note: Please be aware this is NOT a cartoon. I actually DO work for the people in the Microsoft clip art collection.

Thursday, January 15, 2004

J2ME:Better than ....

This lady appears to be having a lot of fun with J2ME. Go on have a dabble, have a shufty.

Wednesday, January 14, 2004

J2EE: Code Generation Techniques

I have been ruminating on the complexity of developing Websphere/J2EE applications. N-tier layered applications are fab and groovy but tend to have what appears to be repeating elements through the layers and into the database backend.

This kind of approach is neccessary to reap the benefits of the MVC pattern etc but from a manual coding/maintenance point of view, looks like a load of Sandra Bullocks to me.

Well you don't have to type all this stuff in you could use a code generator of course. The ServerSide article "Back End Code Generation Techniques For Java" describes these tools rather nicely.

It is full of sobering little nuggets like:

"There are a number of persistence options, and some options, like EJB, take up to seven classes and interfaces per database table. It’s no great wonder that of the 150 tools listed in the Code Generation Network database that the majority are for Java, and that the majority of those are for building database persistence code."

The article goes on to list a number of code generation approaches and tools; some of them open source. The most interesting approach for me was the the roll you own, using XSLT. He doesn't mention Rational Rose though, but I guess that is another beastie altogether.

Thing is, if I am honest, I can't stand code generators. They tend to churn out a load of chaff saying "This function was generated by CheeseWare Incs Cheese-o-matic 2004" and then you go and re-write most of it.

Rock and a hard place m'thinks.

Monday, January 12, 2004

DREAD: Monkey Programmer Boy 2000AD

Saturday, January 10, 2004

J2EE: Websphere Security

The Websphere Redbook example I am experimenting with uses filter servlets to add programatic security. The filter servlets are mapped to various urls in the web.xml. The filter servlet checks for the existance of a user object in the session and redirects you to the login.jsp if it can't find one. If you are logged in, then the filter servlet will find the user object (this is added to the session when you login) and pass you straight through to the resource you were after.

This is fab for sites with a few areas that require security but am not convinced that it is a good approach for larger sites with hundereds of pages. Maybe I'm wrong but what i'd rather have (in a domino stylee) is a declarative security approach much like our good old fashioned ACLs.

This is all available in Websphere of course but seems oriented towards LDAP and operating system user registeries. Hmmm. What I was after was using the built in websphere security features but pointing them at my custom user registery, so I was kind of pleased to find "Testing J2EE Security Applications Using a Custom Registry in WebSphere Studio V5"

Anybody else found any decent Websphere security/authentication resources? If you have please stick a comment on.

As Otis Redding said:

"I want security, yeah
I'm telling you, once say again, oh now
Security
And I want it in the end, oh"

Thursday, January 08, 2004

LOTUSFEAR: Monkey Programmer Boy Merchandise

With Lotusfear only a few weeks away the team here at "Can I get down now dad?" have decided to produce their own Monkey Programmer Boy merchandise. It's quality stuff, incorporating badly sized jpegs and the cheapest fonts available.

Tuesday, January 06, 2004

This was posted via my mobile phone using the blogger api oooo

---
This post was made with a trial version of BlogPlanet, a photo blog client for mobile phones. For more information visit www.blogplanet.net
.

Monday, January 05, 2004

RPS: Important Sporting News

If the endless grind gets you down as you spiral towards death and oblivion; there is always "Rocks, Paper Scissors" to pass the time. Here's the official site: The Official Rock Paper Scissors Strategy Guide.

J2EE: Differences with Domino Development.

Since my glorious exam result I have been busy going through the Redbook: "WebSphere Application Server - Express: A Development Example for New Developers" which contains a real world non-ejb websphere application. I have downloaded the source code and imported into WSAD and gone over the design to find out how things were done. The example application is a good place to start as it uses STRUTS, log4J, DB2 backend and some typical design patterns (Data Access Object & Business Facade).

I have used the Redbook design as a template for re-building one of my Domino applications into a J2EE app. This has proven a very useful exercise and I would reccomend it. The key benefit is that the app is real-world enough to be useful, unlike the typical "Don't runwith scissors" kind of examples you find in many books.

One of the main things I have noticed is how simple life is in the Domino world. This is often a frustrating limitation but you don't half realise how much you take forms, views and the object store for granted when you are in the bowels of a J2EE app.

For instance, take a user registration form. In domino you would:

1. Create a form with name and address on it. Bit of validation in the fields maybe.
2. Create a view with username on it and sort by username.

Thats it. You've got the form and this saves the record into the object store and off you go.

In J2EE (following the Redbook example) you would do the following:

1. Create a form with name and address on it.
2. Create an associated formbean with name and address fields, getter and setter functions.
3. Add a mappiong to the STRUTS config.
4. Add a validate() function to the form bean. This will have stuff about the name and addrress in it too.
5. Create user data transfer object (with name and address fields) so you can send user information around layers.
6. Create a usermanager class to act as a business facade for the data access layer.
7. Create user data access object with name and address fields, getter and setter functions. This accesses the backend database.
8. Finally the relational database itself which has a table called user which has name and address fields too.
9. Oh and then you have to do the stuff to display a list of users like the view ...

Phew. Bit more involved eh, and were not using EJBs.

Now imagine adding a new field, country for instance. In domino you just add the field to the form. If the new field doesn't need any validation or appear in the view then you are done.

In the J2EE example you have a lot of work to do. Adding the field to the various objects and then altering the relational database structure.

Don't get me wrong. In some respects working in the J2EE environment is a total breath of fresh air. You can create large layered applications which have a coherent design and go FAST. Once Domino hits its glass ceiling these type of apps become a spider's web of $$viewtemplate for dontRunWithScissors forms and hacks.

That said, for simple applications Domino is a breeze, which is food for thought for those suggesting Websphere is a contender in the SMB market place. My example is based on a Websphere express example by the way.

Friday, January 02, 2004

STRUTS: Now look here!

This is a good intro to Struts and websphere: "Writing a Simple Struts Application using WebSphere Studio V5"

Thursday, January 01, 2004

ANT: A tutorial

I thought this was rather good: "Apache Ant 101: Make Java builds a snap"

This page is powered by Blogger. Isn't yours?