File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Dynamic UI generation problem while opening popup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Dynamic UI generation problem while opening popup" Watch "Dynamic UI generation problem while opening popup" New topic

Dynamic UI generation problem while opening popup

vinod perla

Joined: Jan 06, 2005
Posts: 16
Hello All,

I am working on JSF since 2 months . I have a need in project such that if I open a popup calling the same JSP again , I need to generate the components as per the condition and store the values and close the window . This is just an sample , truly speaking I need to generate many components in popup while calling the same JSP. The Problem I am facing now is , I can see the same Parent window components when I open the popup.Its not showing the new PanelGrid. From Parent window to nth popup window , we are going to store values in Same object in sessionScope.

Can some one help me in fixing this issue . As I am stuck at work to proceed further.

The Below is just a sample of my application scenario.

Code :


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%-- jsf:pagecode language="java" location="/src/pagecode/pages/" --%><%-- /jsf:pagecode --%>
<%@taglib uri="" prefix="h"%>
<%@taglib uri="" prefix="hx"%>
<%@taglib uri="" prefix="f"%>
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
<link rel="stylesheet" type="text/css"
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Rational Application Developer">
<link rel="stylesheet" type="text/css" href="../theme/stylesheet.css"

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<hx:scriptCollector id="scriptCollector1">
<h:form id="DynamicUIform" styleClass="form" >

<h:panelGrid binding="#{pc_ToTest.htmlPanelGrid}"


=========================================================================== ( Backing Bean)


public class ToTest extends PageCodeBase {

public HtmlPanelGrid htmlPanelGrid = null;

protected HtmlForm DynamicUIform;

private FacesContext facesContext = null;

private Application application = null;

protected HtmlScriptCollector scriptCollector1;

protected HtmlCommandExButton button1;

public HtmlPanelGrid gethtmlPanelGrid() {
//if (htmlPanelGrid == null) {
//htmlPanelGrid = new HtmlPanelGrid();
//System.out.println("new html object created");
htmlPanelGrid = new HtmlPanelGrid();
System.out.println("called gethtml method of Totest"+ htmlPanelGrid);
return htmlPanelGrid;

public void sethtmlPanelGrid(HtmlPanelGrid htmlPanelGridd) {
System.out.println("Called sethtmlPanelGrid of totest.");

this.htmlPanelGrid = gethtmlPanelGrid();
//this.htmlPanelGrid = htmlPanelGridd;

System.out.println("Finished sethtmlPanelGrid of to test." +htmlPanelGrid);

public void testComponent() {
String testing=" ";
System.out.println("entered test component method");
Application application = FacesContext.getCurrentInstance()
facesContext = FacesContext.getCurrentInstance();

System.out.println("entered try block");
testing = (String) facesContext.getExternalContext()
System.out.println("Testing "+ testing );
}catch(Exception e){

this.getSessionScope().put("Reference", new Reference());
System.out.println("created Reference obj in session");

System.out.println("already Reference in session");

System.out.println("Choice is "+choice);

if ( testing !=null && testing.equals("one")){

HtmlOutputLabel arrestType = new HtmlOutputLabel();
HtmlInputText htmlInputText = new HtmlInputText();
ValueBinding InenameBinding = application
IntegerConverter conv = new IntegerConverter();
htmlInputText.setValueBinding("value", InenameBinding);
System.out.println("executed if block");


HtmlOutputLabel officerId = new HtmlOutputLabel();
HtmlInputText htmlInputText1 = new HtmlInputText();
ValueBinding lnameBinding = application

htmlInputText1.setValueBinding("value", lnameBinding);
System.out.println("executed else block");

HtmlCommandButton submitButton = new HtmlCommandButton();
submitButton.setValue("Submit Button");
MethodBinding submitButtonBinding = application.createMethodBinding(
"#{pc_ToTest.doSubmitTest}", null);

String javaScriptText = "'"
+ "ToTest.faces"
+ "?sessionPath="
+ "one"+ "', '\', 'status=1,width=750,height=450,scrollbars=yes,resizable=no,modal=yes');return false;";
HtmlCommandButton submitButton1 = new HtmlCommandButton();
submitButton1.setValue("Popup window ");

System.out.println("end of test component method");

public String doSubmitTest() {

System.out.println("From method getSubmitTest");

// System.out.println("page level"+ pageLevel);
return "testpage";


Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
I have a few questions.

a) Why don't you use different JSF files for main window and parent window?
b) Are you using "client" mode of state saving?

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
vinod perla

Joined: Jan 06, 2005
Posts: 16
Hi Venkat,

My Application Scenario is like this . We use reflection part to get the fields in the java class. If we have a Object reference/Collections in the class, we are providing a button such that if the user clicks the button , it will display the popup to get the input for the fields in the Object/collection. If it again has a Object reference/collection again popup on top of the popup .

So its a kind of tool like GUI which works out for Insert operation for 20 services . So we are not sure how many jsp's we require at runtime. thats why we are trying to use the same page . Once after getting the full object from the GUI , we will call the data service layer for DB operations . From all the windows( parent &childs) I am saving data to only one object in sessionScope.

Secondly, the "client" mode of state saving you mean is setTransient(true) right ? If I use setTransient is true , then I am unable to bind the components to the object in sessionScope.

I really appreciate your time in this . I am stuck at work now , due to this . I knew the application performance will be too low . But this app we use internally for testing purpose.

Waiting for response. Thanks in advance.

I agree. Here's the link:
subject: Dynamic UI generation problem while opening popup
jQuery in Action, 3rd edition