0

I trying to resolve a issue regarding pretty faces pass parameters to bean:

I have configured pretty-config mapping as follows:

<url-mapping id="frontend_search"> 
    <pattern value="/szukaj/#{ categoryId }" />   <!-- pass parameter from url -->
    <view-id value="#{searchView.getViewPath}" />  <!-- dynamic view id -->
</url-mapping>

Problem is that. The parameter is not being passed into request parametersMap

    String catId = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("categoryId"); 

is null

but when i change configuration of pretty faces to the following (no dynamic view-id)

<url-mapping id="frontend_search"> 
    <pattern value="/szukaj/#{ categoryId }" />   <!-- pass parameter from url -->
    <view-id value="/faces/template_1/frontend/pages/products/search.xhtml" />  <!-- no dynamic view id -->
</url-mapping>

it works fine!. I cant understand why that happen. Meaby somebody have been that problem and can help here? I Will grateful for help

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Michał Ziembiński
  • 1,124
  • 2
  • 10
  • 31
  • Possible duplicate of [Dynamic view id using pretty faces navigation refuses to work](http://stackoverflow.com/questions/26290077/dynamic-view-id-using-pretty-faces-navigation-refuses-to-work) – Igor Deruga Apr 27 '16 at 13:30

1 Answers1

1

Not sure why this way isn't working. But you could bind the parameter directly to the searchView, which could work much better:

<url-mapping id="frontend_search"> 
    <pattern value="/szukaj/#{searchView.categoryId}" />
    <view-id value="#{searchView.getViewPath}" />
</url-mapping>

You will just need to add the categoryId property to your bean.

chkal
  • 5,598
  • 21
  • 26