JSF-Javascript调用Primefaces组件

JSF Javascript calls Primefaces componants

本文关键字:组件 Primefaces 调用 JSF-Javascript      更新时间:2023-09-26

hi我想从java脚本函数定期调用backbean我想刷新页面的一个面板,而不是整个页面这是我用脚本写的

$('#submitbutton').click();

<h:commandButton id="submitbutton" immediate="true" value="" styleClass="ui-day" style="border:0;display : none;" 
                            action="#{liveGraphBean.plotInterval1('daily')}" >  

而不是刷新,我只想刷新页面的面板

<p:panel id="dailyGraphPanel">
                    <div id="chartdiv" style="width: 100%; height: 400px;"></div>
                </p:panel>

那么我该怎么做呢感谢

您可以使用Primeface Poll标签

http://www.primefaces.org/showcase/ui/ajax/poll.xhtml

http://www.primefaces.org/showcase/ui/ajax/remoteCommand.xhtml

<h:commandButton id="submitbutton" immediate="true" value="Submit" styleClass="ui-day" style="border:0;display : none;" action="#{liveGraphBean.plotInterval1('daily')}">
    <f:ajax render="dailyGraphPanel" execute="@this"/>
</h:commandButton>

<p:commandButton id="submitbutton" immediate="true" value="Submit" styleClass="ui-day" style="border:0;display : none;" action="#{liveGraphBean.plotInterval1('daily')}" update="dailyGraphPanel" process="@this" />
<h:panelGroup id="dailyGraphPanel">
  <div id="chartdiv" style="width: 100%; height: 400px;"></div>
</h:panelGroup>

我还建议您使用http://www.primefaces.org/showcase/ui/ajax/poll.xhtml

IMHO,将您的图表组件#chartdiv刷新与面板刷新分组会更简单、更干净。

然而,一个快速的解决方案,只需很少的修改,也许可以满足你没有解释的限制,你可以从切换

<h:commandButton id="submitbutton" immediate="true" value="" styleClass="ui-day" style="border:0;display : none;" action="#{liveGraphBean.plotInterval1('daily')}" >

<p:commandButton id="submitbutton" immediate="true" value="" styleClass="ui-day" style="border:0;display : none;" action="#{liveGraphBean.plotInterval1('daily')}" update="dailyGraphPanel">

根据p:commandButton和p:panel的相对位置,pour可能需要调整要更新的组件的路径,或者只需要使用一个方便的素数函数,p:component

<p:commandButton id="submitbutton" immediate="true" value="" styleClass="ui-day" style="border:0;display : none;" action="#{liveGraphBean.plotInterval1('daily')}" update="#{p:component}">

我在h:commandButton文档中看不到更新属性http://docs.oracle.com/javaee/6/javaserverfaces/2.0/docs/pdldocs/facelets/但你会在p:commandButton中找到它http://www.primefaces.org/docs/vdl/3.5/primefaces-p/commandButton.html

您应该阅读PrimeFaces文档中的"部分渲染"部分,以获得有关其工作原理的更详细解释(PrimeFace优秀用户指南第498页第4.1节http://www.primefaces.org/docs/guide/primefaces_user_guide_5_0.pdf)。