1

I'm working with JSF and PrettyFaces and I need to do the next thing. I have 4 buttons generated in an ui:repeat. Every commandButton sets an object in a Conversation Bean and then I have to navigate to another page and get the object that was set in the button clicked. It seems pretty simple but the problem is I need a PrettyFaces friendly URL in the browser.

Tests done:

  • If I put the xhtml resource as string in the return commandbutton action navigates correctly but the URL points to the xhtml resource, not to the pretty-faces friendly URL. (Ex: ...host/my-web/prices.xhtml)

  • If I put the friendly URL as string (/web/prices/) in the return commandbutton action is not navigating.

  • If I do a redirect as follows:

    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
    
    try {
         context.getExternalContext().redirect("/web/prices/");
    

It navigates correctly to the friendly URL but the conversation is not working because before I redirect I'm setting the object recived in the commandbutton action and when navigates this object in the conversation bean is null.

Any idea how to solve that?

Thanks in advance.

dcalap
  • 1,048
  • 2
  • 13
  • 37
  • Which version of PrettyFaces are you using? – chkal Aug 06 '13 at 13:54
  • The problem is that the bean won't survive the redirect. It would be better to store the data in session and retrieve it in the `@PostConstruct` of the bean that handles your prices.xhtml page. – Luiggi Mendoza Aug 06 '13 at 14:16

1 Answers1

3

Looks like you're not adding the cid parameter to your redirects. That has to be passed via POST or query string in order for the conversation to continue. The value for that you can retrieve from an injected Conversation object.

LightGuard
  • 5,298
  • 19
  • 19
  • I believe that @LightGuard is correct. You need to manually add the CID parameter if you are doing redirects programatically. – Lincoln Aug 06 '13 at 22:19