Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
17. May 2008, 02:39 CET | Link

Hello,

I would like to know if there is any way to know what the current view-id is from a web page.

I'm using <a:include> tags to add common functionality to several web pages. However in some cases one element of the include page fragment will be different in one page from all the other pages where the page fragment is used.

That case could be handled with some kind of EL expression which would return what the current (parent) view-id is.

Thanks.

4 Replies:
17. May 2008, 11:14 CET | Link

This will tell you the URL if that helps...

FacesContext.getCurrentInstance().getExternalContext().getRequestServletPath()
Rating:  * * *
17. May 2008, 13:35 CET | Link

And this will tell the view:

FacesContext.getCurrentInstance().getViewRoot().getViewId();

but I don't know how to do that from EL (other than putting that java code in an EL function or in a getter on some component).

Rating:  * * * *
17. May 2008, 14:14 CET | Link

There's a seam manager component that wraps the current faces context, so you can just do:

#{facesContext.viewRoot.viewId}

in EL.

Rating:  * * * * *
18. May 2008, 23:11 CET | Link

or

#{facesContext.viewRoot.viewId}

or

#{view.viewId}