我在我的项目中使用primefaces 3.0,我已经在testing1.xhtml中实现了图表,但该页面内容需要显示在main.xhtml上,但图表不是第一次呈现。仅提供刷新后的图表渲染,但它不应该像这样..我已附加模型片段供您参考..请帮助我解决此问题..
testing1.xhtml
<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:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:portlet="http://java.sun.com/portlet"
xmlns:c="http://java.sun.com/jstl/core">
<h:form id="testForm">
<p:lineChart id="testChart" value="#{testBean.chart}"
style="float:left; margin-top:150px; border:0px; margin-left:0px; padding:0px; height:140px; width:230px; "/>
<h:form>
</ui:composition>
我从main.xhtml调用此页面
main.xhtml
<body onLoad="loadData();" >
<h:panelGrid style="height:33px;"/>
<h:form style="margin:0px; padding:0px;">
<p:remoteCommand name="loadData" action="#{testBean.chartLoad}" update="testChart" />
<p:panel style="height:auto; width:238px;" id="testPanel" header="Testing" closable="false" toggleable="true">
<ui:include src="testing1.xhtml"/>
</p:panel>
提前感谢..
答案 0 :(得分:2)
看起来看起来是一个嵌套的form
问题......
尝试从内页中移除<h:form id="testForm">
,导致其已被外页的form
标记包围...
答案 1 :(得分:1)
只需在页面中添加这些行。加载js / css
时出错System.out.print("Input Equation : ");
n = s.next() + s.nextLine();
n = n.replaceAll("\\s+", "");
char[] nans = n.toCharArray();
c = 0;
for (int i = 0; i < n.length(); i++)
if (nans[i] == '+' || nans[i] == '-' || nans[i] == '/' || nans[i] == '*')
c++;
char[] op = new char[c];
int[] num = new int[c + 1];
c = 0;
for (int i = 0; i < n.length(); i++) {
if (nans[i] == '+' || nans[i] == '-' || nans[i] == '/' || nans[i] == '*') {
op[c] = nans[i];
c++;
}
}
c = 0;
for (int i = 0; i < n.length(); i++) {
if (nans[i] == '1' || nans[i] == '2' || nans[i] == '3' || nans[i] == '4' || nans[i] == '5'
|| nans[i] == '6' || nans[i] == '7' || nans[i] == '8' || nans[i] == '9' || nans[i] == '0')
nus = nus + nans[i];
else if (nans[i] == '+' || nans[i] == '-' || nans[i] == '/' || nans[i] == '*') {
num[c] = Integer.parseInt(nus);
nus = "";
c++;
}
if (i == n.length() - 1){
num[c] = Integer.parseInt(nus);
}
}
for (int i = 0; i < c; i++) {
if (op[i] == '+') {
result = result + num[i] + num[i + 1];
num[i + 1] = 0;
}
else if (op[i] == '-') {
result = result + num[i] - num[i + 1];
num[i + 1] = 0;
}
else if (op[i] == '/') {
result = (result + num[i]) / num[i + 1];
num[i + 1] = 0;
}
else if (op[i] == '*') {
result = (result + num[i]) * num[i + 1];
num[i + 1] = 0;
}
}
System.out.print(" = "+ result);
答案 2 :(得分:0)
从testing1.xhtml中删除标记。由于您的主页面包含h:表单标记,因此您无需在您的ui:include中添加其他标记。
即使它不起作用,然后添加ID并添加update =&#34;:&lt; yourGivenFormID&gt;&#34;在p:lineChart
答案 3 :(得分:0)
删除testing1.xhtml中的表单标记
在tests1.xhtml页面的head部分添加以下内容:
<h:head>
<link rel="stylesheet" href="/javax.faces.resource/charts/charts.css.jsf?ln=primefaces"/>
......
</h:head>