Jsf 通过Java和PrimeFaces生成直方图
我无法通过java素数面生成直方图。我有这个xhtml文件Jsf 通过Java和PrimeFaces生成直方图,jsf,primefaces,histogram,Jsf,Primefaces,Histogram,我无法通过java素数面生成直方图。我有这个xhtml文件 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/f
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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"
xmlns:p="http://primefaces.org/ui">
<ui:define name="content">
<h1 class="title ui-widget-header ui-corner-all">Charts - Bar</h1>
<div class="entry">
<p>BarChart displays a CartesianChartModel.</p>
<p:barChart id="basic" value="#{ChartBean.categoryModel}" legendPosition="ne"
title="Basic Bar Chart" min="0" max="200" style="height:300px"/>
</div>
</ui:define>
</html>
另外,第一个xhtml中的ui.xhtml
模板如下所示
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
<h:head>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
<title>PrimeFaces - ShowCase</title>
<!-- <link rel="shortcut icon" type="image/png" href="#{request.contextPath}/images/favicon.png" /> -->
</f:facet>
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/default.css" />
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/syntaxhighlighter/syntaxhighlighter.css" />
<ui:insert name="head"></ui:insert>
<script type="text/javascript">
$(function() {$('.sidebar a').hover(function() {$(this).toggleClass('ui-state-hover');})});
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12200033-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</h:head>
<h:body>
<div id="header" class="ui-widget ui-widget-header">
<div id="logo">
<img src="#{request.contextPath}/images/logo.png" alt="Logo"/>
</div>
</div>
<div id="page" class="ui-widget">
<div id="sidebar" class="ui-widget-content ui-corner-bottom ui-helper-clearfix ui-shadow">
<h3 class="ui-widget ui-widget-header ui-corner-all submenu-title ui-state-highlight">Charts</h3>
<div class="submenu-content">
<table>
<tr>
<td style="width:33%">
<ul>
<li><a href="#{request.contextPath}/ui/barChart.jsf">Bar</a></li>
</ul>
</td>
<td style="width:33%">
<ul>
</ul>
</td>
</tr>
</table>
</div>
</div>
<div id="content">
<div class="post">
<ui:insert name="content">...</ui:insert>
</div>
</div>
<div style="clear: both;"></div>
</div>
<ui:insert name="footer">
<div id="footer" class="ui-widget ui-widget-header ui-corner-all">
<p class="copyright">Running #{build.primefacesVersion} on #{build.jsfVersion}</p>
</div>
</ui:insert>
<ui:insert name="status">
<p:ajaxStatus style="width:64px;height:64px;position:fixed;right:5px;bottom:5px">
<f:facet name="start">
<p:graphicImage value="/images/loading.gif" />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
</ui:insert>
<ui:insert name="highlight">
<script language="javascript" src="#{request.contextPath}/syntaxhighlighter/scripts/sh.js"></script>
<script language="javascript">
SyntaxHighlighter.all();
</script>
</ui:insert>
</h:body>
</f:view>
</html>
PrimeFaces-展示
$(function(){$('.sidebar a').hover(function(){$(this.toggleClass('ui-state-hover');}));
var _gaq=_gaq | |[];
_gaq.推送([''u设置帐户','UA-12200033-3']);
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://ssl' : 'http://www“)+”.google analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();
图表
...
在#{build.jsfVersion}上运行#{build.primefacesVersion}
SyntaxHighlighter.all();
现在的问题是,当我运行上面的文件时,什么都没有发生,也看不到任何显示。我是新手,因此无法指出我在哪里出错。有人能帮我吗
更新:当我在xhtml文件上运行时,我甚至看不到控制台上打印的
内部构造函数
,控制台写在ChartBean()
构造函数上,当然你看不到构造函数的输出,因为它实际上从未使用提供的代码调用过。要在xhtml页面中访问bean,必须使用@Named或@ManagedBean注释。当您这样做时,当您在xhtml中引用bean时(基于其范围),将创建bean的实例
然后您可以在xhtml中使用它,如下所示:
#{chartBean.categoryModel}
@ManagedBean
@ViewScoped
public class ChartBean implements Serializable {
...
}
#{chartBean.categoryModel}