Nevermind i am able to resolve the issue.

I was creating a new instance of HomeView in onValueChange() which is
causing the issue..(I don't need to create this instance as i already
created it in the ApplicationController constructor..

Thanks




On Jun 20, 5:43 pm, rvns-pats <[email protected]> wrote:
> Hi All,
>
>   I wrote a sample app (based on Contacts2 ) to use the UiBinder and
> using the MVP Pattern and initially my home presenter is getting
> invoked and every thing works fine. Once i click on a link on the left
> hand side panel i want to display a new view in the center panel of my
> DocLayoutPanel. The events are getting fired properly and the event
> Handler is getting the event and updating the view. But the UI is not
> displaying the updated panel . I am not sure what's going wrong.
>
>   Here is the sample code i have..
>
> HomeView.ui.xml:
>
> [CODE]
> <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
>         xmlns:g="urn:import:com.google.gwt.user.client.ui">
> <g:DockLayoutPanel unit='EM' >
>                 <g:north size="5">
>                         <g:HTML >
>                                 <h2> Test heading</h2>
>                         </g:HTML>
>                 </g:north>
>                 <g:south size="3">
>                         <g:HTML >
>                                 <h2> Test Footer </h2>
>                         </g:HTML>
>                 </g:south>
>                 <g:west size="15">
>                         <g:FlowPanel ui:field="navContainer" 
> width="100%"></g:FlowPanel>
>                 </g:west>
>                 <g:center size="12">
>                         <g:FlowPanel>
>                                         <g:FlowPanel 
> ui:field="SummaryContainer" width="100%"></
> g:FlowPanel>
>                                         <g:FlowPanel 
> ui:field="DetailsContainer" width="100%"></
> g:FlowPanel>
>                         </g:FlowPanel>
>                 </g:center>
>         </g:DockLayoutPanel>
> </ui:UiBinder>
> [/CODE]
>
> HomeView.java
> [CODE]
> import
> org.finra.watchlists.client.controller.ApplicationController.Display;
> public class HomeView extends Composite implements Display {
>
>         private static HomeViewUiBinder uiBinder = GWT
>                         .create(HomeViewUiBinder.class);
>
>         @UiTemplate("HomeView.ui.xml")
>         interface HomeViewUiBinder extends
>                         UiBinder<Widget, HomeView> {
>         }
>
>         @UiField
>         public
>         FlowPanel navContainer;
>         @UiField
>         public
>         FlowPanel summaryContainer;
>
>         public FlowPanel getNavContainer() {
>                 return navContainer;
>         }
>         public void setNavContainer(FlowPanel navContainer) {
>                 this.navContainer = navContainer;
>         }
>
>         public FlowPanel getSummaryContainer() {
>                 return summaryContainer;
>         }
>
>         public HomeView() {
>                 initWidget(uiBinder.createAndBindUi(this));
>         }
>
>         public Widget asWidget() {
>                 return this;
>         }}
>
> [/CODE]
>
> In my AppController 's onValueChange i have
>
> [CODE]
> public class ApplicationController implements
> ValueChangeHandler<String>{
>
>         private final HandlerManager eventBus;
>         private final MyServiceAsync rpcService;
>         private HasWidgets container;
>
>         private Display view = null;
>
>         public interface Display extends View {
>                 public FlowPanel getNavContainer();
>                 public FlowPanel getSummaryContainer();
>         }
>      public ApplicationController(MyServiceAsync rpcService,
> HandlerManager eventBus) {
>             this.eventBus = eventBus;
>             this.rpcService = rpcService;
>             this.view = new HomeView();
>             bind();
>           }
>
>           private void bind() {
>             History.addValueChangeHandler(this);
>
>             eventBus.addHandler(MenuItemSelectedEvent.TYPE,
>                     new MenuItemSelectedEventHandler(){
>                                         @Override
>                                         public void 
> onMenuItemSelected(MenuItemSelectedEvent event) {
>                                                 
> GWT.log(".onMenuItemSelected() : selected Item =["+event.getId()
> +"]");
>                                                 
> if(event.getId().equals("NavItem1"))
>                                                 {
>                                                         GWT.log("Displaying 
> the SummaryView");
>                                                         
> SummaryPresenter.Display summaryView = new SummaryView();
>                                                         SummaryPresenter 
> summaryPresenter = new
> SummaryPresenter(rpcService, eventBus, summaryView);
>                                                         
> summaryPresenter.go(view.getSummaryContainer());
>                                                 }
>                                                 else 
> if(event.getId().equals("NavItem2"))
>                                                 {
>                                                         // Code to display 
> the details View.
>                                                 }
>                                         }
>                                 });
>
>           }
>
> @Override
>         public void onValueChange(ValueChangeEvent<String> event) {
>                 String token = event.getValue();
>                 GWT.log("onValueChange() : token =["+token+"]");
>                 if (token.equals("home")) {
>                 GWT.runAsync(new RunAsyncCallback() {
>                   public void onFailure(Throwable caught) {
>                   }
>
>                   public void onSuccess() {
>                     Display viewHome = new HomeView();
>                     HomePresenter presenter = new
> HomePresenter(rpcService,eventBus,viewHome);
>                     presenter.go(container);
>                   }
>                 });
>               }
>         }
>
>         public void go(final HasWidgets container) {
>             this.container = container;
>
>             if ("".equals(History.getToken())) {
>               History.newItem("home");
>             }
>             else {
>               History.fireCurrentHistoryState();
>             }
>           }}
>
> [/CODE]
>
> My Presenter Interface
>
> [CODE]
> public interface Presenter {
>         void go(final HasWidgets container);}
>
> [/CODE]
>
> My Home Presenter:
>
> [CODE]
> public class HomePresenter implements Presenter{
>         private MyServiceAsync rpcService =null;
>         private HandlerManager eventBus = null;
>         private Display display = null;
>         public HomePresenter(MyServiceAsync rpcService,HandlerManager
> eventBus,Display display) {
>                 super();
>                 this.rpcService = rpcService;
>                 this.eventBus = eventBus;
>                 this.display = display;
>         }
>         @Override
>         public void go(HasWidgets container)
>        {
>                // Just Update the Navigation Container...
>                 container.clear();
>                 container.add(display.asWidget());
>                 NavigationPresenter.Display viewNav = new NavigationView();
>                 NavigationPresenter navPresenter = new
> NavigationPresenter(rpcService, eventBus, viewNav);
>         navPresenter.go(display.getNavContainer());
>         }}
>
> [/CODE]
>
> My NavagationPresenter is:
>
> [CODE]
> public class NavigationPresenter implements Presenter{
>
>         public interface Display extends View
>         {
>                 void setData(java.util.ArrayList<String> menuItemList);
>                 String getSelectedItem();
>                 HasSelectionHandlers<TreeItem> getMenuItemsList();
>         }
>
>         private Display display = null;
>         private MyServiceAsync rpcService =null;
>         private HandlerManager eventBus = null;
>
>         public NavigationPresenter(MyServiceAsync rpcService,HandlerManager
> eventBus,Display display) {
>                 super();
>                 this.rpcService = rpcService;
>                 this.eventBus = eventBus;
>                 this.display = display;
>                 bind();
>                 rpcService.getNavigationMenuList(new
> AsyncCallback<ArrayList<String>>() {
>                       public void onSuccess(ArrayList<String> result)
>                       {
>                           NavigationPresenter.this.display.setData(result);
>                       }
>
>                       public void onFailure(Throwable caught) {
>                           Window.alert("Error retrieving Menu Item List");
>                       }
>                   });
>         }
>          public void bind() {
>                  display.getMenuItemsList().addSelectionHandler(new
> SelectionHandler<TreeItem>() {
>
>                         @Override
>                         public void onSelection(SelectionEvent<TreeItem> 
> event) {
>                                 String selectedItem = 
> event.getSelectedItem().getText();
>                                 eventBus.fireEvent(new 
> MenuItemSelectedEvent(selectedItem));
>                         }
>                 });
>          }
>         @Override
>         public void go(HasWidgets container) {
>                 container.clear();
>             container.add(display.asWidget());
>         }}
>
> [/CODE]
>
> My Navigation View:
>
> [CODE]
> import NavigationPresenter.Display;
> public class NavigationView extends Composite implements Display{
>
>         private static NavigationViewUiBinder uiBinder =
> GWT.create(NavigationViewUiBinder.class);
>
>         @UiTemplate("NavigationView.ui.xml")
>         interface NavigationViewUiBinder extends UiBinder<Widget,
> NavigationView> {}
>
>         @UiField FlowPanel listsMenus;
>         private Tree menuItems = new Tree();
>         public NavigationView(){
>                 initWidget(uiBinder.createAndBindUi(this));
>         }
>         @Override
>         public Widget asWidget() {
>                 return this;
>         }
>         @Override
>         public void setData(ArrayList<String> menuItemList) {
>                 for(String menuItem: menuItemList){
>                         TreeItem item = new TreeItem(menuItem);
>                         this.menuItems.addItem(item);
>                 }
>                 if(listsMenus==null){
>                         listsMenus = new FlowPanel();
>                         initWidget(listsMenus);
>                 }
>                 listsMenus.add(this.menuItems);
>         }
>         @Override
>         public String getSelectedItem() {
>                 return this.menuItems.getSelectedItem().getText();
>         }
>         @Override
>         public HasSelectionHandlers<TreeItem> getMenuItemsList() {
>                 return this.menuItems;
>         }}
>
> [/CODE]
>
> And the UiBinder for Navigation View NavigationView.ui.xml:
> [CODE]
> <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
>         xmlns:g="urn:import:com.google.gwt.user.client.ui">
>         <ui:style>
>         </ui:style>
>         <g:FlowPanel>
>                 <g:FlowPanel ui:field="listsMenus" />
>         </g:FlowPanel>
> </ui:UiBinder>
> [/CODE]
>
> Here is SummaryPresenter:
>
> [CODE]
> public class SummaryPresenter implements Presenter{
>
>         private Display display = null;
>         private MyServiceAsync rpcService =null;
>         private HandlerManager eventBus = null;
>         public interface Display extends View
>         {
>         }
>
>         public SummaryPresenter(MyServiceAsync rpcService,HandlerManager
> eventBus,Display display)
>         {
>                 super();
>                 this.rpcService = rpcService;
>                 this.eventBus = eventBus;
>                 this.display = display;
>         }
>
>         @Override
>         public void go(HasWidgets container) {
>                 container.clear();
>                 container.add(display.asWidget());
>         }}
>
> [/CODE]
>
> SummaryView.java
>
> [CODE]
> import SummaryPresenter.Display;
> public class SummaryView extends Composite implements Display{
>         private static SummaryViewUiBinder uiBinder =
> GWT.create(SummaryViewUiBinder.class);
>         @UiTemplate("SummaryView.ui.xml")
>         interface SummaryViewUiBinder extends UiBinder<Widget,SummaryView> {}
>         @UiField FlowPanel summary;
>         public SummaryView()
>         {
>                 initWidget(uiBinder.createAndBindUi(this));
>         }
>         @Override
>         public Widget asWidget() {
>                 return this;
>         }}
>
> [/CODE]
>
> And SummaryView.ui.xml
>
> [CODE]
> <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
>         xmlns:g="urn:import:com.google.gwt.user.client.ui">
>         <ui:style>
>
>         </ui:style>
>         <g:FlowPanel>
>                 <g:Label> Summary Panel :</g:Label>
>                 <g:FlowPanel ui:field="summary" />
>         </g:FlowPanel>
> </ui:UiBinder>
> [/CODE]
>
>  Sorry for the long post..Appreciate your help

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to