如何在 TabMenu 中更改 activeindex [英] How to change activeindex in TabMenu
本文介绍了如何在 TabMenu 中更改 activeindex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个关于primefacess的组件Tabmenu的问题,特别是属性active index,所选页面的索引.我想根据选择的页面更改它,但它始终固定在首页上!这是我的代码:
I have a question concerning the component Tabmenu of primefacess and specifically the attribute active index, the index of the page selected. I would like to change it according to the page chosen but it is always fixed on the front page! This is my code:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<p:tabMenu rendered="true" widgetVar="index">
<p:menuitem value="Home" url="Menu.jsf" icon="ui-icon-star"/>
<p:menuitem value="Fabricants" url="/pagess/pagesFabricant/Fabricant.jsf" icon="ui-icon-wrench" oncomplete="index.select(1)"/>
<p:menuitem value="Composants" url="/pagess/pagesComposant/Composant.jsf" icon="ui-icon-search" oncomplete="index.select(2)"/>
<p:menuitem value="Dossier d'equivalence" url="DEQ.jsf" icon="ui-icon-document" oncomplete="index.select(3)"/>
</p:tabMenu>
</ui:composition>
它不起作用
感谢您的合作,但它不起作用
thx for your cooepration ,but its not working
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<p:tabMenu activeIndex="0" >
<p:menuitem value="Home" url="Menu.jsf" icon="ui-icon-star" update="@all"/>
<p:menuitem value="Fabricants" url="/pagess/pagesFabricant/Fabricant.jsf" icon="ui-icon-wrench" update="@all" />
<p:menuitem value="Composants" url="/pagess/pagesComposant/Composant.jsf" icon="ui-icon-search" update="@all"/>
<p:menuitem value="Dossier d'equivalence" url="DEQ.jsf" icon="ui-icon-document" update="@all"/>
</p:tabMenu>
</ui:composition>
推荐答案
创建 template.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<p:tabMenu activeIndex="#{activeIndex}">
<p:menuitem
value="tab1"
url="/tab1.jsf">
</p:menuitem>
<p:menuitem
value="tab2"
url="/tab2.jsf">
</p:menuitem>
</p:tabMenu>
<h:panelGroup id="mainPanel" style="width:100%">
<ui:insert name="page">Page Content</ui:insert>
</h:panelGroup>
</ui:composition>
在标签页中设置参数
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="template.xhtml">
<ui:param name="activeIndex" value="1" />
<ui:define name="page">
tab1 content
</ui:define>
</ui:composition>
这篇关于如何在 TabMenu 中更改 activeindex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文