Multiple pattern to same vew-id

Splash Forums PrettyFaces Users Multiple pattern to same vew-id


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

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



    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 id="home">
    <pattern value="/admin" />
    <view-id value="/faces/Admin/index.xhtml" />

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

    The file index.xhtml is a masterpage.

    Thank you for your time.


    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?




    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 =
    String par = request.getParameter("myPage");

    but I can’t.

    Can you help me with another advice?


    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:

    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.



    Thank you for your answer.

    I will dig for more infos on JSF 2.0

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

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.