struts-user mailing list archives

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

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 
org.apache.struts.taglib.html.BEAN'

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.

Thanks

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

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

public class OnlsDynaActionForm extends ActionForm {

   public OnlsDynaActionForm() {
	super();
   }

   //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" >
<tr>
<bean:define id="db_clmn" value='<%= "value(" + dib.getDb_clmn() + ")" %>'/>
     <td><bean:write name="dib" property="scrn_clmn" /></td>
     <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" />
                          </html:multibox>
                          <bean:write name="opt" property="label" />
	     </logic:iterate>
	<% } else if (dib.isUITypeRadiobutton() ) { %>
		... display using html:radio
	<% } else if ...{ %>
		...handle other cases
	<% } %>
     </td>
</tr>
</logic:iterate>

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message