Maximum Redirect Error from ErraiUI ??
chaluwa Dec 28, 2013 12:54 PMI have a situation where navigating to a @Page from another @Page results in some kind of recursion and produces a "maximum redirect error" . Here's what I am trying to do.
PostView fires a CDI event when it is shown, this causes PostPresenter to load data (posts). Each post is in a category and there's a view / presenter for them. So we also have CategoryPresenter and CategoryView.
The PostView needs to display category data (say in a combo-box), so the CategoryPresenter listens for the CDI event fired by PostView when PostView is shown, and loads categories if they are not already loaded. This helps if the user visits PostView first. When categories are loaded, a CDI event is fired, PostView observes it and displays categories.
The arrangement is kinda straight-forward, when the app loads and I click on the PostView link which is an injected TransitionActchor<PostView> element in a @Template component used as navbar, the PostView is displayed, showing posts and categories. However, if I proceed to click on the CategoryView link, which is also an an injected TransitionActchor<CategoryView> element in the same navbar component, then we end up in a recursion and the eventual error saying I have exhausted the maximum 99 redirects.
The same thing happens if I start with CategoryView and then try to go to PostView. I have tried to simplify my setup with this Post / Category scenario here, any hints about the error and its solution ??
@Page @Templated
@Singleton
public class PostView extends Composite {
@Inject
private Event<PostViewShown> shownEvt;
@PageShown
private void onPageShown() {
shownEvt.fire(new PostViewShown());
}
...
}
@Page @Templated
@Singleton
public class CategoryView extends Composite {
@Inject
private Event<CategoryViewShown> shownEvt;
@PageShown
private void onPageShown() {
shownEvt.fire(new CategoryViewShown());
}
...
}
@ApplicationScoped
public class PostPresenter {
@Inject
private PostView display;
private void onViewShown(@Observes PostViewShown e){
LogUtil.log("load posts");
...
}
private void onCategoryData(@Observes CategoryData e){
LogUtil.log("populate combo");
...
}
}
@ApplicationScoped
public class CategoryPresenter {
@Inject
private CategoryView display;
@Inject
private Event<CategoryData> dataEvt;
private void onViewShown(@Observes CategoryViewShown e){
LogUtil.log("load categories");
loadCategories();
}
private void onPostViewShown(@Observes PostViewShown e){
LogUtil.log("load categories for postview");
loadCategories();
}
private void loadCategories(){
// if data has not been loaded
// load data, then fire CDI event that data is available
dataEvt.fire(new CategoryData(list));
}
}