如何创建调用操作且不保留 cid 的链接或按钮?
这是一个我无法实现的简单用例:我想创建一个调用服务器方法(操作)的链接或按钮,并将重定向到一个页面而不保留 cid
参数。
我正在使用 JSF2、JBoss 7 和 Seam 3。
以下是我尝试过但没有成功的两种方法。
第一个,h:commandLink
<h:commandLink action="pages/home.xhtml"
actionListener="#{identity.logout()}"
value="#{bundles.layout.logout}" />
这里,identity.logout()
被调用,但是随后,浏览器被重定向到页面/home.xhtml?cid=1
,所以如果我再次登录,就会出错
org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped
。
第二个,h:link
<h:link outcome="/pages/home.xhtml" value="#{bundles.layout.logout}">
<f:ajax event="click" listener="#{identity.logout()}" />
</h:link>
这里,我在生成的超链接中没有任何cid
,而是方法identity。 logout() 未调用...
有人有想法吗?
Here is a simple usecase which I don't manage to realise : I want to create a link or button which calls a server method (action) and will redirect to a page without preserving the cid
parameter.
I'm using JSF2, JBoss 7 and Seam 3.
Here are two methods I tried without success.
First one, the h:commandLink
<h:commandLink action="pages/home.xhtml"
actionListener="#{identity.logout()}"
value="#{bundles.layout.logout}" />
Here, identity.logout()
is called, but then, the browser is redirected to pages/home.xhtml?cid=1
, so if I login again, I will have an
org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped
error.
Second one, the h:link
<h:link outcome="/pages/home.xhtml" value="#{bundles.layout.logout}">
<f:ajax event="click" listener="#{identity.logout()}" />
</h:link>
Here, I don't have any cid
in the generated hyperlink, but the method identity.logout()
is not called...
Does someone have an idea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
h:commandLink
并从identity.logout()
调用conversation.end()
应该可以。您没有包含identity.logout()
的代码,但我怀疑您没有结束对话。通过结束对话,您可以将其从长时间运行更改为瞬态,此时不应传播它。Using
h:commandLink
and callingconversation.end()
fromidentity.logout()
should work. You didn't include the code foridentity.logout()
, but I suspect you're not ending the conversation. By ending the conversation, you change it from long-running to transient, at which point it should not be propagated.