users@glassfish.java.net

Java Tag Library problem

From: <glassfish_at_javadesktop.org>
Date: Fri, 24 Aug 2007 11:38:08 PDT

I have a problem with my application's java custom tag library. There is an error dealing with setter method naming which appears for two out of fifty or so tags. Here's the description:

[b]org.apache.jasper.JasperException: /brands/previsor/customersettings/solutionlist.jsp(409,3) PWC6339: Cannot find a setter method for the attribute vals2 of the tag handler com.previsor.platform.tags.ui.CheckboxGroup[/b]

Here's the tag that I'm calling:

[b]<ui:checkboxgroup columns="6" checked="<%=checked%>" vals2="<%=szValueString%>" labelTexts="<%=labelTexts%>" labels="<%=labels%>" rules="required,maxSelected" all="true" none="true" maxSelected="5" />[/b]

The value of "szValueString" is, as you might imagine, a simple String.

Here is the setter method in my tag, CheckBoxGroup.java:

public void setVals2( String vals3 )
{
   this.vals2 = vals3;
   String [] tempVals = this.vals2.split( "," );
   this.alValues.clear();
   for ( int a = 0; a < tempVals.length; a++ )
   {
      this.alValues.add( tempVals[a] );
   }
}

I used to have it like this, but I thought passing an ArrayList might be causing problems:

public void setValues( ArrayList values )
{
   this.values = values;
}

Here's the TLD entry:

[b]<attribute>
   <name>vals2</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>[/b]

In all cases, I get the same error. Here's what I've tried:

1. Changing the name of the attribute to something else to avoid some unknown collision (along with the member variable name and setter method to match).
2. Changing the data type of the attribute
3. Changing the order the attributes appear in the tag jsp code.
4. Changing the TLD to make the attribute not required.
5. Changing the name of the setter method to all lower case.
6. Passing a null value as the attribute value.
7. Passing an empty ArrayList as the attribute value.
8. Keeping the bad attribute and adding a completely new one to pass the data.
9. Removing the vals2 attribute entirely <-- This works, but the tag is useless without it.
10. Removing the vals2 attribute entirely and adding another attribute to pass the data. (failed)

I thought it must be the data I'm passing, but after trying an empty ArrayList, an array of Strings, and finally a simple String value, I no longer do. Does anyone have any idea what Glassfish is looking for in a tag's setter method? Keep in mind, 48 out of the 50 tags I've written continue to work flawlessly. The two which do not work have only one thing in common: at the start of my troubles, both the bad attributes were named "values". I've done everything I could think of to eliminate that name as a cause.
[Message sent by forum member 'wrast34' (wrast34)]

http://forums.java.net/jive/thread.jspa?messageID=232529