2

I would like to use an ajax tag based on which page is currently shown. I am using JSF 2 and Primeface 3.5

If (currentPage = pageOne.xhtml){ do something } else { do something different }

My Source is looking like that:

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:m="http://java.sun.com/jsf/composite/components/mmnet"
    xmlns:c="http://java.sun.com/jsp/jstl/core">

    <h:form id="customerSearchForm">
....
...

<c:if test=" ">
<p:ajax event="rowSelect" oncomplete="initInfoPage();"/>
</c:if>

....
...

what is the correct expression inside ?

test= ...

Is there a way to get which page is currently shown?

Regards LStrike

LStrike
  • 1,598
  • 4
  • 26
  • 58
  • 2
    I used #{view.viewId} to get current page. Look at this [EXAMPLE](http://stackoverflow.com/a/3255120/1692632) – Darka Apr 24 '13 at 09:35
  • 1
    #{view.viewId == 'pageOne.xhtm'} please try this i think its working – hayat Apr 24 '13 at 11:26

1 Answers1

3

You can get the ID of the current view via #{view.viewID}. This is basically the physical path of the template client file, relative to the webcontent root.

So, this should do, provided that pageOne.xhtml is directly in the root of the webcontent.

<c:if test="#{view.viewId == '/pageOne.xhtml'}">

Note that it starts with a leading slash and does not contain the JSF mapping, if any.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555