How can handle URL ?

Splash Forums PrettyFaces Users How can handle URL ?

This topic contains 40 replies, has 3 voices, and was last updated by  thanhtung90 5 years, 8 months ago.

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

    thanhtung90
    Participant

    Dear everybody, when i create url by set <pattern> value like this:

    <pattern>#{danhMucController.category}</pattern>

    and then check in danhMucController, “category”‘s but seem nothing. And:

    <pattern>/#{/[a-z-_:]+/}/</pattern>

    it fine, but how can get url with?

    #21347

    Your first pattern will probably not match because path parameters don’t match / in the default configuration and you are missing the leading slash as the first part of the URL. Try:

    <pattern>/#{danhMucController.category}</pattern>

    You second pattern is missing the name of the property to inject the value into. You need to write something like:

    <pattern>/#{ /[a-z-_:]+/ danhMucController.category }/</pattern>

    See the documentation for details:

    http://ocpsoft.com/docs/prettyfaces/3.3.0/en-US/html/Configuration.html#config.pathparams.regex

    #21348

    thanhtung90
    Participant

    Uhm, i tried, but current still null when i access in both cases:

    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    String menu = externalContext.getRequestParameterMap().get("category");

    and similar with:

    <pattern>/#{ /[a-z-_:]+/ category }/</pattern>
    this.getCategory();

    But fail, too.

    #21349

    Does the pattern really match? Is the view rendered that you referenced in your mapping?

    #21350

    thanhtung90
    Participant

    Actual, i don’t understand your mind(sorry because my english not good). I’m try with

    http://localhost:8084/ProjectName/abcxyz/

    In my config, i choice like your suggest and like above, here:

    <pattern>/#{ /[a-z-_:]+/ category }/</pattern>
    <view-id>#{danhMucController.navigator}</view-id>

    Navigator() method return String which dynamic url i want redirect to: “pretty:home”.

    For homepage, my pattern here:

    <url-mapping id="home">
    <pattern value="/"/>
    <view-id>/faces/abc/def/index.xhtml</view-id>
    </url-mapping>
    <url-mapping id="register">
    <pattern value="/re-gis-ter.html"/>
    <view-id>/faces/abc/def/register.xhtml</view-id>
    </url-mapping>

    and these fine, for few other with fix .xhtml pages – it’t ok, too.

    #21351

    Ah, OK, you are using dynaview! Perhaps this is related to this issue:

    http://code.google.com/p/prettyfaces/issues/detail?id=120

    Seems like the same issue, right?

    #21352

    thanhtung90
    Participant

    In this example, my app infinity loop:

    #{ /.*/ parameters : navigationBean.parameters}

    And other, I see nothing special with my cases.

    "
    Hmm, strange. It really shouldn't happen that way. Do you think you could create a little example app that shows this? I'm very surprised by this actually, because this is how the code looks in PrettyPhaseListener:

    if (!event.getFacesContext().getResponseComplete())
    {
    // run parameter validation
    validator.validateParameters(event.getFacesContext());

    // abort if validation failed, 404 response code has already been set
    if (event.getFacesContext().getResponseComplete())
    {
    return;
    }

    // inject parameters
    injector.injectParameters(event.getFacesContext());
    }

    PrettyContext prettyContext = PrettyContext.getCurrentInstance(event.getFacesContext());
    if (prettyContext.shouldProcessDynaview())
    {
    dynaview.processDynaView(prettyContext, event.getFacesContext());
    }
    <Lincoln>
    "

    This maybe need i extends or implements PrettyPhaseListener?

    #21353

    1. Regarding the infinity loop. Could you post the complete mapping please?

    2. I don’t think you can fix this issue by extending PrettyPhaseListener. IMHO the if statement (first line in your quote) is the problem. You could try to remove the if but this would require you to clone the PrettyFaces source and compile it yourself. I hope to find some time on the weekend to work in this issue. Perhaps I will find the real cause of this then.

    #21354

    thanhtung90
    Participant

    1. Here,

    The server side component of the HTTP Monitor has detected a java.lang.StackOverflowError.
    This happens when there is an infinite loop in the web module.
    Correct the cause of the infinite loop before running the web module again.

    and pattern that i use in problem:

    #{ /.*/ parameters : navigationBean.parameters}

    2. I just suggest about that link you gave because in pattern that you gave (both 2 cases):

    <pattern>/#{ /[a-z-_:]+/ danhMucController.category }/</pattern>

    or

    <pattern>/#{ /[a-z-_:]+/ category : danhMucController.category }/</pattern>

    nothing i received (null value).

    #21355

    Hey there.

    could you please post the complete <url-mapping> that is causing the stack overflow? And perhaps the stacktrace. This would be really helpful for finding the cause of this issue.

    I did some research on the problem regarding the path parameters that are not injected when using dynaview. I think I found the bug causing this and just pushed a fix to the main repository. Could you perhaps give the latest snapshots (3.3.1-SNAPSHOT) a try? You can find all required details on how to use the snapshots here:

    https://github.com/ocpsoft/prettyfaces/wiki/Snapshots

    Thanks

    Christian

    #21356

    thanhtung90
    Participant

    This is my code:

    <url-mapping id="catalog" >
    <!-- <pattern>/#{category : /[a-z-_:]+/}/</pattern>-->
    <!-- <pattern value="/category/"/>-->
    <pattern>/#{ /[a-z-_:]+/ category : danhMucController.category }/</pattern>
    <!-- <pattern>#{/.*/ category: danhMucController.category}</pattern>-->
    <view-id>#{danhMucController.navigator}</view-id>
    <!-- <action>#{phimController.navigator}</action>-->
    </url-mapping>

    But how i can use this version Snapshots? I’m a newbie. Thank.

    #21357

    thanhtung90
    Participant

    I download Snapshots version but nothing change with

    <pattern>#{/.*/ category: danhMucController.category}</pattern>

    i still receive error above.

    #21358

    The fix that I wrote about (and which is now available in 3.3.1-SNAPSHOT) fixes the issues you described in your second post on this thread. You wrote that the category parameter was always null when using dynaview. This issue should be fixed now. So please try something like this:

    <url-mapping id="catalog">
    <pattern>/#{ danhMucController.category }/</pattern>
    <view-id>#{ danhMucController.navigator }</view-id>
    </url-mapping>

    with:

    public class DanhMucController {

    private String category;

    public String navigator() {
    System.out.println("Category: "+category);
    return "/faces/myview.xhtml";
    }

    }

    The stack overflow error seems to be a totally different issue. We will definitively need the stacktrace to help you there.

    #21359

    thanhtung90
    Participant

    Actual i don’t understand, i follow your tutorial, even i copy because i fear confuse by myself, but current with Snapshots “prettyfaces-jsf2-3.3.1-20110919.063144-23-sources.jar” combine 2 codes above i still got result null. No warning, no error.

    This is my web.xml:

    <filter>
    <filter-name>Pretty Filter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
    <async-supported>true</async-supported>
    </filter>

    <filter-mapping>
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>ASYNC</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    <context-param>
    <param-name>com.ocpsoft.pretty.BASE_PACKAGES</param-name>
    <param-value>controller.abc</param-value>
    </context-param>

    #21360

    I don’t know whats wrong with your code. Could you perhaps build a small example app reproducing this issue? You could use my Maven archetypes to set up a small PrettyFaces project quickly.

    https://github.com/chkal/prettyfaces-archetypes/wiki

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

You must be logged in to reply to this topic.

Comments are closed.