0

I am using JSF 2.0. My url is not changing while navigating to another page. In faces-config.xml.

<navigation-rule>
    <from-view-id>/pages/common_attribute_list.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>editManageCommon</from-outcome>
        <to-view-id>/pages/add_common_attribute.xhtml</to-view-id>
    </navigation-case>
 </navigation-rule>

I am not using <redirect> in navigation cases, because I have also to show faces messages in another pages. If I add <redirect> it stops showing faces message. How can I change the URL without adding <redirect>?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Surya
  • 416
  • 4
  • 7
  • 26
  • to change url you have to use redirect in you navigations. redirects won't prevent facesmessages to be displayed. the actual question should be then, why you cannot show faces messages? to give you an answer, we need your xhtml where you display the messages, and your bean (controller). – Rami.Q Jan 09 '14 at 07:09
  • while nevigating I was getting lost my facesMessage , then I removed redirect now I am getting FacesMessage(got this answer from stackoverflow) http://stackoverflow.com/questions/20948259/unable-to-show-faces-message-on-xhtml-page. – Surya Jan 09 '14 at 12:18

1 Answers1

0

In order to change the URL in browser's address bar, you have to tell the browser to fire a new HTTP request on exactly that URL. That's exactly what the redirect does under the covers. So you really need to keep it in.

See also:


Coming back to the undesired consequence of the faces message being lost on redirect, that's fully expected as they are request scoped and you're with the redirect essentially trashing the current request and creating a new request. You can let the faces message survive the redirect by storing them in the so-called flash scope.

It's just a matter of calling Flash#setKeepMessages() passing true while adding the message.

context.addMessage(message);
context.getExternalContext().getFlash().setKeepMessages(true);

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555