0 Replies Latest reply on Jan 11, 2012 4:53 AM by aogier

    How to create a link or button which calls an action and doesn't preserve cid?

    aogier

      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 {noformat}cid{noformat} parameter.

       

       

      I'm using JSF2, JBoss 7 and Seam 3.

       

       

      Here are two methods I tried without success.

       

       

      *First one, the {noformat}h:commandLink{noformat}*

       

       

      {code:xml}<h:commandLink action="pages/home.xhtml"

        actionListener="#{identity.logout()}"

        value="#{bundles.layout.logout}" />

      {code}

       

      Here, {noformat}identity.logout(){noformat} is called, but then, the browser is redirected to {noformat}pages/home.xhtml?cid=1{noformat}, so if I login again, I will have an

       

      {noformat}org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped{noformat}

       

       

      error.

       

       

      *Second one, the {noformat}h:link{noformat}*

       

       

      {code:xml}<h:link outcome="/pages/home.xhtml" value="#{bundles.layout.logout}">

        <f:ajax event="click" listener="#{identity.logout()}" />

      </h:link>

      {code}

       

      Here, I don't have any {noformat}cid{noformat} in the generated hyperlink, but the method {noformat}identity.logout(){noformat} is not called...

       

       

      Does someone have an idea ?

       

      (I've posted that question on [stackoverflow|http://stackoverflow.com/questions/8807294/how-to-create-a-link-or-button-which-calls-an-action-and-doesnt-preserve-cid], but perhaps this is a better place to get some help?)