如何区分jsf操作或直接url链接调用的页面

发布于 2024-09-27 01:01:44 字数 624 浏览 9 评论 0原文

我有一种情况,我有一个带有列表的会话bean,这个列表我在html数据表中显示。当用户从浏览器或普通 href 访问 url 时,我必须显示所有记录。还可以搜索数据,我必须在其中显示过滤后的列表。现在,在用户进行搜索后,列表包含过滤后的记录,执行此操作后,他将页面留给其他页面,现在如果用户点击网址或使用菜单返回此页面,因为我有此列表在会话 bean 中,我仍然有过滤列表。

由于 JSF 1.1 或 2.0 preRenderView 概念中没有默认操作,因此很难清除列表并再次获取未过滤的数据(所有结果)。即使 getList() 方法中的技巧也无法完成任务。

我计划使用阶段监听器,因为当用户通过浏览器中的 href 或 url 点击到达页面时,调用应用程序阶段不会发生。我可以在会话 bean 中切换布尔变量,在 getList() 中我可以执行一些技巧来检查它是 url、href 命中还是通过命令按钮。

希望我已经说清楚了。简而言之,我必须在我的 bean 中确定请求是否直接来自 href、浏览器或操作。如果搜索操作过滤数据表的记录,如果不保留列表缓存,并且只要不进行搜索就继续显示它。

请指导我是否以正确的方式做事或想太多,或者是否可以以更有效的方式完成。

提前致谢。 好吧平台是weblogic门户10.3中的jsf 1.1......

I have a situation, I have a session bean with list, this list I show in html data table. When the user hits the url from browser or normal href, I have to show all records. There is provision to search for the data also, where I have to show the filtered list. Now after a user has made the search, the list contains filtered records and after doing this he leaves the page to some other, and now if the user hits the url or uses the menu to come back to this page, since I have this list in session bean, I still have the filtered list.

Since there is no default action in JSF 1.1 or 2.0 preRenderView concept, its difficult to clear the list and get non filtered data(all results) again. Even tricks in getList() method fail to accomplish the task.

I have planned to use phase listener, as when a user reaches a page via href or url hit in browser, invoke application phase does not happen. I can toggle boolean variable in my session bean and in getList() I can perform some trick to check it was url,href hit or by command button.

Hope I have made myself clear. In short I have to identify in my bean whether the request came directly from href,browser or an action. If search action filter records for data table if not keep list cache and keep showing it as long as search is not made.

Just guide me whether I am doing things in right way or thinking too much or can it be done in much more efficient way.

Thanks in advance.
Well platform is jsf 1.1 in weblogic portal 10.3 .....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪心 2024-10-04 01:01:44

JSF 1.x 操作默认使用 POST 方法。直接链接/书签/等本质上是 GET 方法。由于没有 ResponseStateManager#isPostback()FacesContext#isPostback() 在 JSF 1.1 中,您必须自己确定请求方法:

HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
boolean postback = "POST".equalsIgnoreCase(request.getMethod());

或者检查请求中的某个参数参数图,但我无法从头顶上分辨出您要检查哪一个。你必须自己确定。

boolean postback = facesContext.getExternalContext().getRequestParameterMap().containsKey(SOME_KEY);

如果 postbacktrue,则调用 JSF 操作。

JSF 1.x actions use by default POST method. Direct links/bookmarks/etc are by nature GET method. Since there's no ResponseStateManager#isPostback() or FacesContext#isPostback() in JSF 1.1, you have to determine the request method yourself:

HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
boolean postback = "POST".equalsIgnoreCase(request.getMethod());

Or check for a certain parameter in the request parameter map, but I can't tell from top of head which one you'd like to check. You've to determine it yourself.

boolean postback = facesContext.getExternalContext().getRequestParameterMap().containsKey(SOME_KEY);

If postback is true, then a JSF action is been invoked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文