0

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 ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Anthony O.
  • 22,041
  • 18
  • 107
  • 163

1 Answers1

0

Using h:commandLink and calling conversation.end() from identity.logout() should work. You didn't include the code for identity.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.

Brian
  • 477
  • 3
  • 5
  • The code of `identity.logout()` is [Seam's 3 security module](https://github.com/seam/security/blob/release/3.1.0.Final/impl/src/main/java/org/jboss/seam/security/IdentityImpl.java#L420). It doesn't call `conversation.end()` but `session.invalidate()`. Moreover, I've created a `PostLoggedOutEvent` observer which calls `conversation.end()`, but nothing's better : it stills redirect to `pages/home.xhtml?cid=X` where `X` is the current conversation id before logout. – Anthony O. Jan 12 '12 at 09:16