• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic UI generation problem while opening popup

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :

ToTest.jsp=====>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%-- jsf:pagecode language="java" location="/src/pagecode/pages/ToTest.java" --%><%-- /jsf:pagecode --%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Totest</title>
<link rel="stylesheet" type="text/css"
href="<%=request.getContextPath()%>/styles/style.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"
title="Style">
</head>

<f:view>
<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}"
></h:panelGrid>

</h:form>
</hx:scriptCollector>
</body>
</f:view>
</html>


===========================================================================

ToTest.java ( 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);
testComponent();
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()
.getApplication();
facesContext = FacesContext.getCurrentInstance();
//facesContext.getViewRoot().setTransient(true);
htmlPanelGrid.getChildren().clear();

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


if(this.getSessionScope().get("Reference")==null){
this.getSessionScope().put("Reference", new Reference());
System.out.println("created Reference obj in session");


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

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

htmlPanelGrid.setColumns(2);
if ( testing !=null && testing.equals("one")){


HtmlOutputLabel arrestType = new HtmlOutputLabel();
arrestType.setValue("ArrestType");
HtmlInputText htmlInputText = new HtmlInputText();
ValueBinding InenameBinding = application
.createValueBinding("#{sessionScope.Reference.arrestType}");
IntegerConverter conv = new IntegerConverter();
htmlInputText.setConverter(conv);
htmlInputText.setValueBinding("value", InenameBinding);
htmlPanelGrid.getChildren().add(arrestType);
htmlPanelGrid.getChildren().add(htmlInputText);
System.out.println("executed if block");

}else{

HtmlOutputLabel officerId = new HtmlOutputLabel();
officerId.setValue("OfficerId");
HtmlInputText htmlInputText1 = new HtmlInputText();
ValueBinding lnameBinding = application
.createValueBinding("#{sessionScope.Reference.officerId}");
htmlInputText1.setId("officerId");

htmlInputText1.setValueBinding("value", lnameBinding);
htmlPanelGrid.getChildren().add(officerId);
htmlPanelGrid.getChildren().add(htmlInputText1);
System.out.println("executed else block");
}


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

String javaScriptText = "window.open('"
+ "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 ");
submitButton1.setOnclick(javaScriptText);
htmlPanelGrid.getChildren().add(submitButton1);


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";

}

}
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
vinod perla
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


regards,
Vinod
 
Popeye has his spinach. I have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic