0
www.Mysite.com/account/show_account_info.xhtml
www.Mysite.com/civil/steel/lrfd/column/simple_column.xhtml 
www.Mysite.com/index.xhtml   

Hi When my current page is index.xhtml with this command button I can go to Page simple_column.xhtml

<p:commandButton value="Simple Column" action="civil/steel/lrfd/column/simple_column"/>

and My problem is : when my current page is simple_column.xhtml and I want go to show_account_info.xhtm what is my action value?

<p:commandButton value="Show Account Info" action="?" />

Please Help me. with a lot of Thanks. Ali Farzadmehr

Farzadmehr
  • 71
  • 1
  • 1
  • 7
  • I saw your attempt to ask a question by editing my answer; don't do that. Add a comment to the answer to get clarification. If the component you're working with is the `` you should have that instead in your question instead of the command button you have here. The `action` attribute on the menu item doesn't take a navigation url; use the `url` attribute for that instead – kolossus Aug 09 '14 at 21:13

1 Answers1

1

Seeing as you're navigating completely out of the current directory, you can use

    facesContext.externalContext.applicationContextPath //JSF2.2

    facesContext.externalContext.requestContextPath //JSF2.1

At the end, you'll have (depending on your version of JSF)

    <p:commandButton value="Show Account Info" action="#{facesContext.externalContext.requestContextPath}/account/show_account_info" />

As a matter of better use of JSF components, you should be using a <p:button/> or <h:button/>, if all you need to do is navigate. It comes with less overhead and provides support for bookmarkability of your URLs

Related reading:

Community
  • 1
  • 1
kolossus
  • 20,559
  • 3
  • 52
  • 104