Saturday, May 27, 2006

My Favourite Netbeans Update Centres

I just upgraded to a Netbeans 5.5 after cleaning up all my installs. I wanted the new Subversion support, which was available in the beta release via the Beta Update Centre. The problem was, the daily build doesn't have the Beta update centre listed, and try as I might I can't find anywhere where it is explained how to add it manually. I've had to download and install the beta again just to find the url.

In future, I'll use this:

My Favourite Netbeans Update Centres

Wednesday, May 17, 2006

Adding a New User to Websphere Portal 5.x and Letting them Access a Page

Documentation not great. To create a user, and let them see your page, do as follows:

1. On the login screen click the "Sign Up" link
2. Add your users details
3. Click "OK" to create the user
4. Login as the admin user
5. Click on the "Administration" link in the top right hand corner
6. Select the "Access" section on the left hand side
7. Click on "User and Group Permissions"
8. Search for your new User by UID
9. Select your users "edit" icon (the pencil) under select resource type
10. Select "Pages"
11. For the "Content Root" page, click the "assign access" icon (the key)
12. Tick the "user" box
13. Click "Done"
14. Click on the [user uid] breadcrumb to get back to the recources to allocate access to page
15. Click the "portlets" link
16. For each portlet you need to asssign access to, find it, click the "assign access" icon (the key), tick the "user" box and click "Done"

You should now be able to log in as the user, navigate to the page (if required) and see the portlets you have allowed user access to.

Thursday, April 20, 2006

Mapping the Websphere Portlet Wiring Jungle

While great for inter portlet communication, IBM's concept of inter portlet comms by "wiring" using WSDL is a complicated one and easy to screw up. Here's some notes I've made as I've made my way through getting it working:

THE WSDL PARTS:
Types: Describes data types (using XML schema) that can be emitted by the source portlet.
Messages: Describes messages that can be produced or consumed by the portlet.
Port Type: Describes the abstract interface of the portlet, as seen by the property broker.
Binding: Describes how the abstract interface (port type) is implemented.

OUTPUT FROM A PORTLET:
Portlet HTTP Request Parameter Name (the wire action to call) ="XXXXX" ->
that portlets wsdl <binding... <operation... <portlet:action name="XXXXX"


Portlet HTTP Request Parameter Name (the value to pass) ="AAAAA" ->
that portlets wsdl <binding... <operation... <output... <portlet:param name="AAAAA"

that portlets wsdl <binding... <operation... <output... <portlet:param part-name="BBBBB" ->
that portlets wsdl <message... <part... name="BBBBB"

that portlets wsdl <binding... <operation... name="CCCCC" ->
that portlets wsdl <portType... <operation... name="CCCCC"

that portlets wsdl <binding type="tns:DDDDD" ->
that portlets wsdl <portType name="DDDDD"

that portlets wsdl <portType... <operation... <output message="tns:EEEEE" ->
that portlets wsdl <message... name="EEEEE"

that portlets wsdl <message... <part... type="tns:FFFFF" ->
that portlets wsdl <types... <xsd:schema... <xsd:simpleType name="FFFFF"

INPUT TO A PORTLET:
that portlets wsdl <types... <xsd:schema... <xsd:simpleType name="GGGGG" ->
that portlets wsdl <message... <part... type="tns:GGGGG"
NOTE: These datatypes must be the same as those in the output portlet wsdl

that portlets wsdl <message... name="HHHHH" ->
that portlets wsdl <portType... <operation... <input message="tns:HHHHH"

that portlets wsdl <portType name="IIIII" ->
that portlets wsdl <binding type="tns:IIIII" ->

that portlets wsdl <portType... <operation... name="JJJJJ" ->
that portlets wsdl <binding... <operation... name="JJJJJ"

that portlets wsdl <message... <part... name="KKKKK" ->
<binding... <operation... <input... <portlet:param part-name="KKKKK"

that portlets wsdl <binding... <operation... <input... <portlet:param name="LLLLL" ->
Portlet code request.getParameter("LLLLL"); // the passed value

that portlets wsdl <binding... <operation... <portlet:action name="MMMMM" ->
Portlet code request.getParameter("MMMMM"); // the called action


MORE INFORMATION:
See: http://www-128.ibm.com/developerworks/websphere/library/tutorials/0509_saddal/0509_saddal_reg.html

Friday, April 14, 2006

Setting the Default Goal in Maven 1.0.2

To set the default goal in a maven 1.0.2 project, add it to the 'project' tag in maven xml as an attribute. E.g.:

default="jar:install"

Wednesday, April 12, 2006

Another Stupid JSP Mistake
If you want to directly embed the output of a Java bean property in your jsp you need to surround the call to the getter with '<%= %>' and not '<% %>' as I initially was doing...
Another JSTL EL Gotcha

I just spent agfes banging my head against a JSP null pointer exception.

It turned out that the reason I was getting it was because I was using JSTL 1.0 but had tried to use '[n]' notation to access a list. Something which seems only to be available in JSTL 1.1...

For more info check out: The JSTL Expression Language > Operators
The Significance and Importance of Quotes in JSTL EL

I just spent a few hours debuggung a null pointer in a Portlet JSP I'm writing. It's notoriously difficult as you need to deploy to see if you've cocked up and if the error is in your jsp, even decompiling the result can be of no use as this loses the comments and consequently the error of the line number is meaningless. I was reduced to cutting the page down to the barest minimum and then putting the bits back, one at a time to see where my mistake lay... (Ignore the wierd tags, that's there to get this to display properly)

As it turned out, the error was a particulary few-pixelled one. I had:


...c:when test="${not empty sessionBean.myProtoSubscription.mySubscribedEntityId}">
...c:choose>
...c:when test="{sessionBean.myProtoSubscription.mySubscribedEntityId" > 0}">
...


Where mySubscribedEntityId was a Long. I thought this would be the problem as the error was about a "null" and feared the Long > long transition would be the cluprit. How wrong was I. I'd just missed out two tiny quotes round the '0'. This now works:


...c:when test="${not empty sessionBean.myProtoSubscription.mySubscribedEntityId}">
...c:choose>
....c:when test="sessionBean.myProtoSubscription.mySubscribedEntityId"> '0'}">
...


Read more about JSTL EL "not empty" tags here

Tuesday, April 04, 2006

More SQL...

We wanted to change a field in every one of our defendants so that they had a "PrisonerID" based on their defendant id (which was the primary key) with a prefix of 'PR00'. We did the following (on MySQL 5):

mysql_prompt> update defendants set prisonerId=concat('PR00', defendantId);
MySQL Database Dumping Command Quickie

I try and avoid using databases so much that I can never remember any commands, but I've had to look this up more than once:

DOS_PROMPT> mysqldump --user=[UID] --host=[server] --password --opt [database] > [filenameForDump.sql]


Lots more info is in the manual at:

MySQL 5.0 Reference Manual :: 8.10 mysqldump — A Database Backup Program

It alows you to dump the schema creation sql as well as sql to load the current data.

BTW, remember there's also
SET_FOREIGN_KEY_CHECKS=0
or
...=1
to enable / disable foreign key constraint checking for the duration of any upload

Thursday, March 30, 2006

List Insert Based on CompareTo

Here's some code I've had to write more than once. It inserts something into a list at a position based on the compareTo method. Consequently the element inserted must imlpement this.

public void addElement(MyElement aElement)
{
List myElementsList = this.getMyList();

// Check that the list exists
if (myElementsList == null)
{
myElementsList = new ArrayList();
}

// Check that the list is not empty
if (myElementsList.size() == 0)
{
myElementsList.add(0, aElement); // add the element at the beginning
return;
}

MyElement currentElement;

for (int index = 0 ; index < myElementsList.size() ; index++)
{
currentElement = (myElement) myElementsList.get(index);

// if the current element has the same compareTo value as the element to be added
if (currentElement.compareTo(aElement) == 0)
{
// The hearing is already in the list. Take no further action and return
return;
}
// else if the current element is before the element to be added
else if (currentElement.compareTo(aElement) < 0)
{
myElementsList.add(index, aElement);
return;
}
}
}
}

Tuesday, March 28, 2006

Can Your Own Demo

I found something great on t'internet the other day. I had been asked to do a demo of our new ystem to some users but it would have taken too long to decommission, move and recommission our dev server to be able to show them something moving on screen. Then I remembered I'd seen flash demos on the Netbeans website. I slipped on over and saw they were using Wink.

It's brilliant. You just download and go. We have a real mickey mouse one at the moment but it seems form other demos I've seen you can add "Next" buttons, commentary and subsections of the screens. All this and it can export to a .swf file which you can share!

Beautiful.