Question about parameters and jsf phases.

Splash Forums PrettyFaces Users Question about parameters and jsf phases.

This topic contains 7 replies, has 3 voices, and was last updated by  Christian Kaltepoth 6 years, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17972

    loshmi
    Participant

    Hello, im using jsf 2.1.0 myfaces, seam-faces 3.0.2, pretty-faces 3.2.1 and tomcat 7.0.14 (and seam-servlet).

    Seam-faces has a tag <s:viewAction ../> which i just can get to work properly, so i tried rolling my own solution.

    I invoke actions on beans on certain jsf Phases. i know that pretty faces have their own actions on pages but as far as i know with those actions you cannot redirect a user to a different viewId.

    If i leave my url with the original params and only use prettyfaces for rewritting of the url part (like this ‘/editCustomer?customerId=12’ ) i can get my customerId from the HttpServletRequest in restoreview jsf phase.

    However if i use prettyfaces to make more restful url (like this ‘/editCustomer/#{customerId}/’), than it seems to me that pretty faces converts that url (to ‘/editCustomer?customerId=12’)only somewhere before Render Response phase which is too late for any redirecting.

    Now my question is if i get the url from servlet request in the Restore View phase, and it looks something like this (‘/editCustomer/12/’), can I somehow get that rewritten, or recognized as customerId=12 that early in the lifeCycle?

    I have a reference to prettyconfig from the servlet context, I can even get the UrlMapping for my url, but what to do then i am kind of lost there??

    Any hints??

    Thanks in advance.

    #21083

    Hi there,

    you can navigate from a prettyfaces action method just like a jsf action method:

    http://ocpsoft.com/docs/prettyfaces/snapshot/en-US/html/Configuration.html#config.actions.navigation

    http://ocpsoft.com/docs/prettyfaces/3.3.0-SNAPSHOT/en-US/html/navigation.html

    I hope this helps.

    -Lincoln

    #21084

    loshmi
    Participant

    Ok i guess i wasn’t detailed enough.

    Seam-faces and seam-security give you the option to configure prettyfaces in java code with something like this:

    @ViewConfig

    interface Pages{

    @UrlMapping(“myPage”)

    @admin

    item1;

    }

    Where @admin is an annotation that user defines, and seam security understands (only Admins are able to see this page). I like that feature and i would like to continue having that, but with this kind of configuration I cannot execute actions on page loads (I guess seam-faces guys have forgotten about actions).

    So i want to keep best of both worlds:

    1) Keep pretty-config here in java code so i can restrict roles and stuff like that.

    2) Use actions (just like with pretty-config) that can redirect a user if need arises.

    I already implemented my on @ViewAction annotation which adds actions to page loads.

    All i need now, is the information when does the handling of params such as (‘editCustomer/#{customerId}/’) happens (at what exact time does that happen in JSF 2?). To be more clear: at what JSF phase will the ‘customerId’ be available in FacesContext parameter map?

    Another question is:can i somehow programmatically tell prettyfaces: “Look here is the view-url ‘editCustomer/2/’ extract and store parameters for me?

    Thanks in advance.

    #21085

    I am also on the JBoss Seam team ;) So yeah, @UrlAction is on the way, but not done yet. Until then, if you need actions I recommend using the XML or annotation based PrettyFaces configuration :/ I’ll point Brian Leathem at this thread, though, and see if he can shed any more light on a faster workaround for you.

    Hang tight! This may be coming in a Seam Faces release near you.

    #21086

    Regarding your questions:

    All i need now, is the information when does the handling of params such as (‘editCustomer/#{customerId}/’) happens (at what exact time does that happen in JSF 2?). To be more clear: at what JSF phase will the ‘customerId’ be available in FacesContext parameter map?

    These parameters should be available in all JSF phases because the path parameters are converted into query parameters in the PrettyFilter which gets executed before the FacesServlet.

    Another question is:can i somehow programmatically tell prettyfaces: “Look here is the view-url ‘editCustomer/2/’ extract and store parameters for me?

    No, there is no user level API for this. I guess you should take a look at the source of PrettyFilter and PrettyPhaseListener to get an idea on how the internals work.

    https://github.com/ocpsoft/prettyfaces

    I hope this helps :)

    Christian

    #21087

    Actually @loshmi,

    If you wanted to do programmatic configuration, you could create a custom configuration provider, but this will only be accessed when the application boots up:

    http://ocpsoft.com/docs/prettyfaces/snapshot/en-US/html_single/#ConfigurationProvider

    #21088

    loshmi
    Participant

    Thanks guys. I will have a look at that.

    Thanks for the answers.

    #21089

    BTW: Did I understand you correctly that <s:viewAction ../> isn’t working at all in your case?

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

You must be logged in to reply to this topic.

Comments are closed.