?
Solved

listbox - action

Posted on 2005-03-25
11
Medium Priority
?
1,907 Views
Last Modified: 2008-01-09
I have a jsp page with three frames (3 jsp pages) . I have a list box in top frame, when I select a value it shud perform an struts action and data shud be displayed in the second frame.

1) how to get selected value from list box to action class?
String listItem =request.getParameter(listbox) ;

if(listItem.equals("200000")
{
 mapping.findForward("frame2");
}      

is this the correct procdure??
      

2) how to forward the page to second frame only?


thanks a lot
0
Comment
Question by:johnson100
[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
  • 6
  • 3
  • 2
11 Comments
 
LVL 92

Assisted Solution

by:objects
objects earned 800 total points
ID: 13634626
you need to specify the target frame in your form tag
0
 
LVL 5

Expert Comment

by:Triguna
ID: 13635987
For getting the selected value,

   listBox.selectedValue;

and as you have choosen the request.getParameter, it will come as you selected in the Combo.

And for forwarding,

use response.forward(response.encodeURL("frame2"));

and offcourse if you want to display the output in the target frame, you need to specify the target as said above.
0
 

Author Comment

by:johnson100
ID: 13647825
thanks all of u.


below is my jsp page select code and javascript code. Depending up on the value selected I will do validation in action class. But when ever I select a value in the list box , value automatically dissappears and could not perform the validation cos it come back to the default space(empty value). like when I select 002000, it always come back to empty.


<td>
<SELECT NAME="list" onChange="selectedKey()">
<option value=""></option>
<option value="001000">001000</option>
<option value="002000">002000</option>
<option value="003000">003000</option>
<option value="004000">004000</option>
<option value="005000">005000</option>
</select>
</td>


<script language="javascript">            
function selectedKey()
{
   document.form1.submit();
}
</script>
      
      
      
}




0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:johnson100
ID: 13647826
how to make the value stay in the list box when selected??


thanks a lot
0
 
LVL 92

Expert Comment

by:objects
ID: 13648484
> like when I select 002000, it always come back to empty.

When exactly is this occurring?
Isn't your forms target a different frame?
0
 
LVL 5

Accepted Solution

by:
Triguna earned 1200 total points
ID: 13649483
Offcourse it will display the first value as you are submitting to the same form.

in your script, what you want? Whether to go to the selected page or selcted item must show as an alert message.

Whatever you choose, if you write the form1.submit() it will goto that page.

So avoid writing form1.submit() in the selectedKey function.
0
 

Author Comment

by:johnson100
ID: 13653064
I will make it clear.

I have three frames in a page. In first frame there is a list box and depending up on the listbox selected value an action is performed(action class) and mapping.findforward("2ndframe.jsp") forwards the required page to the second frame.
In the action class I am checking for the selected value and  if the value is not null I am forwarding the required page to second frame or else forwarding an empty page to second frame.
 
If I remove the form1.submit the value stays but the action class can not be called!!

How do i do?


Thanks a lot
0
 
LVL 92

Expert Comment

by:objects
ID: 13656871
is the form response displaying in the 2nf frame ok?
0
 

Author Comment

by:johnson100
ID: 13657549
yes it is displaying in the second frame, but the value from the textbox dissappears! I want the selected value to be displayed.


many thanks
0
 

Author Comment

by:johnson100
ID: 13657817
yes it is displaying in the second frame, but the value from the listtbox dissappears! I want the selected value to be displayed.

thanks

0
 

Author Comment

by:johnson100
ID: 13666382
i got it! u can do it by using jstl conditional statements before loading the same page

thanks all of u.
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

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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