1

I´m developing a web application with Primefaces 3.5. I need to redirect/forward the request to another xhtml page without changing the URL address in the address bar, since the main website address is going to be configured in the JBoss server to be accesible from outside.

This is my index.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">
<f:view>
<ui:insert name="metadata"/>
    <f:event type="preRenderView" listener="#{forwardBean.forward}" />
<h:body></h:body>
</f:view>
</html>

This is my ForwardBean.java:

(...)
@ManagedBean
@ApplicationScoped
public class ForwardBean {
    public void forward() throws IOException {
        FacesContext.getCurrentInstance().getExternalContext().redirect("main/SearchForm.xhtml");

The redirect works fine, but changes the URL in the address bar:

http://.../main/SearchForm

Can I redirect without seeing "main" in the address bar? I don´t know if PrettyFaces or any new feature of JSF 2.0 can help, I´m new to this technology.

Thanks in advance!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
riteshg
  • 21
  • 7
  • 1
    Looks like you're seeking for forwarding instead of redirect. – Luiggi Mendoza Nov 26 '13 at 14:59
  • 1
    possible duplicate of [How to perform navigation in preRenderView listener method](http://stackoverflow.com/questions/16106418/how-to-perform-navigation-in-prerenderview-listener-method) – Luiggi Mendoza Nov 26 '13 at 15:02
  • 1
    Why don't you just `` that page? – BalusC Nov 26 '13 at 15:13
  • Hi BalusC, actually I was redirecting to a page that you can only access if properly logged in, so the login website was opening by default, and after inserting proper user/pass you are finally redirected. I have changed this and now the login.xhtml is configured as the default page, but after logged in the URL address in the bar address is still http://.../main/SearchForm, which I want to avoid – riteshg Nov 26 '13 at 15:45
  • You need to add `@` to reply somebody in a comment. E.g. `@BalusC`. – Luiggi Mendoza Nov 26 '13 at 20:24
  • Thank you @Luiggi Mendoza, I´m new to this community. I finally redesigned the logon part of the application and this question no longer needs an answer. – riteshg Nov 29 '13 at 09:34

0 Answers0