Search code examples
jsfjbossseam

Init method is not filled in even with parameters


I have lost a few hours trying to figure out why I can not retrieve the parameters of my link. Following this question, I did my link with passing parameters. My problem is relatively easy, if I can get the parameters in the popup that opens when the user clicks the link. Except that I can not get them.

My class has a method annotated with @Create that every time the object is initialized it executes this method.

The only way I can get the idsess_ parameter is in the URL, but I can not pass any parameters I want the URL.

In short, by clicking on my <a:commandLink> wish the <f:param>'s were passed to the bean in a matter and the same to process according to these parameters.

Edit: changed my code and created my own action. In this case I was reusing an action of another view. I recreated my action and used the method described in the answer that was accepted


Solution

  • Not sure what your <a:commandLink/> component is? (Im assumed you re-mapped a4j:commandLink somehow?)

    I think the problem you are having is that the @RequestParameter variables are only populated when the page first renders, when you click the commandLink you are performing a postback so the values are lost.

    You should try doing a redirect instead (ie. using <s:link> with <f:param> rather than commandLink) or you can pass the parameters using pages.xml to bind the request params, using this markup:

    <page view-id="/your-page.xhtml">
            <param name="pId" value="#{bean.variable}" required="false" />
            <action execute="#{bean.action}" />
    </page>