Wrox Home  
Search P2P Archive for: Go

  Return to Index  

j2ee thread: Dynamic Drop Down Menu in a Java Bean


Message #1 by "F Younus" <fy8674@s...> on Wed, 13 Nov 2002 20:06:21
Faisal,

The method return type is public ResultSet but your returning
a String (sendBack).

Brenda




>From: "F Younus" <fy8674@s...>
>Reply-To: "Java 2 Enterprise Edition" <j2ee@p...>
>To: "Java 2 Enterprise Edition" <j2ee@p...>
>Subject: [j2ee] Dynamic Drop Down Menu in a Java Bean
>Date: Wed, 13 Nov 2002 20:06:21
>
>I am trying to create a dynamic drop down menu for a JSP Page. Below is
>the code for the Java Bean Method. I am receiving following error.
>
>
>C:\j2sdk1.4.0_02\bin>javac Rpm.java
>Rpm.java:178: incompatible types
>found : java.lang.String
>required: java.sql.ResultSet
>return sendBack;
>^
>1 error
>
>I am thinking that I need to create another method to request the sendBack
>variable. Please let me know if you have any suggestions.
>
>Thanks, Faisal-
>
>
>
>public ResultSet dropDownMenu(String objectName, String switchVar, String
>luTableName, String luTableFieldDescription, String luTableFieldId) {
>//String rsdropDownMenu=null;
>ResultSet rsdropDownMenu=null;
>String sendBack = null;
>if (switchVar.equals("update")){
>//UPDATE Mode
>//sendBack = sendBack + "<option value=\"" + luTableFieldId + "\">" +
>luTableFieldDescription + "</option> \n";
>}else if (switchVar.equals("add")){
>// ADD Mode
>sendBack = "<select name="+objectName+"> \n";
>
>connect();
>String queryString;
>queryString = "SELECT " + luTableFieldId + ", " + luTableFieldDescription
>+ " FROM " + luTableName ;
>Statement stmt = con.createStatement();
>rsdropDownMenu = stmt.executeQuery(queryString);
>
>while (rsdropDownMenu.next()) {
>//loop
>sendBack = sendBack + "<option value=\"" + rsdropDownMenu.getString("ID")
>+ "\">" + rsdropDownMenu.getString("DESCRIPTION") + "</option> \n";
>}
>
>sendBack = sendBack + "</select> \n";
>disconnect();
>}else{
>// VIEW Mode
>//sendBack = "<textarea name="+objectName+" cols="+colSize+"
>rows="+rowSize+">"+objectValue+"</textarea>";
>}
>return sendBack;
>}


_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 
http://join.msn.com/?page=features/virus


  Return to Index