jsf - Pretty Faces EL Injection does not work -


i building online application in jsf 2 primefaces , spring. want use pretty faces make our search urls bookmarkable.

here 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 bean want 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 , setters ...  } 

only "/search" works fine. tried changing order of mappings in pretty-config.xml , using dummy values other 2 parameters , using 1 parameter. thing tried change teh expressions "#{bean.param}" "#{getparam : bean.param}". changing scope of bean doesn't either.

on webpage use primefaces commandlink has "searchview.navigate" action parameter.

i following error message:

http status 404 - /search/a/b/c

type status report

message /search/a/b/c

description requested resource (/search/a/b/c) not available.

definitely having pattern /search/#{searchview.searchquery}/#{searchview.searchtags}/#{searchview.searchorder} bad idea.

here quote of my conversation @lincon, prettyfaces team lead:

  • me: , other one, possible add 2 params in pattern? /detail/#{appid}/#{navigationindex}.
  • lincon: create secondary url-mapping display same view-id, , long parameters different, e.g: 1 mapping "/detail" , other "/detail/#{appid}", you'll fine. if have same pattern, you'll have problems.

personally don't use el expressions url patterns. began use them have big drawback: force specify url written in pattern.

for example, having /students/#{studentid} force specify student id reach page. otherwise need declare second pattern same view-id. appart that, second parameter in request force use http standard way pass parameters (imagine want add second one, need /students/detail/#{studentid}?viewmode=2, passing them in different way).

for me easier declare /students/detail , after pass params in classic (not pretty) http way: /students/detail?studentid=1&viewmode=2.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -