.comment-link {margin-left:.6em;}

J. Daniel Ashton

www.flickr.com
This is a Flickr badge showing public photos from jdashton. Make your own badge here.
Whatever your hand finds to do, do it with all your might, —Ecclesiastes 9:10a NIV
The LORD God has told us what is right and what he demands:
"See that justice is done,
let mercy be your first concern,
and humbly obey your God." —Micah 6:8, CEV
With all your heart you must trust the LORD and not your own judgment.
Always let Him lead you, and He will clear the road for you to follow. —Proverbs 3:5,6 CEV

see also — My Homepage

My Photo
Name: Daniel Ashton
Location: Germantown, Maryland, United States


Any links with a dashed underscore probably point to Amazon.com

Sunday, July 16, 2006

Don't Forget the Form!

For the last two weeks I've been working very hard on a project at work that involves creating a portlet using Struts. This in itself should not be too difficult, as numerous examples exist. In fact, the RSA (Rational Software Architect, a superset of RAD) documentation includes tutorials on this very subject.

To my dismay, I could not reliably get them to work! I finally gave up and mangled one of the working samples to get the job done. In moments when I could not be focused on finishing that task I beat my head against the question of why the start-from-scratch (or nearly so) method was not creating a working portlet.

The specific problem I ran into is that trying to display data using a <bean:write /> tag consistently results in an RMOD (red message of death) stating
This portlet is unavailable. If the problem persists, please contact the portal administrator.
This was driving me crazy. I checked the classpath, every configuration file, repeatedly compared the files and directories between working and non-working versions.

Finally, this evening, I discovered a solution. (I won't say the solution, but it's at least a solution.) Simply ensuring that the .jsp includes a form definition, even one that's totally empty, is enough to enable the <bean:write /> functionality.

My now-working page looks like this:
<%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"%>

<portletapi:init>

<html:form action="/displayFile"></html:form>

<table border="0">
<tbody>
<tr>
<th>fileSize</th>
<td><bean:write name="fileForm" property="fileSize"></td>
</tr>
<tr>
<th>fileName</th>
<td><bean:write name="fileForm" property="fileName"></td>
</tr>
</tbody>
</table>

Note the empty (but apparently mandatory) form tags. Why is this necessary? Why doesn't the wizard automatically put these tags into files it creates? Why has no one else blogged about this?

That's why I'm blogging about these things now. As a newbie I search using Google in hopes of answering these questions. Coming up with practically no results multiplies my frustration. So by at least writing about these problems as I run into them, I hope to make life easier for some other newbie who faces the same challenges. At least this time I have a suggestion for such a searcher:
Don't forget the form!

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home