You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Vincent Craven <pa...@cravenfamily.com> on 2002/12/08 22:41:12 UTC

Struts

Hi,

I have a DynaValidatorForm I want to pre-populate with info from a
database. I have no problem doing this with a non-dynamic form. My code
looks like this:

DynaValidatorForm newForm = new DynaValidatorForm();
newForm.set("personNameInfo","firstname",person.getFirstName());

I have also tried:
DynaValidatorForm newForm = new DynaValidatorForm();
newForm.set("firstname",person.getFirstName());

Form name is "personNameInfo", field name is "firstname". I'm not sure
the difference between name/key/value. I don't know what 'name'
represents.

I store the form in the request under the key "personNameInfo".

When I try the 'set' though, I get an exception:

ERROR-15:19:36,060 frontend.struts.SelectPersonAction-Error fetching
person with id=7
java.lang.NullPointerException
        at
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.j
ava:551)
        at
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:442)
        at
com.cravenfamily.registry.frontend.struts.SelectPersonAction.secureExecu
te(SelectPersonAction.java:59)

The problem is my 'dynaClass' is null. I assume there is some kind of
init I'm supposed to be calling, but I don't know what it is. Here's the
relavent DynaActionForm code.

    /**
     * Return the property descriptor for the specified property name.
     *
     * @param name Name of the property for which to retrieve the
descriptor
     *
     * @exception IllegalArgumentException if this is not a valid
property
     *  name for our DynaClass
     */
    protected DynaProperty getDynaProperty(String name) {

        DynaProperty descriptor = getDynaClass().getDynaProperty(name);
<-- Exception
        if (descriptor == null) {
            throw new IllegalArgumentException
                ("Invalid property name '" + name + "'");
        }
        return (descriptor);

    }

What am I missing?

Paul Vincent Craven


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