Solved

Pop up using struts

Posted on 2006-07-04
5
665 Views
Last Modified: 2013-11-28
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','height=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("selectedItem") in the action class.
0
Comment
Question by:rmvprasad
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 17037715
> My doubt is how to pass this selected item as a parameter to popup.do

You can do

onclick="passSelected(this.yourformname.selectedItem.value)" and this should get you the value in the input with the name "selectedItem"
0
 

Author Comment

by:rmvprasad
ID: 17037815
Thoe I am using a form data is not accessed through form as it is stored in valueobjects/transferobjects which is declared inside the form. Data is displayed in table not in controls as textbox

will not the statement req.getParameter("selecteditem" ) declared in action class work.
0
 
LVL 35

Expert Comment

by:girionis
ID: 17037863
> 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='+<%=<your struts variable here>%>;
      window.open('url','New','height=600,width=600',200,200);
}

> will not the statement req.getParameter("selecteditem" ) 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.getParameter("selecteditem" )%>;
      window.open('url','New','height=600,width=600',200,200);
}

but you will have to set the "selectedItem" value from a *previous* page.
0
 

Author Comment

by:rmvprasad
ID: 17037917
Thanks for the real good answer. One last question

Will the statement

var url='popup.do?selectedItem='+<%=req.getParameter("selecteditem" )%>;

pass the value of the selected item to popup.do, as I need it in popup.do. If no how to.
0
 
LVL 35

Accepted Solution

by:
girionis earned 50 total points
ID: 17037935
> pass the value of the selected item to popup.do, as I need it in popup.do

It will if the parameter "selectedItem" comes from a *previous* page (i.e. when you did the request), if in the same page as the JavaScript code you have a "selectedItem" parameter and you want to get this then you will not be able to do it using the "req" object. You will have to use JavaScript.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now