0

I have a JSF 2.0 app where each page is stored in a cms_page table in the database. That table has the PK column cms_page_id and a URL column (which holds the SEO friendly URL).

When I display a page there is a link called About Us, which has the URL "/com/aboutus.html" This appears in my XHTML file as: #{cmsPage.cmsPageUrlName}/>

Which renders <a href="/com/aboutus.html">About Us</a>

As far as I know h:outputLink cannot be used to fire any methods in the backing bean. I can't use h:commandLink, as this will not show the "/com/aboutus.html" URL when you hover over the link. I can't figure out how to fire a backing bean method to navigate to the next page. The about us link would really be going to /faces/pages.xhtml, but would use PrettyFaces to display the "/com/aboutus.html" URL

Also, what would I to if I went directly to the URL www.test.com/com/aboutus.html? This URL doesn't exist, the actual URL would be www.test.com/faces/pages.xhtml?url=%2Fcom%2Faboutus.html Should I be looking at setting up PrettyFaces to do all the work instead?

CaptainMorgan
  • 1,193
  • 2
  • 25
  • 55

2 Answers2

0
  1. create Databaseconnection
  2. read column from the database
  3. write the column into your jsf page

please take a look at JSF/JPA documentations or tutorials to solve this.

Lukas Eichler
  • 5,689
  • 1
  • 24
  • 43
0
<ui:include src="#{cmsPage._url}" />

ManagedBean Name

@ManagedBean(name="cmsPage")
@SessionScoped
class Cms_Page{
  private String _pageId;
  private String _url;

  //getter setter
}

Use Custom method to fetch from DAO and set the values inside Cms_Page

BholaVishwakarma
  • 581
  • 6
  • 18