binding model data submitted via an HTML form.
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
> That is what the documentation implies for custom bindings:
>
> The @As annotation also allows you to define a completely custom
> binder. A custom binder is subclass of TypeBinder that you define in
> your project...You can use it in any action...
>
> And that is what my tests confirm. What is a little puzzling is that
> in the section above the one from which I just quoted, one sees this:
>
> public class User extends Model {
> @NoBinding("profile") public boolean isAdmin;
> @As("dd, MM yyyy") Date birthDate;
> public String name;
> }
>
> Which suggests that the @As annotation can be used at the field level.
> But when I stepped through a model save operation using a custom @As
> binding, the custom binder was never triggered.
>
> If I am missing something, please let me know. If a regular (as
> opposed to custom) @As annotation can indeed be applied to a model
> field, when is the formatting applied - during a model save?
>
It is applied during the binding phase ie when binding http parameter to Java object.
For example
?user.birthdate=22,%2009%201980&user.name=bob
with a controller class
public static void profile(User user) {
// User is now an object with name=bob and birthDate=Date(22nd september 1980)
}
Does that answer your question?
Nicolas