Advertisement
Advertisement


Can I submit a Struts form that references POJO (i.e. not just String or boolean) fields?


Question

I have a Struts (1.3x) ActionForm that has several String and boolean properties/fields, but also has some POJO fields.

so my form looks something like:

MyForm extends ActionForm {
    private String name;
    private int id;
    private Thing thing;

    ...getters/setters...
}

In the JSP I can reference the POJO's fields thusly:

<html:text property="thing.thingName" />

...and the values display correctly, but if I try to submit the form I get the ServletException: BeanUtils.populate error.

There seems to be a lot of information about this general topic on the web, but none really addresses my specific question, which is: shouldn't I be able to submit a form in Struts that contains fields that are POJOs?

2008/09/15
1
1
9/15/2008 3:27:51 PM

Accepted Answer

You can, as long as the fields follow the JavaBean conventions and the setter takes something Struts can understand.

So Thing needs getThingName() and setThingName(String).

2014/12/19
2
12/19/2014 12:21:36 PM

Source: https://stackoverflow.com/questions/63935
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]