How Else Can I Do This With Errai ??
chaluwa Apr 1, 2015 11:04 AMThe Problem
I want to be able to have modal overlays of certain @Page templates in my app such that the overlays can be invoked from any @Page showing in Errai UI Navigation Panel. Consider an managing Products that should be in a Category, traditionally I'd have views to create / list categories and products separately. I'd create a Category first and then create a Product, specifying the category of the product while creating it. This means that if I am already at the Product view and need to make a news Product for a category that does not yet exist, then I'd have to navigate back / away to the Category view to create it first before coming back to continue creating the Product I earlier wanted to create.
My Solution
A solution would be to have a button on the Product view that opens the same Category @Page (or another @Templated version of it) in a modal dialog. Such that the Product creation workflow is not interrupted by navigating away.
I tried this experiment with a @Templated LoginView component which I subclassed into a @Templated LoginPageView @Page and a @Templated LoginModalView component. LoginView is a @Dependent view that targets the whole of a login.html file and is @AutoBound to a @Portable and @Bindable Login POJO whose username and password fields are bound into the view with @DataField elements.
LoginPageView is a @Page that extends LoginView and targets a portion of the login.html file, it participates in Errai UI Navigation and is displayed within the navigation panel. LoginModalView is a @Templated component that also extends LoginView and also targets another portion of the same login.html file suited for the modal UI. Since both extend LoginView, they inherit her protected @DataFields bound to the username and password fields of the Login POJO.
The Outcome
Since I try to follow the MVP pattern, I have a "Presenter" that will drive these UIs / views, and thats where things begin to fall apart. I have a @ApplicationScoped AuthPresenter that should drive the login process like a controller. Within it, I inject the LoginPageView and I am able to use the app as planned. However, once I try to inject the LoginModalView (the second LoginView implementation), the app fails to run and complains thus : " org.jboss.errai.ioc.rebind.ioc.exception.InjectionFailure: unable to resolve type injector for: meshportal.client.local.LoginView "
The Question
It appears I can't inject and use both subclasses of the LoginView component within AuthPresenter. Am I missing something or is there a better way to approach this ?? You can have a look at portions of my code here : http://ur1.ca/k2zm2