Multiple pattern to same vew-id

Splash Forums PrettyFaces Users Multiple pattern to same vew-id

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  surendra 4 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #19024

    surendra
    Participant

    Hi,

    First of all I want to thank you for this wonderful piece of software. It resolve a lot of my needs.

    I am trying to customize my project like this:

    My home page and all other pages must access the same .xhtml file

    <url-mapping id="allPages">
    <pattern value="/admin/#{mainAdmin.myPage}" />
    <view-id value="/faces/Admin/index.xhtml" />
    </url-mapping>

    <url-mapping id="home">
    <pattern value="/admin" />
    <view-id value="/faces/Admin/index.xhtml" />
    </url-mapping>

    <url-mapping id="home">
    <pattern value="/admin/" />
    <view-id value="/faces/Admin/index.xhtml" />
    </url-mapping>

    The file index.xhtml is a masterpage.

    Thank you for your time.

    #23217

    First of all I think you should to not use two distinct mappings for the second and the third one. Instead you could just use a rewrite rule to redirect the user from the one to the other. Something like this:

    <rewrite match="/admin" substitute="/admin/" redirect="302" />

    But it should also be possible to use multiple mappings for the same view id. Did you test it? Did it cause any errors?

    #23218

    surendra
    Participant

    Hi,

    I tested url-mapping and it works fine.

    I start learning java only a few weeks ago, so please be patient if I ask something obvious.

    With url-mapping how can see the difference?

    I was trying to read myPage variable with:

    HttpServletRequest request =
    (HttpServletRequest)FacesContext
    .getCurrentInstance()
    .getExternalContext()
    .getRequest();
    String par = request.getParameter("myPage");

    but I can’t.

    Can you help me with another advice?

    #23219

    With the configuration you posted above, your are injecting the value of the path parameter into a bean. So you won’t be able to read the value using request.getParameter(). If you want to do it this way, you should use named parameters instead.

    See this chapter of the documentation for details:

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

    BTW: Are you really sure that you want multiple URLs for only one view? This seems a bit strange for me. Wouldn’t that mean that you will have a very very large view which is difficult to manage. I recommend to use different views and the templating support of JSF 2.0 to manage parts of the page that are same for each view.

    #23220

    surendra
    Participant

    Thank you for your answer.

    I will dig for more infos on JSF 2.0

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

You must be logged in to reply to this topic.

Comments are closed.