Dynamic include with TabView model and <ui:include> not work

UI Components for JSF
Post Reply
dieego_
Posts: 4
Joined: 23 Nov 2011, 05:34

06 Apr 2012, 01:52

I'm trying to create a dynamic include the TabView as follows:

Code: Select all

<p:tabView value="#{tabViewController.tabList}"
	activeIndex="#{tabViewController.activeIndex}" var="tabItem"
	dynamic="true" closeable="true" >
	
	<p:tab title="#{tabItem.title}">
		<ui:include src="#{tabItem.url}"></ui:include>
	</p:tab>
	
</p:tabView>
and

Code: Select all

public TabViewController() {
		setTabList(new ArrayList<TabItem>());

		getTabList().add(new TabItem("tab1", "pag1.xhtml", 0));
		getTabList().add(new TabItem("tab2", "pag2.xhtml", 1));
	}
The attribute "url" works within the <p:tab>, but does not work in <ui:include>.

I tried to debug the class IncludeHandler, the value is not evaluated correctly.
PrimeFaces 3.2
Mojarra 2.1.7
Tomcat 7

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

06 Apr 2012, 04:30

1. Look at your rendered HTML and see what is the rendered HTML for the ui:include src="..." in the xhtml below.

Code: Select all

   <p:tab title="#{tabItem.title}">
      <ui:include src="#{tabItem.url}"></ui:include>
   </p:tab>
2. WHat happens when you add cache="true"?

3. What happens when you remove dynamic="true"?

Please reply to all above, separately, and test results of # 2 and # 3.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

dieego_
Posts: 4
Joined: 23 Nov 2011, 05:34

10 Apr 2012, 05:39

hi, thanks for answering

1. The result for the xhtml is a empty <div>

Code: Select all

<div id="j_idt13:j_idt23:0:j_idt24" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-helper-hidden" role="tabpanel" aria-hidden="false" style="display: block; "></div>
The items 2 and 3, don't change the result.

In the class com.sun.faces.facelets.tag.ui.IncludeHandler, the method apply evaluates the attribute "src" and returns ""
PrimeFaces 3.2
Mojarra 2.1.7
Tomcat 7

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

10 Apr 2012, 07:27

1. Is your bean viewscoped? If so, try sessionScoped.
2. is your web.xml configured with partial/full state saving? See below.

http://www.lmgtfy.com/?q=stackoverflow+ ... coped+1492

I am using viewscoped beans and i just remembered that my fix for the issue discussed in the URL is as follows:

Code: Select all

    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
        <param-value>/index.xhtml</param-value>
    </context-param>
Since I have the ui:include src="..." in index.xhtml:

Code: Select all

                <p:layoutUnit position="center">
                    <p:outputPanel id="pageContentPanel" style="width: 100%; height: 100%">

                        <p:outputPanel layout="block">
                            <ui:include src="#{(pageNavigationController.isPageForPrinter() == true) ? pageNavigationController.blankPage : pageNavigationController.page}"/>
                        </p:outputPanel>

                    </p:outputPanel>
                </p:layoutUnit>
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

dieego_
Posts: 4
Joined: 23 Nov 2011, 05:34

10 Apr 2012, 14:02

Hi,

My bean is SessionScoped.
I had tried using a variable directly in the bean, and works out of <p:tabView>.
The problem occurs when I put this variable in the list of objects TabView
Still thanks for help.
PrimeFaces 3.2
Mojarra 2.1.7
Tomcat 7

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

10 Apr 2012, 16:46

Please share your entire bean which builds list of tabView tabs and url. I am building dynamic list of tabs via the POJO approach and I don't use dynamic="..." at all.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

sakkie6yster
Posts: 80
Joined: 23 Nov 2011, 08:46

25 Oct 2012, 14:36

Hi Smith,

were you actually able to use the ui:include with the dynamic tabs?

I am struggling with the same thing.
Primefaces 5.3, Extensions 4.0.0
Glassfish 3.1.2.2, Wildfly-10.0.0.Final
JSF 2.2

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

25 Oct 2012, 15:39

The problem lies with the use of <ui:include/>

This is a build time tag which means that it controls what is included in the component tree when this is first built. As a result of this EL expressions are only evaluated at build time and are never evaluated again even if the view is being refreshed.

For a more complete explanation on this, read this excellent article: http://www.ninthavenue.com.au/blog/c:fo ... n-facelets

If you are using templating, and you should be, then replace include with define and insert pairs.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

Cesar M. Casasola
Posts: 23
Joined: 23 Nov 2012, 01:26

09 Apr 2013, 01:26

andyba wrote:The problem lies with the use of <ui:include/>

This is a build time tag which means that it controls what is included in the component tree when this is first built. As a result of this EL expressions are only evaluated at build time and are never evaluated again even if the view is being refreshed.

For a more complete explanation on this, read this excellent article: http://www.ninthavenue.com.au/blog/c:fo ... n-facelets

If you are using templating, and you should be, then replace include with define and insert pairs.
Have any of you ever tried this?.

I'm trying following but neither work

Code: Select all

<p:dialog id="dlgWSistemas" widgetVar="dlgSistemas" 
		resizable="false" draggable="false" styleClass="dlgCenter" 
		visible="true" closable="false"
		onShow="showDlgSistemaListener()"
		onHide="hideDlgSistemaListener()" >	
	<p:outputPanel id="opTabSistemas">
		<p:tabView value="#{controller.listTabs}" var="t"  >
		<p:tab title="#{t.perfil}" >
			
			<ui:define name="pageSubMenu">
				<ui:insert>
					<ui:include src="#{t.url}" />
				</ui:insert>
			</ui:define>

		</p:tab>
		</p:tabView>
	</p:outputPanel>
</p:dialog>

<h:form prependId="false">
	<p:remoteCommand name="showDlgSistemaListener" 
		update=":opTabSistemas"
		actionListener="#{controller.openDialog}"/>
		
</h:form>
In my case, when openDialog shows call openDialog method that initialized listTabs object.

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

09 Apr 2013, 11:11

Cesar M. Casasola wrote:
andyba wrote:The problem lies with the use of <ui:include/>

This is a build time tag which means that it controls what is included in the component tree when this is first built. As a result of this EL expressions are only evaluated at build time and are never evaluated again even if the view is being refreshed.

For a more complete explanation on this, read this excellent article: http://www.ninthavenue.com.au/blog/c:fo ... n-facelets

If you are using templating, and you should be, then replace include with define and insert pairs.
Have any of you ever tried this?.

I'm trying following but neither work

Code: Select all

<p:dialog id="dlgWSistemas" widgetVar="dlgSistemas" 
		resizable="false" draggable="false" styleClass="dlgCenter" 
		visible="true" closable="false"
		onShow="showDlgSistemaListener()"
		onHide="hideDlgSistemaListener()" >	
	<p:outputPanel id="opTabSistemas">
		<p:tabView value="#{controller.listTabs}" var="t"  >
		<p:tab title="#{t.perfil}" >
			
			<ui:define name="pageSubMenu">
				<ui:insert>
					<ui:include src="#{t.url}" />
				</ui:insert>
			</ui:define>

		</p:tab>
		</p:tabView>
	</p:outputPanel>
</p:dialog>

<h:form prependId="false">
	<p:remoteCommand name="showDlgSistemaListener" 
		update=":opTabSistemas"
		actionListener="#{controller.openDialog}"/>
		
</h:form>
In my case, when openDialog shows call openDialog method that initialized listTabs object.
As your question is not related to the Thread topic you really need to ask it in a new Thread. Please do so.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests