3 Replies Latest reply on Mar 15, 2010 6:18 PM by nbelaevski

    <ui:include src Dynamically load file issue

    sandeepgowda

      Hi,

      I am attached the code below, the component <ui:include, where SRC value change dynamically, but the browser is not getting reflected.

       

      only on browse Refresh(press of F5),its working, please help me in fix.

       

       

      <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich">
          <head>
              <title>Customer Details</title>
              <meta http-equiv="keywords" content="enter,your,keywords,here" />
              <meta http-equiv="description"
                  content="A short description of this page." />
              <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

       

              <style>
      .cols {
          vertical-align: top;
          width: 50%;
      }
      </style>
          </head>

       

          <body>
              <h:form id="form">
                  <h:panelGrid columns="2" columnClasses="cols" width="100%">
                      <rich:panelMenu style="width:200px" mode="ajax"
                          iconExpandedGroup="disc" iconCollapsedGroup="disc"
                          iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
                          iconCollapsedTopGroup="chevronDown">
                          <rich:panelMenuGroup label="Asset and Liability ">
                              <rich:panelMenuItem label="Asset"
                                  action="#{MainPanel.onAssetSelection}" reRender="selectedPanel">
                                  <a4j:support event="oncomplete" reRender="selectedPanel" ></a4j:support>
                              </rich:panelMenuItem>
                              <rich:panelMenuItem label="Liability"
                                  action="#{MainPanel.onLiabilitySelection}"
                                  reRender="selectedPanel">
                                  <f:param name="strCurrent" value="/Jsf/SearchCustomer.xhtml" />
                              </rich:panelMenuItem>
                          </rich:panelMenuGroup>
                          <rich:panelMenuGroup label="Group 2">
                              <rich:panelMenuItem label="Item 2.1">
                                  <f:param name="strCurrent" value="Item 2.1" />
                              </rich:panelMenuItem>
                              <rich:panelMenuItem label="Item 2.2">
                                  <f:param name="strCurrent" value="Item 2.2" />
                              </rich:panelMenuItem>
                              <rich:panelMenuItem label="Item 2.3">
                                  <f:param name="strCurrent" value="Item 2.3" />
                              </rich:panelMenuItem>
                              <rich:panelMenuGroup label="Group 2.4">
                                  <rich:panelMenuItem label="Item 2.4.1">
                                      <f:param name="strCurrent" value="Item 2.4.1" />
                                  </rich:panelMenuItem>
                                  <rich:panelMenuItem label="Item 2.4.2">
                                      <f:param name="strCurrent" value="Item 2.4.2" />
                                  </rich:panelMenuItem>
                                  <rich:panelMenuItem label="Item 2.4.3">
                                      <f:param name="strCurrent" value="Item 2.4.3" />
                                  </rich:panelMenuItem>
                              </rich:panelMenuGroup>
                              <rich:panelMenuItem label="Item 2.5">
                                  <f:param name="strCurrent" value="Item 2.5" />
                              </rich:panelMenuItem>
                          </rich:panelMenuGroup>
                          <rich:panelMenuGroup label="Group 3">
                              <rich:panelMenuItem label="Item 3.1">
                                  <f:param name="strCurrent" value="Item 3.1" />
                              </rich:panelMenuItem>
                              <rich:panelMenuItem label="Item 3.2">
                                  <f:param name="strCurrent" value="Item 3.2" />
                              </rich:panelMenuItem>
                              <rich:panelMenuItem label="Item 3.3">
                                  <f:param name="strCurrent" value="Item 3.3" />
                              </rich:panelMenuItem>
                          </rich:panelMenuGroup>
                      </rich:panelMenu>
                      <h:panelGroup id="selectedPanel" rendered="true">
                          <rich:panel bodyClass="rich-laguna-panel-no-header">
                              <a4j:outputPanel ajaxRendered="true">
                                  <ui:include src="#{MainPanel.strSelectedPath}"></ui:include>
                                  <h:outputText value="#{MainPanel.strSelectedPath}" id="Current" />
                              </a4j:outputPanel>
                          </rich:panel>
                      </h:panelGroup>
                  </h:panelGrid>
              </h:form>
          </body>
      </html>

       

      regards

      Sandeep

        • 1. Re: <ui:include src Dynamically load file issue
          nbelaevski

          Hi Sandeep,

           

          Try adding a4j:log to the page and check if there are any errors/warnings.

          • 2. Re: <ui:include src Dynamically load file issue
            sandeepgowda

            Thanks for the replay, but i tried log, no errors....

             

            But i understood that UI:Include is static loader, so we need the explicitly Load the component,

             

            But i am stuck while getting FaceletFactory instance. Canyou please help me. Below method will be called on click of menu.

             

            FacesContext facesContext = FacesContext.getCurrentInstance();

             

            Application application = facesContext.getApplication();
                       
                         UIViewRoot viewRoot = facesContext.getViewRoot();
                       
                         // if (viewRoot instanceof PartialViewRoot) {
                         // viewRoot = ((PartialViewRoot) viewRoot).getBase();
                         // /*restorePartialView(facesContext, (PartialViewRoot)
                         viewRoot);*/
                         // }
                       
                         String id = "form" + UINamingContainer.SEPARATOR_CHAR
                         + "selectedPanel";
                         UIPanel includeSection = (UIPanel) viewRoot.findComponent(id);
                       
                         if (includeSection == null) {
                         // LOG.error("Component with Id '" + id + "' was not found");
                       
                         return;
                         }
                                           
                                              
                         FaceletFactory factory = ?????HOW to Get Instance in Richfaces.
                       
                         Facelet ft = factory.getFacelet(.strSelectedPath);
                       
                         // construct component sub-tree with given parent
                         ft.apply(facesContext, includeSection);
                       
                         // some required magic ...
                         includeSection.getAttributes().remove("com.sun.facelets.MARK_ID");

            • 3. Re: <ui:include src Dynamically load file issue
              nbelaevski
              Try a4j:include component.