6 Replies Latest reply: Apr 23, 2012 10:26 AM by hantsy bai RSS

    How to load partial page content dynamically.

    hantsy bai Master

      I tried to user ui:included to load content in my new Seam3 application dynamically, but it did not work as my seam 2 application.

       

      The following steps were expected.

       

       

      1. click a link.

       

      <h:commandLink value="Company Search">
              <f:ajax render=":form:contentPane" execute="@this"  listener="{ set the content view }/>
          </h:commandLink>
      

       

      2.fire a navigation event and obseve the event.

       

       

      navEvent.fire(new NavigationEvent(
                         NavigationEnum.SEARCH_VIEW,
                         NavigationEnum.SEARCH_SIDEBAR_VIEW, 
                         NavigationEnum.SEARCH_COMPANY_LIST_VIEW)
              );
      

       

       

      public void onViewChanged(
                  @Observes(during = TransactionPhase.BEFORE_COMPLETION, notifyObserver = Reception.IF_EXISTS) NavigationEvent e) {
              if (log.isDebugEnabled()) {
                  log.debug(" view changed...@" + e);
              }
      
              if (e.getMainView() != null) {
                  this.setMainView(e.getMainView().getViewId());
              }
      
              if (e.getSidebarView() != null) {
                  this.setSidebarView(e.getSidebarView().getViewId());
              }
      
              this.setContentView(e.getContentView().getViewId());
          }
      

       

      3. rerender the content

       

       

      <h:panelGroup id="contentPane" layout="block" styleClass="ch-box">
                          <h2>
                              <ui:insert name="pageTitle" />
                          </h2>
      
                          <ui:include src="#{nav.contentView}" />
                      </h:panelGroup>
      

       

      The third step is problematic here....the rendering is delayed, when the event had been fired, it still kept in the original page, when I refreshed the page manully, it will load the page correctly.

       

      Where is wrong in these steps?

       

      I have used this mode in my seam2 application, and I think every Seam 2 developer should remember the RichFaces Photoalbum application, it also used the Seam2 events.

       

       

      BTW: My development envoirment, JBoss 7.0.1(Majarro 2.0.2, Weld 1.1.5), JDK 7.

       

      Any suggestions here?