• 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

problem with the popup

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

My requirement is,i have one JSP page ,namely welcome.jsp.in that there is one button "addcontact".when i click on that one,a pop-up of addcontact.jsp should come.and after entering the details and clicks on ADD button ,that popup should vanish and whatever the contacts we have added before should come to the contact list automatically!

This is my code (welcome.jsp):


%@ taglib uri="/tags/struts-bean" prefix="bean" %
%@ taglib uri="/tags/struts-html" prefix="html" %
%@ taglib uri="/tags/struts-logic" prefix="logic" %
%@page import="java.util.*" %

html

head
title welcome page /title
/head
script type="text/javascript"
function addcontact()
{
addcontactwindow=window.open("addcontact.jsp","addcontactwindow","status=1,scrollbars=1,resizable=1");
addcontactwindow.moveTo(2,2);
}
/script body
html:errors/
h2 welcome /h2 %=session.getAttribute("ausername")%
h2 MyProfile /h2
NAME %=session.getAttribute("ausername")%
EMAIL %=session.getAttribute("aemail")%
h2 Contacts /h2
logic:iterate id="person" name="arll"
logic:iterate id="details" name="person"
bean:write name='details' property='key'
bean:write name='details' property="value"
/logic:iterate
/logic:iterate
INPUT TYPE="button" VALUE="Add Contact" onklick="addcontact()"
/body
/html



With this code ,when i clicks on add button,another window is coming and saying that"you are successfully added the contact",

here what i want is instead of that,that popup should close and that contacts must automatically adds in the contact list.

How can i do that?give me a suggestion

Regards,
sreelakshmi.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was unable to find a property "contact list".
You can pass the value from the pop-up using

window.opener

for example. on clicking the ADD button in addcontact.jsp , you may call a js function addContact() where you can try something like this.

window.opener.document.getElementById("id").value="<values read from the pop-up>"

This will pass the value to the main page.

or else submit your values from the pop-up and reload the page welcome.jsp with the new values added.


-HTH

Go through this link http://www.javascriptkit.com/javatutors/remote2.shtml
[ September 18, 2007: Message edited by: Ranjit Gopinathan ]
 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd use a faux popup...an inline div. Display the other JSP and an include in the div. Then when the button is acted upon in the div you could do an inline refresh on the main page.
 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you ranjit,

my addcontact.jsp page is like this

%@ taglib uri="/tags/struts-bean" prefix="bean" %
%@ taglib uri="/tags/struts-html" prefix="html" %
html:html
headtitleAddContact page /title/head
script type="text/javascript"
function add()
{

self.close();

}
/script

body

html:form action="/addform.do"
html:errors/
b Name /b
html:text property="name"/ br
b email /b
html:text property="email"/ br
b phno /b
html:text property="phno" / br

html:submit value="add" onklick="add()"/
/html:form

/body
/html:html

and i gave my welcome.jsp before,here how can i made changes in addcontact,jsp inorder to change (add contacts) the welcome.jsp?

Regards,
sreelakshmi
 
Ranjit Gopinathan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inside the js function add() ,
use window.opener to pass the value back to the welcome page.
 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranjit,

I tried it in the same way.here is my addcontact.jsp

%@ taglib uri="/tags/struts-bean" prefix="bean" %
%@ taglib uri="/tags/struts-html" prefix="html" %
html:html
headtitleAddContact page /title/head
script type="text/javascript"
function add()
{
window.opener.document.getElementById("name").value="name"
window.opener.document.getElementById("email").value="email"
window.opener.document.getElementById("phno").value="phno"
self.close();

}
/script

body

html:form action="/addform.do"
html:errors/
b Name /b
html:text property="name"/ br
b email /b
html:text property="email"/ br
b phno /b
html:text property="phno" / br

html:submit value="add" onklick="add()"/
/html:form

/body
/html:html


now also there is no change.same thing repeats.and after clicks on add button,popup is not disappearing.
please make me clarify!

Thank you,

Regards,
sreelakshmi.
 
Ranjit Gopinathan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For you to do window.opener.document.getElementById("name").value="name"
welcome.jsp needs an html element with id="name"
eg: a <html:text property="" name="" styleId="name"/>

What window.opener.document.getElementById("name").value="name" does is
It pass the value(name) to the window.opener(welcome.jsp here) and assign it to an element with id "name" in welcome.jsp.

I assume that there is no element in welcome.jsp with id="name"

To pass value from addcontact.jsp , try something like this.
In welcome.jsp have a html element ( text or hidden field) with an id "name".
In addcontact.jsp
<html:text property="name" styleId="nameId"/>
In add() function
window.opener.document.getElementById("name").value=
document.getElementById("nameId").value;
 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranjit,

Thank you very much!

i made the changes like what you have been said.now i got exception:

org.apache.jasper.JasperException: /welcome.jsp(36,0) Attribute phno invalid for tag text according to TLD
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



my welcome.jsp is:


%@ taglib uri="/tags/struts-bean" prefix="bean" %
%@ taglib uri="/tags/struts-html" prefix="html" %
%@ taglib uri="/tags/struts-logic" prefix="logic" %
%@page import="java.util.*" %

html

head
title wlcome page /title
/head
script type="text/javascript"
function addcontact()
{
addcontactwindow=window.open("addcontact.jsp","addcontactwindow","status=1,scrollbars=1,resizable=1");
addcontactwindow.moveTo(2,2);


}
/script



body

html:errors/

h2 welcome /h2<%=session.getAttribute("ausername")%
h2MyProfile h2

NAME %=session.getAttribute("ausername")%

EMAIL %=session.getAttribute("aemail")%
h2Contacts/h2
html:text property="" name="" styleId="name"/
html:text property="" phno="" styleId="phno"/
html:text property="" email="" styleId="email"/
INPUT TYPE="button" VALUE="Add Contact" onklick="addcontact()"/
/body
/html



my addcontact.jsp is:

%@ taglib uri="/tags/struts-bean" prefix="bean" %
%@ taglib uri="/tags/struts-html" prefix="html" %
html:html
headtitleAddContact page/title/head
script type="text/javascript"
function add()
{
window.opener.document.getElementById("name").value=
document.getElementById("nameId").value;
window.opener.document.getElementById("phno").value=
document.getElementById("phnoId").value;
window.opener.document.getElementById("email").value=
document.getElementById("emailId").value;

window.close();


}
/script


body

html:form action="/addform.do"
html:errors/
bName/b
html:text property="name" styleId="nameId"/br
bemail/b
html:text property="email" styleId="emailId"/br
bphno/b
html:text property="phno" styleId="phnoId"/br

html:submit value="add" onklick="add()"/
/html:form>
/body
/html:html

please look into that and let me know the mistake i made!

Thankyou,

Regards,
sreelakshmi
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ummm...the error message (Attribute phno invalid for tag text) sure seems self explanatory to me. I suspect that this is line 36 of welcome.jsp:

html:text property="" phno="" styleId="phno"/


BTW, the formatting of your post is very hard to read. Do you have a bunch of html:text tags with empty property and name attributes? Why?

- Brent
 
Ranjit Gopinathan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
html:text property="" name="" styleId="name"/
html:text property="" phno="" styleId="phno"/
html:text property="" email="" styleId="email"/

For html:text there is no attribute named phno or email.Thatz the reason for the exception.
Refer http://struts.apache.org/1.x/struts-taglib/tlddoc/html/text.html for more info.

The example should be customized according to your requirement than copy pasting it.
 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranjit,

As i am very new to struts and java,i supposed to do that.i do never repeat like this.

However i am facing same problem still now.how can i resolve that?
Thank you,
Regards,
sreelakshmi.
 
Ranjit Gopinathan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please check your Private Messages My Profile
 
reply
    Bookmark Topic Watch Topic
  • New Topic