Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

listbox - action

Posted on 2005-03-25
11
Medium Priority
?
1,920 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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Machine Learning is one of the profound applications of AI and therefore, just like AI, it is surrounded by myths and fears. Check out these facts about ML that demystify the related myths.
In my humble opinion (IMHO), TouchDown from Symantec is the best in class for this type of application, but Symantec has end-of-lifed it and although one can keep using it, it will no longer be supported or upgraded.  Time to look for alternatives t…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses

564 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