0

Let's say that n-pages of application contains a link to page A. But that link actually placed in the template part of that n-pages.

Note that the page A also contains that template part. So that link is present in the page A too.

The idea is to hide the link to page A when the transition was happened from any other n-pages to page A. I.e. when we are on any of the n-pages then that link is present but is we are an the page A then that link is hidden.

How can I achieve that with a little effort?

rozerro
  • 5,787
  • 9
  • 46
  • 94

1 Answers1

1

You can use rendered attribute and check viewId in it. In yor case:

<h:commandLink rendered="#{view.viewId ne '/pageA.xhtml'}"/>

In this exmaple h:commandLink will be rendered in all pages except pageA.xhtml

Also you can pass parameters in your template by using ui:param tag. So you render link in template only if parameter true:

<!-- template.xhtml: -->
<h:commandLink rendered="#{renderLinkParam}"/>...<ui:insert name="myPage"/>

And use this code on your page to pass parameter:

<ui:composition template="template.xhtml">
        <ui:param name="renderLinkParam"  value="#{true}" />
        <ui:define name="myPage">...
        </ui:define>
</ui:composition>
Artem
  • 371
  • 4
  • 11