如何使用 JSF
下午好,
我有一个搜索页面,它使用 ajax 来呈现多个数据表,而无需刷新页面。
我必须为每个表调用一个方法作为侦听器。
下面是第一个工作正常的数据表的片段。
要渲染第二个数据表,我需要调用方法 #{evalController.prepareList}
作为 ajax 的侦听器。问题是 "Listener" 属性不会采用多个方法。
所以剩下的方法是多次调用,并且每次使用不同的监听器,这是行不通的。有办法实现这一点吗?
如果不是,我是否应该在托管 Bean 中创建一个方法来调用我需要的所有方法并将其用作一个侦听器?
预先感谢您的帮助。
<h:form id="searchform">
<h:panelGrid columns="3" >
<p:inputText value="#{ddnController.patientID}" id="pidinput" maxlength="7" size="7">
<f:ajax execute="@this" event="keyup" render="searchbutton ddntable" listener="#{ddnController.prepareList}"/>
</p:inputText>
<h:commandButton image="#{resource['images/search.png']}" id="searchbutton" value="#{bundle.Search}"
action="submit" actionListener="#{ddnController.prepareList}"
disabled="#{empty ddnController.patientID or ddnController.patientID.equals('0')}"/>
<p:panel><h:outputText value="Saisir 0 pour avoir tous les Patients" style="font-style: italic;"/></p:panel>
</h:panelGrid>
<p:dataTable id="ddntable" value="#{ddnController.items}" var="ddn" rendered="#{!empty ddnController.items}" paginator="true" >....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web
技术交流群。
下午好,
我有一个搜索页面,它使用 ajax 来呈现多个数据表,而无需刷新页面。 我必须为每个表调用一个方法作为侦听器。 下面是第一个工作正常的数据表的片段。
要渲染第二个数据表,我需要调用方法 #{evalController.prepareList}
作为 ajax 的侦听器。问题是
所以剩下的方法是多次调用
<h:form id="searchform">
<h:panelGrid columns="3" >
<p:inputText value="#{ddnController.patientID}" id="pidinput" maxlength="7" size="7">
<f:ajax execute="@this" event="keyup" render="searchbutton ddntable" listener="#{ddnController.prepareList}"/>
</p:inputText>
<h:commandButton image="#{resource['images/search.png']}" id="searchbutton" value="#{bundle.Search}"
action="submit" actionListener="#{ddnController.prepareList}"
disabled="#{empty ddnController.patientID or ddnController.patientID.equals('0')}"/>
<p:panel><h:outputText value="Saisir 0 pour avoir tous les Patients" style="font-style: italic;"/></p:panel>
</h:panelGrid>
<p:dataTable id="ddntable" value="#{ddnController.items}" var="ddn" rendered="#{!empty ddnController.items}" paginator="true" >....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我仍然不确定为什么复合方法在调用时没有效果。可能在正确的阶段之前或之后没有调用它(我稍后将对其进行分析)。不管怎样,我找到了一个具有两条边的解决方案(它解决了我的问题,但让我牺牲了ajax的使用):
所以而不是调用- 来自每个托管 bean - 我用作侦听器的方法 (prepareList()):(
顺便说一句,此方法将数据模型设置为 NULL 来刷新它,这就是我的数据表刷新的方式)。
在命令按钮内,我嵌套了属性操作侦听器:
我希望.
可以嵌套在如果有人有一个允许使用属性操作侦听器和ajax以避免使用按钮提交表单的解决方案,欢迎他/她。我将接受他/她的回答。
I am still not sure why the composite method do not have effect when called. Probably it is not called during before or after the right phase (I'll be profiling it later). Anyway, I found a solution with two edges (it is solving my problem but makes me sacrifice the use of ajax) :
So Instead of calling - from each managed bean - the method (prepareList()) which I use as listener:
(by the way, this method sets the datamodel to
NULL
to refresh it, and that is how my datatables get refreshed).Inside the command button I nested property action listener:
I wish
<f:PropertyActionListener />
could be nested inside<h:ajax/>.
If somebody has a solution that allows to use property action listener and ajax to avoid submitting the form with a button, s/he is welcome. I'll make then his/her answer as accepted.