Executing first configured mapping of by default for all other actions

Splash Forums PrettyFaces Users Executing first configured mapping of by default for all other actions

This topic contains 1 reply, has 2 voices, and was last updated by  Christian Kaltepoth 1 year, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27090

    Lucky
    Participant

    I have a Search Form executing below action
    <h:commandButton styleClass="btn" type="submit" value="Submit" action="pretty:job-search-results" inclueViewParams="true"> </h:commandButton>

    I configured mappings in pretty-config.xml

    <url-mapping id="customer-result">
    	<pattern value="/#{customerMBean.lookupId}/"/>
    	<view-id value="/pages/customer-result.xhtml"/> 
    </url-mapping>  
    	
    <url-mapping id="mySearch-result">
    	<pattern value="/#{mySearchMBean.addressId}/"/>
    	<view-id value="/pages/mySearch-result.xhtml"/> 
    	<action onPostback="false">#{mySearchMBean.doLookupForAddress}</action>
    </url-mapping> 
    
    <url-mapping id="job-search-results">
    <pattern value="/#{searchJobsMBean.keySkills}/"/>
    	<view-id value="../jobs/job-search-results.xhtml"/>
    	 <action onPostback="false">#{searchJobsMBean.getJobs}</action> 
    </url-mapping>

    The issue is whenever I execute job-search-results action (3 one) its executing first action by default.

    When I move the first two mappings to bottom of it, its executing correctly.

    Am I doing anything wrong here?

    #27091

    The problem is that your mappings overlap. Imagine an URL like /contextpath/3/. How should PrettyFaces know which of the patterns should match? It cannot!

    You have basically two options. Either use custom regular expressions to ensure that for each URL only the relevant mapping matches.

    See: http://www.ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.pathparams.regex

    Or prefix your URL with something that makes the patterns unique:

    <pattern value="/c/#{customerMBean.lookupId}/"/>
    ...
    <pattern value="/a/#{mySearchMBean.addressId}/"/>
    ...
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Comments are closed.