Lincoln Baxter III

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 1,275 total)
  • Author
    Posts
  • in reply to: URL Params from action method #27452

    Hi,

    To do this, you’ll need to create a “mapped query-parameter” in your pretty-config.xml file (or your class configuration if you are using annotations.)

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

    <url-mapping id="store"> 
       <pattern value="/store/" /> 
       <view-id value="/faces/shop/store.jsf" />
       <query-param name="section"> #{bean.section} </query-param>
    </url-mapping>

    Then you just need to set the value of the bean before navigating to the page:

    public String onCommandButton() {
       bean.setSection("shoes");
       return "pretty:store";
    }

    PrettyFaces will extract the parameter value and use it when creating the URL.

    I hope this helps.

    in reply to: rewrite-annotations-impl included twice #27447

    Rewrite version 3.4.0.Final has been released and includes this fix.

    Hi There,

    I believe your issue is related to the fact that you are likely using the JSF Page Navigation system — You need to issue a page redirect in order to change the URL after navigation using the language picker you’ve implemented.

    This page has a good explanation of the difference between Forward (the default) and Redirect (what you need).

    https://www.mkyong.com/jsf2/jsf-page-forward-vs-page-redirect/

    Hope this helps.

    Additionally, consider using Rewrite (the library PrettyFaces is built on) for internationalization:

    https://github.com/ocpsoft/rewrite/blob/master/documentation/src/main/asciidoc/configuration/i18n.asciidoc

    Thanks,
    Lincoln

    in reply to: 301 permanent Redirect #27285

    Without too much commentary from me on why your code didn’t work, I’ll just say that can’t run code after you return from a function. Just assign the builder you are already using to a variable named “builder”. This should fix your code:

    public Configuration getConfiguration(final ServletContext context) {
           ConfigurationBuilder builder = ConfigurationBuilder.begin()     
                    
            for (Map.Entry pair : linkName.entrySet()) {
                builder.addRule().when(Direction.isInbound().and(Path.matches("/some/{page}/"))).perform(Forward.to("/new-{page}/"));
            }
    
            return builder;
        }
    in reply to: 301 permanent Redirect #27280

    Just iterate like you normally would, and call the builder.addRule() method from within your loop:

    
    loop ( over stuff )
    {
        builder.addRule()
          .when(Direction.isInbound().and(Path.matches(key)))
          .perform(Forward.to(value));
    }
    in reply to: Rewrite Websphere configuration #27269

    Hm. Good question. This is the first I’ve heard of trouble since that screenshot was created.

    Have you configured your web.xml?

    in reply to: 301 permanent Redirect #27255

    Sure, absolutely:

    
    Map<String, String> urlMap = ...
    for( String oldPath : oldPaths )
    {
       builder.addRule
          .when(Path.matches(oldPath))
          .perform(Redirect.to(urlMap.get(oldPath)))
    }
    

    Or however you want to implement the loop. Remember you can use {params} to simplify many mappings if your URL structure has patterns and repetition.

    in reply to: 301 permanent Redirect #27252

    Hi Banifou,

    Try something like:

    .when(Path.matches("/old/{path}"))
    .perform(Redirect.permanent("http://domain.com/new/{path}/etc/etc"));
    
    in reply to: Rewrite Rules when using with ADF/Webcenter #27031

    Hi Siddharth,

    Without seeing what is in your view.PrettyFacesAdfProcessor, I can’t really suggest what your problem might be. There could be a bug in that. However, for the type of large-scale configuration you are using, I would recommend using Rewrite directly (PrettyFaces is a configuration extension for Rewrite):

    http://ocpsoft.org/rewrite/

    An example rule that would do what you want:

    .addRule(Join.path("/de/{p}").to("/xyz/{p}"))
    .where("p").matches(".*")

    ~Lincoln

    in reply to: Multiple rewrite url value from database #27028

    Christian is right, you probably want to either trigger a purge of the the ServletContext configuration cache:

    context.put(ServletContextConfigurationCacheProvider.class.getName() + "_cachedConfig", null)

    Or… you can implement your own HttpConfigurationCacheProvider and register it as documented here:

    https://github.com/ocpsoft/rewrite/blob/master/api/src/main/java/org/ocpsoft/rewrite/spi/ConfigurationCacheProvider.java#L25

    (Just make sure the priority is set to a lower number than the existing ServletContext cache provider’s priority (to override it.)

    However, in order for this to work, you will also need to disable the ServletContext cache entirely:

     <context-param>
        <param-name>org.ocpsoft.rewrite.config.CONFIG_RELOADING</param-name>
        <param-value>true</param-value>
      </context-param>

    ~Lincoln

    in reply to: Cannot forward after response has been committed #27006

    I’m a glassfish noob and eclipse isn’t letting me actually set up a GlassFish server, so I may not get to try this soon. Will need to revisit.

    in reply to: Cannot forward after response has been committed #27005

    I see another problem with your rule. Currently it will match on ALL urls, and “excluded” will always be empty. The reason is this:

    .where("excluded").matches("(?!/wres|/123/123/test)")

    The problem here is that the above regex is always going to be 0-width, (because the lookahead is zero width, and the regular expression has no character groups.) It should probably be:

    .where("excluded").matches("(?!/wres|/123/123/test).*")

    But this leads to another problem, where I think that will cause “excluded” to match more than what you want. In reality, I think you are trying to improperly use two parameters to match one thing. That won’t work. You should just do this all with the parameter for “url”.

    ConfigurationBuilder config = ConfigurationBuilder.begin();
    
    config.addRule()
             .when(Direction.isInbound().and(Path.matches("{url}"))
                .andNot(DispatchType.isError())
             )
             .perform(Forward.to("/123/123/test?url={url}" ) )
             .where("url").matches("(?!/wres|/123/123/test).*");

    I am about to try this myself.

    in reply to: Cannot forward after response has been committed #27003

    I was trying to figure out what might cause this problem last night, but I have to admit that I don’t really understand what happened. Could you perhaps upload a sample application that reproduces this so that I can see what is going on?

    Is this a problem with Rewrite that is incompatible with GlassFish? Or was there an error encountered during servlet processing (after rewrite forwarded, then rewrite triggered again on the error dispatch.)

    I think this configuration might solve your problem (and allow you to keep your web.xml error config.)

    ConfigurationBuilder config = ConfigurationBuilder.begin();
    
    config.addRule()
             .when(Direction.isInbound().and(Path.matches("{excluded}{url}"))
                .andNot(DispatchType.isError())
             )
             .perform(Forward.to("/123/123/test?url={url}" ) )
             .where("excluded").matches("(?!/wres|/123/123/test)")
             .where("url").matches(".*");

    Note the exclusion of the ERROR dispatch type:

    .andNot(DispatchType.isError())

    Let me know if this works. Thanks!

    in reply to: The value of required parameter [page] was null. #26997

    What I see wrong with the regex is this:

    
    .matches("^[^\\/.\\s]*$");
              ^           ^

    Because the regex is going to get compiled into a larger regular expression for the entire path, you can’t use start & end matches in the regex. You could either remove them (they aren’t necessary) To be honest I think you just want to use .* based on what I see your pattern does (matches / and anything any number of times).

    Or you could remove the leading slash in your Join path:

    .addRule(Join.path("{page}").to...
    .matches("^[^\\/.\\s]*$");
    

    That might work as well.

    in reply to: The value of required parameter [page] was null. #26996

    Is that right? It matches the encoded URL? Are you sure?

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

« Previous Entries