0

I have a JSF web application using SPRING3 + JSF2 (mojarra 2.1.12) and I have the following problem: I want to redirect my web page and I want to pass a parameter.

First, I used a button and it worked properly but then I decided to change it to a commandlink. The same code doesn't work and I don't know why.

The first button code was as follows:

<sec:authorize ifAnyGranted="ROLE_USER">
    <p:button id="miCuenta" value="miCuenta" title="miCuenta" outcome="/views/usuarios/visorUsuario">
        <f:param name="itemId" value="#{userContext.user.pk}" />  
    </p:button>  
</sec:authorize>

And I changed it to this:

<sec:authorize ifAnyGranted="ROLE_USER">
    <h:commandLink id="miCuenta" value="miCuenta" action="/views/usuarios/Usuarios?faces-redirect=true">
        <f:param name="itemId" value="#{userContext.user.pk}" />  
    </h:commandLink>
</sec:authorize>

I don't know what the problem is in the second approach. Anyone?

Thanks!!

2 Answers2

1

As you just want to redirect to another view and you dont want to do any action, dont use h:commandLink. Use h:link instead:

<h:link id="miCuenta" value="miCuenta" outcome="/views/usuarios/Usuarios">
    <f:param name="itemId" value="#{userContext.user.pk}" />  
</h:link>
user1983983
  • 4,793
  • 2
  • 15
  • 24
  • Thanks! It works, but I put "outcome" attribute instead "action". With action it doesnt work. Thanks for your help! – user3244414 Feb 07 '14 at 11:41
0

You can to pass parameter in actionListener

    <sec:authorize ifAnyGranted="ROLE_USER">
        <h:commandLink id="miCuenta" value="miCuenta" 
action="/views/usuarios/Usuarios?faces-redirect=true" actionListener="#{bean.listener(userContext.user.pk)}>
        </h:commandLink>
    </sec:authorize>

Bye

Michel Foucault
  • 1,724
  • 3
  • 25
  • 48