struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C H" <>
Subject Map-backed action form and multibox problem
Date Mon, 02 Jun 2003 21:53:58 GMT

Iím working on an application thatís designed to render dynamic pages that 
take as input an ArrayList of DisplayItemBeans.  Each DisplayItemBean has 
properties that define:
(a) the UI widget type (text, checkbox, radio button, etc)
(b) the data itemís db column name (used as key in an action form Map)
(c) for selection-type widgets (listbox, checkbox, radio button), a list of 
available options.

I defined a Map-backed ActionForm and a jsp template to work with this 
ArrayList (pls see code snippets below).  The pages render fine for all 
types of widgets except checkboxes.  When I use the html:multibox tag, I 
encounter the following problem:

[ServletException in:/WEB-INF/jsp/dynaBody.jsp] No getter method available 
for property multibox_key_name for bean under name 

However, using the same code, if I just change the widget type to radio 
button or select, things work fine.  Iíd appreciate any comments on what I 
did wrong and suggestions on how I can fix it.


------------- CODE SNIPPETS FOLLOW ----------------

============= ACTION FORM =========================

public class OnlsDynaActionForm extends ActionForm {

   public OnlsDynaActionForm() {

   //QUES: Sample from jakarta website declared this Map as final.
   //Does it need to be final? What's the advantage of using final?
   private final Map values = new HashMap();

   public void setValue(String key, Object value) {
      values.put(key, value);

   public Object getValue(String key) {
      return values.get(key);

======================= JSP =========================

[Assume that dispList, an ArrayList of DisplayItemBeans, exists in some 
scope and:
- has get/set methods for scrn_clmn (label to display), db_clmn (column name 
used as key in ActionForm map), options (ArrayList of LabelValueBeans 
containing choices for selection widgets)
- has helper methods such as isUITypeCheckbox() to identify what type of 
widget it is]

<logic:iterate id="dib" name="dispList" type="DisplayItemBean" >
<bean:define id="db_clmn" value='<%= "value(" + dib.getDb_clmn() + ")" %>'/>
     <td><bean:write name="dib" property="scrn_clmn" /></td>
	<% if (dib.isUITypeCheckbox() ) { %>
	     <logic:iterate id="opt" name="dib" property="options" 
type="org.apache.struts.util.LabelValueBean" >
                          <html:multibox  property="<%=dib.getDb_clmn()%>" >
                          <bean:write name="opt" property="value" />
                          <bean:write name="opt" property="label" />
	<% } else if (dib.isUITypeRadiobutton() ) { %>
		... display using html:radio
	<% } else if ...{ %>
		...handle other cases
	<% } %>

Tired of spam? Get advanced junk mail protection with MSN 8.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message