Search Filter Dynamic Url

Splash Forums PrettyFaces Users Search Filter Dynamic Url

This topic contains 14 replies, has 3 voices, and was last updated by  ravindra 2 years, 7 months ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #25585

    ravindra
    Participant

    Hi sir,

    We have a search functionality where there are few filters. User can select any of the combinations of those filters.
    Current Search URL with query string: /pages/search.xhtml?cat=12&mode=1 (Where cat and mode in the query string are two search filters. Also the order of these params might change.)
    Required Patterns: /p/search/cat-12/mode-1 (or) /p/search/mode-1/cat-12 (or) /p/search/mode-1 (or) /p/search/cat-12
    These patterns depends on user selecting the filters. User can select any of the combinations or none of those filters.
    Please advice a solution for our requirement.

    Thanks & Regards
    Ravindra

    #25586

    You could for example define a single parameter that also matches / characters and then parse it yourself. Something like:

    .addRule( Join.path("/p/search/{filters}").to("/pages/search.xhtml") )
    .where("filters").matches(".*").bindsTo(...)
    

    But personally I don’t think that it is a good idea to place optional filters in the path part of the URL. I for myself would use query parameters instead, as they are optional by nature.

    #25587

    ravindra
    Participant

    Can you please check URL’s in the following site. We are basically trying to achieve that.

    https://www.elance.com/r/contractors/q-java/ind-true

    Change search filters from left page in the above page and observe the URL.

    #25588

    Yeah, you can do that with the approach I posted before.

    #25589

    ravindra
    Participant

    Can you please explain with an example it would be grateful to me,

    bit confusion in where condition
    .where(“filters”).matches(“.*”).bindsTo(…)

    Thanks & Regards
    Ravindra

    #25590

    Have a look at the “Getting started with Rewrite” section of the documentation:

    http://ocpsoft.org/rewrite/docs/

    Parameters and their configuration is described there.

    #25591

    ravindra
    Participant

    Thanks for your support

    i will try it.

    Regards
    Ravindra

    #25592

    ravindra
    Participant

    hi sir,

    i tried which you suggested ,

    .addRule( Join.path(“/p/search/{filters}”).to(“/pages/search.xhtml”) )
    .where(“filters”).matches(“.*”).bindsTo(El.retrievalMethod(“bean.loadItem”))

    but its giving an error,

    Please help out this problem its great helpful to me

    #25594

    Hey ravindra,

    but its giving an error

    This is not a very helpful description of you problem. Without more details, nobody will be able to help you.

    Christian

    #25596

    ravindra
    Participant

    sorry christian,

    i will send you the full details regarding the error,

    Thanks for your support,

    Regards
    Ravindra

    #25598

    ravindra
    Participant

    Hi sir,

    The error is

    
    org.ocpsoft.rewrite.exception.RewriteException: No registered org.ocpsoft.rewrite.el.spi.ExpressionLanguageProvider could handle the Expression [search.initializeFilters]
    	at org.ocpsoft.rewrite.el.El.executeProviderCallable(El.java:185)
    	at org.ocpsoft.rewrite.el.El.access$100(El.java:40)
    	at org.ocpsoft.rewrite.el.El$ElMethod.retrieve(El.java:210)
    	at org.ocpsoft.rewrite.config.Invoke.perform(Invoke.java:52)
    	at org.ocpsoft.rewrite.config.DefaultOperationBuilder$DefaultCompositeOperation.perform(DefaultOperationBuilder.java:56)
    	at org.ocpsoft.rewrite.config.RuleBuilder.perform(RuleBuilder.java:136)
    	at org.ocpsoft.rewrite.config.DefaultOperationBuilder$DefaultCompositeOperation.perform(DefaultOperationBuilder.java:56)
    	at org.ocpsoft.rewrite.config.RuleBuilder.perform(RuleBuilder.java:136)
    	at org.ocpsoft.rewrite.config.DefaultOperationBuilder$DefaultCompositeOperation.perform(DefaultOperationBuilder.java:56)
    	at org.ocpsoft.rewrite.config.RuleBuilder.perform(RuleBuilder.java:136)
    	at org.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider.rewriteHttp(DefaultHttpRewriteProvider.java:182)
    	at org.ocpsoft.rewrite.servlet.http.HttpRewriteProvider.rewrite(HttpRewriteProvider.java:43)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:247)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:188)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)	
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:64)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:144)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
    	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at java.lang.Thread.run(Thread.java:724)
    
    

    Regards
    Ravindra

    #25599

    Could you post the code of the bean containing the method you are trying to call. Also post all the Rewrite dependencies you added to your project.

    #25601

    ravindra
    Participant

    Please ignore my previous error log. Below is the code.

    .addRule().when(Direction.isInbound().and(Path.matches("/p/search/{filters}"))).perform(Forward.to("/pages/search.xhtml")).where("filters").matches(".*");

    My Request URL is /p/search/cat-12/mode-1 and I got cat-12/mode-1 through {filters}. Now I need to split {filters} and pass them to /pages/search.xhtml as cat=12&mode=1.

    Is there any way where I can access the {filters} value and pass it to a method to split them as desired and pass them back to /pages/search.xhtml?

    Something like .to("/pages/trainingSearch.xhtml?"+getQueryString("{filters}") where getQueryString is a static method in custom class PrettyConfigurationProvider which extends HttpConfigurationProvider.

    • This reply was modified 2 years, 7 months ago by  ravindra.
    • This reply was modified 2 years, 7 months ago by  Lincoln Baxter III.
    #25606

    Yes…

    .addRule()
    .when(Direction.isInbound().and(Path.matches("/p/search/{filters}")))
    .perform(Forward.to("/pages/search.xhtml{filters}"))
    .where("filters").matches(".*").transposedBy(new Transposition<String>() {
       public String transpose(Rewrite event, EvaluationContext context, String value) {
           // convert the '/blah=23/foo=sd/' format to your query string format here and return it.
       }
    });
    #25620

    ravindra
    Participant

    Hi Lincoln,

    Thanks a lot ,now its working fine,

    awesome example with explanation.

    Thank you thank you,

    Regards
    Ravindra

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.

Comments are closed.