You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Ayad <ma...@javamark.com> on 2002/11/10 22:51:01 UTC

Map-backed Action Forms

I'm trying out a Map-backed ActionForm. In my jsp I use :

<html:text property="value(username)" size="16" maxlength="16"/>

The action form is:

public class MapForm extends ActionForm
{
 private HashMap map = new HashMap();

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

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

 /**
  * Returns the map.
  * @return HashMap
  */
 public HashMap getMap()
 {
  return map;
 }
}

I'm getting:

500 Servlet Exception
javax.servlet.jsp.JspException: No getter method for property username
of bean org.apache.struts.taglib.html.BEAN

I have looked through the archive I can't find any pointers to what I'm doing wrong.

Any ideas ?

Re: Map-backed Action Forms

Posted by Mark Ayad <ma...@javamark.com>.
Fould the problem !

I should have in my MapForm class:

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);
    }


----- Original Message -----
From: "Mark Ayad" <ma...@javamark.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, November 10, 2002 10:51 PM
Subject: Map-backed Action Forms


I'm trying out a Map-backed ActionForm. In my jsp I use :

<html:text property="value(username)" size="16" maxlength="16"/>

The action form is:

public class MapForm extends ActionForm
{
 private HashMap map = new HashMap();

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

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

 /**
  * Returns the map.
  * @return HashMap
  */
 public HashMap getMap()
 {
  return map;
 }
}

I'm getting:

500 Servlet Exception
javax.servlet.jsp.JspException: No getter method for property username
of bean org.apache.struts.taglib.html.BEAN

I have looked through the archive I can't find any pointers to what I'm
doing wrong.

Any ideas ?



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>