I am building an online application in JSF 2 with Primefaces and Spring. I want to use Pretty Faces to make our search urls bookmarkable.
Here is my pretty-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">
<url-mapping id="index">
<pattern value="/" />
<view-id value="/sites/public/template/index.xhtml" />
</url-mapping>
<url-mapping id="searchWithParams">
<pattern value="/search/#{searchView.searchQuery}/#{searchView.searchTags}/#{searchView.searchOrder}" />
<view-id value="/sites/public/product/productSearch.xhtml" />
</url-mapping>
<url-mapping id="searchWithoutParams">
<pattern value="/search" />
<view-id value="/sites/public/product/productSearch.xhtml" />
</url-mapping>
</pretty-config>
Here is my Bean I want to inject in:
@Component
@Scope("request")
public class SearchView {
private String searchQuery = "";
private String searchTags = "";
private String searchOrder = "";
public SearchView() {
// void
}
public void navigate() {
String url = "";
try {
url = "/search" +
"/" + URLEncoder.encode(searchQuery, "UTF-8") +
"/" + URLEncoder.encode(searchTags, "UTF-8") +
"/" + URLEncoder.encode(searchOrder, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
url = "/search";
}
try {
FacesContext.getCurrentInstance().getExternalContext().redirect(url);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// Getters and Setters ...
}
Only "/search" works perfectly fine. I also tried changing the order of the mappings in the pretty-config.xml and using dummy values for the other two parameters and only using one parameter. Another thing I tried was to change teh expressions "#{bean.param}" to "#{getParam : bean.param}". Changing the scope of my bean doesn't help either.
On the webpage I use a primefaces commandlink which has "searchView.navigate" as action parameter.
I always get the following error message:
HTTP Status 404 - /search/a/b/c
type Status report
message /search/a/b/c
description The requested resource (/search/a/b/c) is not available.