Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

  • Use OGNL expressions - the framework will automatically take care of creating the actual objects for you.
  • Use JavaBeans! The framework can only create objects that obey the JavaBean specification, provide no-arg constructions and include getters and setters where appropriate.
  • Remember that person.name will call getPerson().setName(). If the framework creates the Person object for you, it remember that a setPerson method must also exist.
  • The framework will not instantiate an object if an instance already exists. The PrepareInterceptor or action's constructor can be used to create target objects before type conversion.
  • Wiki MarkupFor lists and maps, use index notation, such as _people\[0\].name_ or _friends\['patrick'\].name_. Often these HTML form elements are being rendered inside a loop. For [JSP Tags], use the iterator tag's status attribute. For [FreeMarker Tags], use the special property $\{foo_index\}\[\].
  • For multiple select boxes, it isn't possible to use index notation to name each individual item. Instead, name your element people.name and the framework will understand that it should create a new Person object for each selected item and set its name accordingly.

...

The framework automatically converts the type of the parameter sent in to the type of the key property using type conversion.

Wiki MarkupUnlike Map and List element properties, if {{fooCollection(22)}} does not exist, it will not be created. If you would like it created, use the notation {{fooCollection.makeNew\[index\]}} where _index_ is an integer 0, 1, and so on. Thus, parameter value pairs {{fooCollection.makeNew\[0\]=Phil}} and {{fooCollection.makeNew\[1\]=John}} would add two new Foo Objects to {{fooCollection \ -\-}} one with name property value {{Phil}} and the other with name property value {{John}}. However, in the case of a Set, the {{equals}} and {{hashCode}} methods should be defined such that they don't only include the {{id}} property. Otherwise, one element of the null {{id}} properties Foos to be removed from the Set.

An advanced example for indexed Lists and Maps

...

  • When submitting this via a form, the id value is used as KeyProperty for the MyBean instances in the beanList.
  • Wiki MarkupNotice the () notation\! Do not use \ [\] notation, which is for Maps only\!
  • The value for name will be set to the MyBean instance with this special id.

...