0

I'm trying to make a registration application using JSF 2.0 with jsp as pages. My page has several input fields, once the user enters all the data and clicks on the submit button, database has to be updated with user entered data. I want to generate a popup window here stating that "REGISTRATION COMPLETE, your REFERENCE ID is 00001" where the reference ID is from back end.

Here is the code which I tried

<h:commandButton id="submitBtn" value="Submit" action="#{regBean.submitDetails}" onclick="javascript:popUp('registrationNum.jsp')" />

The registrationNum.jsp is

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        
    </head>
    <body>
    <f:view>
        <h:panelGrid>
            <f:facet name="header">              
                <h:outputText value="#{regBean.regNum}" ></h:outputText>
            </f:facet>
        </h:panelGrid>
    </f:view>
    </body>
</html>

But I'm unable to display the registrationNum.jsp.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
esha
  • 3
  • 2
  • 4

2 Answers2

1
  • Create an Registration view ( jsp or XHTML), including your fields
  • Invoke an action on registration button click
  • Do the processing in action
  • Navigate user to some other page if its successful , else put user to same page with error message
  • if its successful then set the processed ref Id in managed bean
  • on success view use any dialog (javascript, rich:modalpanel) to show the alert message
jmj
  • 237,923
  • 42
  • 401
  • 438
  • I've done all the above process...got stuck in creating a popup...can u post some sample code for a pop window in my scenario – esha May 03 '11 at 08:16
  • `alert("Registration Completed with ref Id: #{yourBean.refId}"); ` invoke this on page load – jmj May 03 '11 at 08:26
  • this alert popus up on the page load...but i need a popup after user enters all the details and clicks on submit button. also after the database gets updated – esha May 03 '11 at 10:49
  • then use AJAX and render the component. [check this answer](http://stackoverflow.com/questions/5852890/how-to-update-a-value-displayed-in-the-page-without-refreshing/5853873#5853873) – jmj May 03 '11 at 10:55
0

Check this answer, i think that will help you out.

You cannot directly land on the pop as all the pop up needs a parent page.

So either land in a result page or in the same ppage and use the script to come up with a pop according to value set in the session , You can use a flag or even a string.

Community
  • 1
  • 1
Sundhar
  • 149
  • 1
  • 7
  • 21