JSF 中链接和 ajax 重定向中的 URL 片段
我发现JSF 2.0中ajax操作调用的方法可以返回导航案例,然后可以重定向页面。
例如。当我在页面 index.xhtml
上并且我的 ajax 调用返回导航案例 detail
时,页面将被重定向。那太好了。
<h:commandLink value="The link" action="#{bean.someAction}" >
<f:ajax />
</h:commandLink>
但现在我只想在当前页面中进行部分重定向,因此我想使用 URL 片段。所需的最终 URL 类似于 index.xhtml#someComponentId
。我尝试通过在导航案例后面附加 #fragment
部分来实现此目的,但它不起作用。
请问有什么方法可以让ajax和普通重定向能够使用URL片段吗?感谢您的回复。
I found out that methods called by ajax actions in JSF 2.0 can return navigation case and then the page can be redirected.
Eg. when I am on page index.xhtml
and my ajax call return navigation case detail
then the page is redirected. That is great.
<h:commandLink value="The link" action="#{bean.someAction}" >
<f:ajax />
</h:commandLink>
But now I would like to do only partial redirect in the current page, so I would like to use URL fragment. The desired final URL looks like this index.xhtml#someComponentId
. I have tried to do it with appending of #fragment
part behind the navigation case but it doesn't work.
Is there any way how to make ajax and normal redirects able to use URL fragments, please? Thanks for your responses.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以整天在代码中指定片段,但无法解析这些片段。您将需要对页面进行更多控制。我曾短暂使用过 jQuery hashchange 插件。 http://benalman.com/projects/jquery-hashchange-plugin/。还有一个名为 BBQ 的插件,它位于同一页面上,并且可以执行更多操作。
然后你需要指定一个回调(我给你的那个网站上有教程)来指导页面对该特定哈希执行什么操作。
查看示例。
http://benalman.com/code/projects/jquery-bbq/ example/fragment-basic/
我知道这个答案有点模糊,但我相信它会为您指明如何解决此问题的正确方向。
You can specify fragments all day in your code but you have nothing to parse those fragments. Your going to need more control over your page. I have used the jQuery hashchange plugin briefly. http://benalman.com/projects/jquery-hashchange-plugin/. There is also a plugin called BBQ, which is on the same page and does more.
Your then going to need to specify a callback(there are tutorials on that site I gave you) to direct the page what to do on that particular hash.
Check out the examples.
http://benalman.com/code/projects/jquery-bbq/examples/fragment-basic/
I know this answer is kind of vague but I believe it will point you in the correct direction on how to solve this issue.