Hi all-

I have this piece of html going against the "testForm" form bean that is
declared for that page. It calls the getTest method.

<bean:write name="testForm" property="test" filter="true"/>

causes

  public String getTest()
  {
    return "Test called";
  }

to be called. hence, it seems like fields can be calculated and may not have
value holding variables.



So I try the same thing with an array. First I create a dummy object to
store in the array.

  class Person
  {
    String name;
    Person(String name)
    {
      this.name = name;
    }
    public void setName(String name)
    {
      this.name = name;
    }
    public String getName()
    {
      return this.name;
    }
  }

Then I create the following in the "testForm" form bean.

  public Person[] getPersons()
  {
    Person[] result = new Person[3];
    result[0] = new Person("this");
    result[1] = new Person("that");
    result[2] = new Person("other");
    return result;
  }

But when I try to access this calculated "persons" property as follows

<logic:iterate id="person" name="testForm" property="persons">
  <bean:write name="person" property="name" filter="true"/>
  </p>
</logic:iterate>

I get "Cannot find bean person in scope null". Can someone point me what I
am doing wrong here?

The reasoning behind using calculated properties versus real ones is to
avoid nested collections and loading all at once after a successful login.
Also this will free me from maintaining the relations and updates in
memory/underlying db, and I will treat every record and their operations in
an atomic manner.

Thanks,
--a

Reply via email to