mardi 19 mai 2015

Spring MVC - form handling with object request params

Assume I have the following entities in my application:

public class Payment {
    private Long id;
    private Service service;
    private User user;
    private BigDecimal amount;
}

public cass Service {
    private Long id;
    private String name;
    private BigDecimal minAmount;
    private BigDecimal maxAmount;
}

public class User {
    private Long id;
    private String login;
    private String password;
    private BigDecimal balance;
}

I need to create html form that will allow users to process payments (instances of Payment class). So I need to create Payment instance in my controller method. I know that I can add to controller method, for example, Service service argument, and it will be filled by values from form with the same names. But how can I get the filled Payment object? With filled Service and User objects? I need to somehow save the whole Service object in my server page? How? I use Thymeleaf, if it matters.




Aucun commentaire:

Enregistrer un commentaire