jump to navigation

DynaActionForm Properties not set – BUG with indexed form properties March 7, 2008

Posted by Tomas in IBM Webspehere.
Tags:
trackback

One of the most annoying “features” of the Websphere Portal that it uses butchered (aka modified) Struts 1.1 Framework. During this “modification” some things fell through the cracks and some interesting bugs got introduced. I spend 2 days blidly debugging this piece of shit portal to find a workaround.

Here is the problem: You have a DispactchAction and a DynaActionForm you add indexed properties on your jsp page and some of those indexed properties are not being set. If you debug it, you see the values in the request, but they never make it to the form. And some of the other form properties, not only indexed are not being set out of a sudden. If you remove the indexed properties from the form and jsp everything starts working.

The bug lies somewhere in the modified struts framework. Modified code does not recognize a setter method with signature setSomething( String value) as a valid setter method. This bug only surfaces if indexed properties exist in the form and jsp. To get around this bug you must change the signature to setSomethig( Object value ) and you get the values.

Here is the example:

Form:
<form-bean name=”roleForm” type=”org.apache.struts.action.DynaActionForm”>
<form-property name=”role”
<form-property name=”attribute” type=”com.something.model.Attribute[]” size=”100″ />
</form-bean>

Jsp:
<logic:iterate id=”attribute” name=”roleForm” property=”role.attributes” >
<tr>
<td>
<html:hidden indexed=”true” name=”attribute” property=”id” />
<html:hidden indexed=”true” name=”attribute” property=”version” />
<html:text indexed=”true” property=”key” name=”attribute” size=”20″ maxlength=”250″ />
</td>
<td><html:text indexed=”true” property=”value” name=”attribute” size=”20″ maxlength=”250″ /></td>
<td><input type=”submit” value=”Delete” /></td>
</tr>
</logic:iterate>

Which produces:
<tr>
<td>
<input type=”hidden” name=”attribute[0].id” value=”1″>
<input type=”hidden” name=”attribute[0].version” value=”1″>
<input type=”text” name=”attribute[0].key” maxlength=”250″ size=”20″ value=”TEST”>
</td>
<td><input type=”text” name=”attribute[0].value” maxlength=”250″ size=”20″ value=”TEST2″></td>
<td><input type=”submit” value=”Delete” /></td>
</tr>

So you must have:
public void setKey(String key) {
this._key = key;
}
public void setKey(Object key) {
this._key = key.toString();
}

For this to work.

Comments»

1. Phaedrus - March 16, 2008

Hi,

I won’t comment on the detail other than to say. “DON”T USE A PORTAL!!”. It is amazing that vendors get away with this stuff. It is an indictment on our whole industry that the King can be totally naked and no one notices other than the odd whistle blowers like yourself.

KEEP UP THE GOOD WORK. IBM MARKETING WILL HATE YOU, BUT WHO CARES :).

I can’t believe that anyone actually evaluates this stuff before purchasing. You should ask your architect what happened to the proof of concept? and get him to make it work 🙂 I first went to a Weblogic Portal demo in 1999 I think. A page full of XML convinced me never to go anywhere near the damned thing (LOL!!). I’ve since had the displeasure to “work” with Oracle OC4J Portal and 8 years on, guess what? The J2EE Portal world is no better! The OC4J portal is meant to be struts compatible too, but once you look past the marketing and get into the detail, there is a list as long as your arm of Servlet API non-compliance. It only works if you use their wizard (JDeveloper) to generate the code for you. So if you want to write your own code you’re stuffed. It is just not Servlet API compatible.

Mashups sound more promising, but I haven’t tried them myself. Netvibes has an interesting site (www.netvibes.com) that shows what’s possible. You can drag and drop urls on to the page and they become portlets. Pretty neat. Something like Flex may be worth looking into also.

As for J2EE JSR168 Portlets. My advice is steer well clear!


Leave a comment