Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 24th, 2006, 11:45 AM
Registered User
 
Join Date: Jan 2006
Location: Weehawken, New Jersey, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ibsidd Send a message via Yahoo to ibsidd
Default JSP & FRAMES

I have 2 vertically aligned frames. In my left frame I have a drop down listbox populated w/entries from a resultset of a query to a database. When the user selects an entry(option), the entry (parameter) needs to be passed to the right frame.
This is at run time and doesn't use any form or submit button.
What is the best way to do this being each frame should have a jsp page.

Any helpful advice?
Thanks!

Ibrahim Siddiqui
Reply With Quote
  #2 (permalink)  
Old January 28th, 2006, 06:22 AM
Authorized User
 
Join Date: Jan 2006
Location: , , USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to longjava
Default

What you need to do is using javascript from the left frame to notify the right frame each time a user selects a new item from the select object.

Here I wrote a template code of how to notify the right frame from the left frame when there is a rew item is selected. By the way, this code I wrote on-the-fly without testing it so please check the syntax since I might be making mistakes about the syntax.

//File: main.html
<html>
<head>
<script type='text/javascript'>
</script>
</head>
<frameset cols='30%,70%'>
   <frame src='left.jsp' name='left'>
   <frame src='right.jsp' name='right'>
</framset>
<html>

---------------------------------

//File: left.jsp
<html>
<head>
<script type='text/javascript'>
function notifyRightFrameWithNewItemSelected( value )
{
   window.top.frames['right'].updateNewItemSelected( value );
}

function itemSelected()
{
   var oSelect = document.getElementById( 'resultSet' );
   if ( oSelect != null )
   {
      var item = oSelect.options[oSelect.selectedIndex].value;
      notifyRightFrameWithNewItemSelected( item );
   }
}
</script>
</head>
<body>
   <%-- Assume your resultset is a List object containing a collection
        of Strings sending back from the server via request object --%>
   <%
      List resultSet = (List) request.getAttribute( "resultSet" );
   %>
   <select name='resultSet' id='resultSet' onselect='itemSelected()'>
      <%
         if ( resultSet != null && resultSet.size() > 0 )
         {
            for ( int i = 0; i < resultSet.size(); i++ )
        {
           String item = (String) resultSet.get( i );
      %>
               <option value='<%=item%>'><%=item%></option>
      <%
            }
     }
      %>
   </select>
</body>
</html>

---------------------------------

//File right.jsp
<html>
<head>
<script type='text/javascript'>
function updateNewItemSelected( newItem )
{
   document.myForm.resultSetItem.value = newItem;
}
</script>
</head>
<body>
<%-- display a selected item from the left frame in the textbox field --%>
<form name='myForm' id='myForm'>
   <input type='text' name='resultSetItem' value=''>
</form>
</body>
</html>

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
jsp & tomcat aruna_k_2006 JSP Basics 1 March 23rd, 2007 07:16 AM
JSP & Proxy Issue mmcgough JSP Basics 0 March 29th, 2005 11:05 AM
input in html & output in jsp Befekadu Pro JSP 0 March 28th, 2005 10:28 AM
JSP & HTTP Server Request Jstmehr4u3 JSP Basics 0 March 2nd, 2004 06:01 PM



All times are GMT -4. The time now is 03:58 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.