rmvprasad
asked on
Pop up using struts
I am new to struts. I need to generate a popup window and pass values to it using struts.
I found the following code on net
javascript function onclick="passSelected()"
<input type="hidden" name="selectedItem" value=""/>
function passSelected(var)
{
alert(var);
var url='popup.do?selectedItem ='+var;
window.open('url','New','h eight=600, width=600' ,200,200);
}
My doubt is how to pass this selected item as a parameter to popup.do. in the above function it is passing as a url. Can I directly access this in the action class. or do I need to use some statement as
req.getParameter("selected Item") in the action class.
I found the following code on net
javascript function onclick="passSelected()"
<input type="hidden" name="selectedItem" value=""/>
function passSelected(var)
{
alert(var);
var url='popup.do?selectedItem
window.open('url','New','h
}
My doubt is how to pass this selected item as a parameter to popup.do. in the above function it is passing as a url. Can I directly access this in the action class. or do I need to use some statement as
req.getParameter("selected
ASKER
Thoe I am using a form data is not accessed through form as it is stored in valueobjects/transferobjec ts which is declared inside the form. Data is displayed in table not in controls as textbox
will not the statement req.getParameter("selected item" ) declared in action class work.
will not the statement req.getParameter("selected
> Data is displayed in table not in controls as textbox
Then you will need ot fill the value using other means, something like
javascript function onclick="passSelected()"
function passSelected()
{
alert(var);
var url='popup.do?selectedItem ='+<%=<you r struts variable here>%>;
window.open('url','New','h eight=600, width=600' ,200,200);
}
> will not the statement req.getParameter("selected item" ) declared in action class work.
This will use the request object. You could use that as well by doing
javascript function onclick="passSelected()"
function passSelected()
{
alert(var);
var url='popup.do?selectedItem ='+<%=req. getParamet er("select editem" )%>;
window.open('url','New','h eight=600, width=600' ,200,200);
}
but you will have to set the "selectedItem" value from a *previous* page.
Then you will need ot fill the value using other means, something like
javascript function onclick="passSelected()"
function passSelected()
{
alert(var);
var url='popup.do?selectedItem
window.open('url','New','h
}
> will not the statement req.getParameter("selected
This will use the request object. You could use that as well by doing
javascript function onclick="passSelected()"
function passSelected()
{
alert(var);
var url='popup.do?selectedItem
window.open('url','New','h
}
but you will have to set the "selectedItem" value from a *previous* page.
ASKER
Thanks for the real good answer. One last question
Will the statement
var url='popup.do?selectedItem ='+<%=req. getParamet er("select editem" )%>;
pass the value of the selected item to popup.do, as I need it in popup.do. If no how to.
Will the statement
var url='popup.do?selectedItem
pass the value of the selected item to popup.do, as I need it in popup.do. If no how to.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can do
onclick="passSelected(this