[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Pop up using struts

Posted on 2006-07-04
5
Medium Priority
?
688 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Suggested Courses

650 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