如何区分jsf操作或直接url链接调用的页面
我有一种情况,我有一个带有列表的会话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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JSF 1.x 操作默认使用
POST
方法。直接链接/书签/等本质上是GET
方法。由于没有ResponseStateManager#isPostback()
或FacesContext#isPostback()
在 JSF 1.1 中,您必须自己确定请求方法:或者检查请求中的某个参数参数图,但我无法从头顶上分辨出您要检查哪一个。你必须自己确定。
如果
postback
为true
,则调用 JSF 操作。JSF 1.x actions use by default
POST
method. Direct links/bookmarks/etc are by natureGET
method. Since there's noResponseStateManager#isPostback()
orFacesContext#isPostback()
in JSF 1.1, you have to determine the request method yourself: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.
If
postback
istrue
, then a JSF action is been invoked.