0

I've registration.xhtml page, where user will enter data to get registered. I've written code in such a way that, if user clicks on register or Cancel button the page is refreshed and the fields become empty.But suppose if the User gives some data in the registration screen, for some reason User goes to some other page(menu1) in the application and comes back to the registration page, the data entered is still being displayed.

I need some suggestion such that each time user click on the links in header the page should be refreshed, where my header page has many links, each of which is a xhtml page Following is my header page

<html>
<f:view>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Untitled Document</title>
      <link rel="stylesheet" href="css/styles.css" type="text/css">
      <title>JSP Page</title>
    </head>
    <body bgcolor="#FFFFFF" >
     <h:form>
     <div id="navigation">
      <ul id="mainMenu">                     
       <li class="cat-item cat-item-3"><span>&nbsp;</span>
        <h:outputLink value="register.jsp" >
         <h:outputText value="Registration"/></h:outputLink>
        </li> 
        <li class="cat-item cat-item-2"><span>&nbsp;</span>
         <h:outputLink value="menu1.jsp">
          <h:outputText value="MENU1"/></h:outputLink>
        </li>
        <li class="cat-item cat-item-2"><span>&nbsp;</span>
         <h:outputLink value="menu2.jsp">
          <h:outputText value="MENU2"/></h:outputLink>
        </li>
       </div>
       </h:form>
      </body>
     </f:view>
    </html>
Mango
  • 650
  • 2
  • 16
  • 38
  • I think it is because you keep your input in session. Show you registration page and tell us the scope of backing bean. – Piotr Gwiazda Apr 20 '12 at 10:01
  • Ya..my bean's Session Scoped...do I've to make it request scoped...???? – Mango Apr 20 '12 at 10:13
  • It's not the problem that page doesn't refresh after next/back transition. It actually refreshes and loads data from you session bean. The rule of thumb says: Don't use session bean unless you are really sure that you need to and aware of possibe side effects. Keep ONLY necessary data in session beans, i.e. user selections etc. – Piotr Gwiazda Apr 20 '12 at 11:24

1 Answers1

0

That can happen if the backing bean is in the session scope. A session scoped bean instance lives as long as the established HTTP session between client and server. So every single HTTP request within that session uses the very same session scoped bean instance. This is not what you want.

Put the bean in the request or view scope.

See also:

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