Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject repository into other classes #2

Open
FrEaKmAn opened this issue Nov 29, 2013 · 1 comment
Open

Inject repository into other classes #2

FrEaKmAn opened this issue Nov 29, 2013 · 1 comment

Comments

@FrEaKmAn
Copy link

Hi

Thank you for this example. Even though there are few major problems with using your example in real-life projects, I'm still sticking with it. My question is how could I include repository into other classes beside controller? For example forms (LoginForm)?

  1. final Form form = Form.form(LoginForm.class).bindFromRequest();

  2. public class LoginForm
    {
    @required
    @Email
    public String email;

    @required
    public String password;
    public String next;

    @Autowired
    private PersonRepository personRepository;

...

personRepository is always null...any ideas?

@FrEaKmAn
Copy link
Author

Actually I got it working by calling

this.personRepository = Play.current().global().getControllerInstance(PersonRepository.class);

but I find it a bit hackish..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant