Primeface datatable.filter()和url参数 [英] Primeface datatable.filter() and url parameter

查看:143
本文介绍了Primeface datatable.filter()和url参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.xhtml模型,其中包含一个表面数据表。
我用这样的URL调用页面:
http:// localhost:8080 / myproject / mypage.jsf?Id = 51& startDate = 04-05-2015& name = whatever



URL参数用于检索在datatable中显示的内容,因此可以让我过滤内容。
我使用URL参数,因为当我在另一个datable中选择一行时显示此页面,所以我必须在烘焙bean上手动重定向到此页面。



然而,每次我使用诸如排序或分页之类的一个表面功能,似乎对支持bean做了一个ajax调用,但是没有参数,所以每个对象都被显示,而不是显示对象的过滤列表。



因此,我如何强制使用这些参数?或者我怎么能把它们放在一个表面的范围(他们是@ManagedProperty在支持bean上)

解决方案

最好最简单的方法是使用 OmniFaces实用程序库,更具体地说,是使用它们的 < o:form>



文件:


< o:form> 是一个扩展标准< h:form> ,并提供了一种在追溯后


$ b $之后,在请求网址中查看或请求参数的方法b

...



您可以使用与< h:form> 相同的方式,您只需将 h:更改为 o:


所以,将< h:form> p>

 < o:form includeRequestParams =true> 

 < o:form useRequestURI =true> 



另请参见:




i have a .xhtml model with a primeface datatable in it. I call the page with an URL like this: http://localhost:8080/myproject/mypage.jsf?Id=51&startDate=04-05-2015&name=whatever

The URL parameters are used to retrieve what will be displayed in the datatable, so it allow me to filter the content. I used URL parameter because this page is displayed when i select a row in another datable so i have to make a manual redirect to this page on the baking bean.

However everytime i use one of primeface functionality like sorting or pagination primeface seems to do an ajax call to the backing bean but WITHOUT the parameters, so every object are displayed instead of a filtered list of Objects.

Therefore how can i force primefaces to use these parameters? Or how can i passe them to primeface scope (they are @ManagedProperty on the backing bean)

解决方案

The best and easiest way is to use the OmniFaces utility library and more specifically their <o:form>.

From the documentation:

The <o:form> is a component that extends the standard <h:form> and provides a way to keep view or request parameters in the request URL after a post-back

...

You can use it the same way as <h:form>, you only need to change h: to o:.

So, replace your <h:form> by either

<o:form includeRequestParams="true">

or

<o:form useRequestURI="true">

See also:

这篇关于Primeface datatable.filter()和url参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆