I want to create Primefaces tab By Java Code?

UI Components for JSF
Post Reply
askkuber123
Posts: 2
Joined: 16 May 2011, 19:17

16 May 2011, 19:45

Hello friends ,
Previously i was using Richfaces in my web application in which i was creating the tab By Java Code..Now i m creating same thing(Primefaces tab ) by same Program but m not able to generate the Tab .
My Java Class Is
package com.kuber.web.jsfbeans;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.component.html.HtmlPanelGroup;

import org.primefaces.component.tabview.Tab;
import org.primefaces.component.tabview.TabView;

@ManagedBean()
@SessionScoped
public class Tabtest {

// public String tabbing(){
//
// for(int i=0;i<3;i++){
// Tab dynamicTab = new Tab();
// dynamicTab.setTitle("hariom"+i);
// }
// return null;
//
// }
public static HtmlPanelGroup generateRichTab() {

TabView tabpanel = new TabView();
tabpanel.setDynamic(true);
int count = 0;
HtmlPanelGroup dynamicDataTableGroup = new HtmlPanelGroup();
for(int i=0;i<3;i++){
HtmlDataTable dataTable = new HtmlDataTable();
dataTable.setTitle("om"+i);
Tab dynamicTab = new Tab();

dynamicTab.setTitle("hariom"+i);
dynamicTab.setInView(true);
dynamicTab.setRendered(true);
dynamicTab.getChildren().add(dataTable);
tabpanel.getChildren().add(dynamicTab);
dynamicDataTableGroup.getChildren().add(tabpanel);
}
return dynamicDataTableGroup;
}

public HtmlPanelGroup getTabBasedOnFeatureName() {


HtmlPanelGroup tabpanel = new HtmlPanelGroup();

tabpanel = generateRichTab();
return tabpanel;
}

}

AND MY JSP PAGE CODE IS

<h:form id="detail">
<table align="center" border="0">
<tr>
<td class="crore" align="right" colspan="6">Cr-Crores, L-Lakhs,K-Thousands</td>

</tr>
<tr>
<td align="left">
<div style="border: 1px solid green; color: black; text-align: center;">
<p:tabView binding="#{tabtest.tabBasedOnFeatureName}" /> </div>
</td>
</tr>
</table>
</h:form></td>

This code is genrating three link rather than genrating tab.Plz help me where m wrong in my approach..
thanks

askkuber123
Posts: 2
Joined: 16 May 2011, 19:17

18 May 2011, 15:05

Issue resolve i added following CSS in JSP/XHTM file it work fine
<link type="text/css" rel="stylesheet" href="/AskKuber-Prime/javax.faces.resource/theme.css.xhtml?ln=primefaces-bluesky" />

<script type="text/javascript" src="/AskKuber-Prime/javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces&v=3.0-SNAPSHOT"></script>
<script type="text/javascript" src="/AskKuber-Prime/javax.faces.resource/core/core.js.xhtml?ln=primefaces&v=3.0-SNAPSHOT"></script>
<script type="text/javascript" src="/AskKuber-Prime/javax.faces.resource/ajaxstatus/ajaxstatus.js.xhtml?ln=primefaces&v=3.0-SNAPSHOT"></script>
<link type="text/css" rel="stylesheet" href="/AskKuber-Prime/javax.faces.resource/jquery/ui/jquery-ui.css.xhtml?ln=primefaces&v=3.0-SNAPSHOT" />
<script type="text/javascript" src="/AskKuber-Prime/javax.faces.resource/jquery/ui/jquery-ui.js.xhtml?ln=primefaces&v=3.0-SNAPSHOT"></script>
<script type="text/javascript" src="/AskKuber-Prime/javax.faces.resource/tabview/tabview.js.xhtml?ln=primefaces&v=3.0-SNAPSHOT"></script>

jainparv
Posts: 16
Joined: 18 May 2011, 11:32

19 May 2011, 04:03

This issue is resolved by adding these resources in page. Question which i still have, why prime faces did not these resources by itself when building the response.

<h:outputStylesheet library="primefaces" name="jquery/ui/jquery-ui.css" target="head" />
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h:outputScript library="primefaces" name="jquery/ui/jquery-ui.js" target="head" />
<h:outputScript library="primefaces" name="core/core.js" target="head" />
<h:outputScript library="primefaces" name="tabview/tabview.js" target="head" />

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests