Take this POJO as the domain.
public class Invoice {
private String codeNumber;
private BigDecimal amount;
private String notes;
private List<InvoiceRows> rows;
}
I have a form which takes that as @ModelAttribute. The form has got four text inputs: codeNumber, amount, notes and "emailAddressToNotify". The POJO's "rows" property is filled in another place, so it's ignored and that's right.
On the other side, the "emailAddressToNotify" property is sent by the form's 'POST' but obviously it's not related with the Invoice POJO. Actually, I need it in my controller "processForm()" method.
Can I simply add a @RequestParam parameter to get it?
And here's the second part of the question, as it's related to the first one:
in my web application, I will often write "huge" forms, in which the fields do not always correspond to the fields of one of my domain objects. So, I ask you for what is the best practice:
Do I have to write a "form-dedicated" POJO, so I can always use @ModelAttribute and validate fields the easy way? or... ?