0

i have a simple menu on jsf:

 <h:panelGroup id="panelMenu">
    <h:form id="menuForm">
    <ul class="nav nav-tabs" id="myTab">
        <li class="active"><h:outputLink value="contenido/Agrupaciones.xhtml"><h:outputText value="Agrupaciones" /></h:outputLink></li>
        <li><h:outputLink value="contenido/Usuarios.xhtml" ><h:outputText value="Usuarios" /></h:outputLink></li>
        <li><h:outputLink value="contenido/Modulos.xhtml" ><h:outputText value="Modulos" /></h:outputLink></li>
        <li><h:outputLink value="contenido/Roles.xhtml" ><h:outputText value="Roles" /></h:outputLink></li>
    </ul>
    </h:form>
    </h:panelGroup>

it works ok, but when im on one of my pages.. let say "users.xhtml" and from that page i go to another like "details" <h:outputLink value="../contenido/detalleUsuario.xhtml">, when i click again in my principal menu to go back to "users" the url looks like this:

contenido/contenido/Usuarios.xhtml when it should be contenido/Users.xhtml. so i get a "page not found error".

4

1 回答 1

3

Use <h:link> instead of <h:outputLink>. The <h:link> treats the path as navigation case outcome and will always resolve it relative to the context path. So you can safely start the outcome with / without worrying about the context path.

<li class="active"><h:link value="Agrupaciones" outcome="/contenido/Agrupaciones.xhtml" /></li>
<li><h:link value="Usuarios" outcome="/contenido/Usuarios.xhtml" /></li>
<li><h:link value="Modulos" outcome="/contenido/Modulos.xhtml" /></li>
<li><h:link value="Roles" outcome="/contenido/Roles.xhtml" /></li>

Note that those links doesn't require a form at all. So the whole <h:form> as you've in your code is completely superfluous.

于 2013-02-04T15:28:36.173 回答