How to create cascading dropdownlist in java

hi,
i am new to java ,i have a employee table that has feilds id,name state city and area. now i have to access employee name based on state city area .i have written console program that displays employee info based on id .now i want a way to acess name by state city and area.ie my program should ask state when i provide state it should display all cities in that state ,then when i select city it should display all area in that city then when i select area it should display all emp name from that area
import java.util.ArrayList;
import java.io.*;
public class Employeelookup {
static ArrayList<Employeelookup> al = new ArrayList<Employeelookup>();
int id;
String name;
String State;
String city;
String Area;
static int count = 0;
Employeelookup()
Employeelookup(int id, String name, String State,String city,String Area)
this.id = id;
this.name = name;
this.State=State;
this.city=city;
this.Area=Area;
count++;
public void SetId(int id)
     this.id=id;
public int getId()
     return id;
public void SetName()
     this.name=name;
public void putDetails(Employeelookup e)
al.add(e);
public Employeelookup getDetails(int id)
Employeelookup es = (Employeelookup)al.get(id);
return es;
public static void main(String[] args ) throws IOException
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Employeelookup e = new Employeelookup();
Employeelookup e1 = new Employeelookup(1, "SaiRam", "karnataka","bangalore","rajajinagar");
Employeelookup e2 = new Employeelookup(2, "Anu", "karnataka","mysore","temple road");
Employeelookup e3 = new Employeelookup(3, "Vasu", "karnataka","bangalore","rajajinagar");
Employeelookup e4 = new Employeelookup(4, "Shillu", "Tamil Nadu","madhurai","b");
Employeelookup e5 = new Employeelookup(5, "Madhu", "Karnataka","shimoga","bus stop");
Employeelookup e6 = new Employeelookup(6, "Volga", "Andra","abc","railway stop");
e.putDetails(e1);     
e.putDetails(e2);
e.putDetails(e3);
e.putDetails(e4);
e.putDetails(e5);
e.putDetails(e6);
System.out.println("The total number of Employeelookups are: " +count);
System.out.println(" ");
while(true)
System.out.println("Enter Employeelookup id to get the Employeelookup details: ");
int id = Integer.parseInt(br.readLine());
boolean flag = false;
for(int i=0; i <al.size();i++)     {
Employeelookup es = e1.getDetails(i);
if(id == es.id)
System.out.println("The details of the Employeelookup with id " id " is: ");
System.out.print(es.id +" " es.name" " es.State" " + es.city+" " es.Area" "+"" );
flag = true;
break;
System.out.println(" ");
if(!flag)
System.out.println("Sorry, no data exists with the id " +id);
System.out.println(" ");
String ch = null;
while(true)
System.out.println("Want to Continue(y/n)?)");
System.out.println(" ");
ch = br.readLine();
if(ch.equalsIgnoreCase("y") || ch.equalsIgnoreCase("n")) break;
if(!(ch.equalsIgnoreCase("y") || ch.equalsIgnoreCase("n")))
System.out.println("Invalid option : please type y/n");
System.out.println(" ");
if(ch.equalsIgnoreCase("n"))
System.out.println(" ");
System.out.println("Thank you");
break;
Edited by: 972831 on Nov 22, 2012 10:50 PM

972831 wrote:
now i want a way to acess name by state city and area.ie my program should ask state when i provide state it should display all cities in that state ,then when i select city it should display all area in that city then when i select area it should display all emp name from that areaWell, where are you stuck? Take the input and see if it's "state", "city" or "area". Then read another input for its name. Then go through all the items you have and check whether there's a match.

Similar Messages

  • How to create web services in java?

    Hi,
    I am a newbie to java webservices. Can anybody tell me how to create web services in java?
    Any tutorial link or step by step doc would be useful.
    Appreciate your help in this regard.
    Thanks in advance.
    naymo01.

    Creating web services in Java appears to depend highly upon the server you intend to use.
    Here's a tutorial: http://java.sun.com/webservices/docs/1.6/tutorial/doc/index.html

  • How to do a dropdownlist in java Swing much like a JMenuBar items

    Hi sir,
    Here i want to know how to do a dropdownlist in java swing much like a JMenuBar items falling from the top to bottom .Here i should not use JMenuBar in any way.
    So that i need to do the dropdownlist by using other feature only.Since i am new to this.I need ur help urgently.Pls do provide the code for this so that i will be so gratefull to u.It is very Urgent.Since i have involved in a project which involves this feature.Pls. do provide the answer as well as the code quickly as possible.
    Thanx
    m.ananthu

    use JComboBox
    http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html

  • How to Create adf table from java bean

    Hi,
    How to Create adf table from java class (Not from ADF BC).
    Thanks
    Satya

    @vlsn -- you have to follow what shay said.
    Do the following in Model layer ::
    create a table property java class with your columns setters and getters like :
    *public class gridProps {*
    private int sno;
    private String orderNum;
    *public void setSno(int sno) {*
    this.sno = sno;
    *public int getSno() {*
    return sno;
    *public void setOrderNum(String orderNum) {*
    this.orderNum = orderNum;
    *public String getOrderNum() {*
    return orderNum;
    Create another table java class which will populate the values to your column values and return the collection :
    *public class gridPopulate {*
    private  List<gridProps> gridValues ;
    *public List<gridProps> setToGrid(ArrayList<ArrayList> valuesToSet) {*
    *if (valuesToSet == null) {*
    return gridValues;
    gridValues = new ArrayList<gridProps>();
    if(btnValue.equals("completeBtn"))
    return gridValues;
    for(ArrayList<String> tempArr:valuesToSet)
    gridProps gp = new gridProps();
    gp.setSno(Integer.valueOf(tempArr.get(0)));
    gp.setOrderNum(tempArr.get(1));
    return gridValues;
    Right click gridPopulate class and create this as data control.This class will be seen in Data control list.Under this data control,Drag the grid property collection(created earlier) to your page.Then execute your binding(gridPopulate) according to your logic.
    Thanks.(My jdev version 11.1.1.5.0)

  • How to run .jar on linux & how to create .jar file using java?

    hi, may i know how to run .jar on linux & how to create .jar file using java? Can u provide the steps on doing it.
    thanks in advance.

    Look at the manual page for jar:
    # man jar
    Also you can run them by doing:
    # java -jar Prog.jar

  • How to create sub domain using java ?

    how to create sub domain using java ?
    for example:
    name1.domainname.com
    name2.domainname.com
    is it possibe ?

    You don't do that using Java.
    Consult the documentation of the application server in question how to configure it. If you're using for example Tomcat 6.0, then you should be consulting this document: [http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html].

  • How to create webservice in Webdynpro java

    Hi Experts,
          I need to develop one application in Visual Composer.Since VC doesn't support coding so i need to create Webservice in webdynpro java and use that webservice in VC.Can any one of you please suggest how to create Webservice in Webdynpro Java.
    Regards,
    Prasanna.

    Hi prasanna,
    Refer this links.
    /people/sridhar.k2/blog/2006/09/12/creating-and-exposing-bapi-as-web-service-and-using-it-in-web-dynpro
    BAPI Exposed as Web Service
    Connect R/3 from Java web application
    Web Dynpro integration with R/3
    http://help.sap.com/saphelp_nw04s/helpdata/en/82/6a0e7bbe744276bf393654b9b576ed/frameset.htm
    Regards,
    karthik.

  • How to use a DropDownList in Java Swing.Its very very Urgent

    Hi Sir,
    Here i need to know how to do (or) create a dropdownlist by using Java Swing.I know that there is JMenuBar & JMenuItems without using that when i click a JButton for example the dropdownlist should come from the top to bottom.I have already posted this quesion once.And i found that it has been removed.So i hope that this time i will get a better answer.Pls.do provide the code as well sir.So that i will be very thankful to u.Since i am involved in a project which contains this
    feature.It is very very Urgent.So pls.do provide the code i will be waiting for the reply.
    Thanx,
    m.ananthu

    use JComboBox
    JComboBox liste = new JComboBox(new Object[]{"azerty","qwerty});the api documentation :
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComboBox.html
    the turotial on combobox :
    http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html

  • How to create a class using java script..

    Hi all,
    Iam new to java script and I tried out the following program but its not working..I basically created a class just like a java prog' but Iam not getting any output or error.Iam attaching the code below.
    If I created one function inside the script and create one object its working fine but what should I do when I have a lot of function??so I created a class and put all the function and created an object but its not working..
    Do let me know what changes should I do..Iam attaching the code which I had written. or give me an example of how to create a class with couple of functions using JAVASCRIPT
    Thanks
    Avis_su
    <html>
    <head><title>JSP Page</title></head>
    <body>
    <SCRIPT language = "JavaScript">
    <!--
    //Created classes
    class book
    var title: String;
    var author:String;
    function author()
    doucument.write("Author is " +this.author);
    function tile()
    doucument.write("Title is " +this.title);
    function printall()
    var counter = 0;
    function author();
    function title();
    var chapters = Array[String];
    for(chapter in this chapters)
    counter++;
    document.write("Chapter" counter" :"+this.chapters[chapter]+"<br>");
    var thisbook = new book()
    thisbook.author = "Sivagami";
    thisbook.title = "MS in CS giude";
    thisbook.chapters = new Array[10];
    thisbook[0] = "Prepare to Excell in all ";
    thisbook[1] = "Learn to be happy";
    thisbook[2] = "Learn to be healthy mentally emotionally physically";
    thisbook[3] = "Siva and Subbu along with kidssssss will be successful in future";
    thisbook.printall();
    //-->
    </script>
    </body>
    </html>

    Run this program to get your answer:
    public class AnswerToYourPost {
    public static void main(String args[]) {
    System.out.println("TRUE/FALSE: This question
    ion belongs on a Java forum.\n"
    + "ANSWER: " + ("Javascript" == "Java"));
    }Since when do we compare objects for equality using operator == ?

  • How to create and instance of Java Object from an XML Document.

    Hi,
    How can we use a XML Document to create an instance of Java Object and do vice versa ie from the Java Object creating the XML Document.
    XML Document is available in the form of a String Object.
    Are there helper class available to achieve this.
    I need to do this in a Servlet.
    Regards
    Pramod.

    JAXB is part of JavaSE while Xmlbeans claims full schema support and full infoset fidelity.
    If the standard APIs do all that you need well then use them.

  • How to create ejbbean in wd-java

    Hi,
    Iam new to Wd-java area.Iam doing the defecttracking application in Webdynpro for java,in that backend is sql server.I want to retrive login details through ejb bean. give me step-by-step coding procedure.i don't know how to create ejb application also.please give me step-by-step.

    Ram,
    Below tutorial may be of some help :- https://www.sdn.sap.com/irj/sdn/webdynpro?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#20
    Chintan

  • How to create dynamic variable in Java?

    Hi,
    I want to create dynamic varible , using ArrayList or Vector. The number of array i dont knwo, so how to create dynamic ArrayList or Vector.
    for example:
    ArrayList1,ArrayList2,ArrayList3.....n
    or
    Vector1,Vector2,Vector3 .....n, the n value i will get at run time, so how to create the dynamic ArrayList or Vector or i can use any other Object in java,
    Pls provide your input.
    Sridhar

    1. I have a HashMap with dataok ... fair enough.
    2. depending on its size, i need to create variable
    to store them.uhm ... why? If you have a variable number of elements in the map then you'd need to generate a variable number of variables (a number, that is not know at compile time, as it seems). Now if you could somehow create those variables, how would you access them? You'd have to generate the code handling them as well ...
    Tell us what kind of data you've got and what you want to do with it. There's certainly a better solution to your problem.
    how to generate variables as per content size of the
    HashMapYou don't.

  • How to display cascaded dropdownlist using MVC4?

    I have two tables in DB to populate cascading dropdownlist. On change of value in first dropdown, second dropdown has to be populated
    using second table. While i tried below code, i am getting the same data for country dropdownlist. countryid is primary key in country table and  it is
    foreign key in state table. First row country id in state table is 6 which corresponds to North America in country table. It displays the same for all 11 rows in country dropdownlist. Please give me right direction?
      public ActionResult Submit()
               List<Country> allcountry= new List<Country>();
               List<State> allstate = new List<State>();
               using (portalconnectionstring pc = new portalconnectionstring())
                    allcountry = pc.countries.OrderBy(a => a.countryname.ToList();
                ViewBag.CountryID = new SelectList(allcountry, "countryid", "countryname");
                ViewBag.StateID = new SelectList(allstate, "stateid", "statename");
                 return View();
                [HttpPost]
                [ValidateAntiForgeryToken]
    public ActionResult Submit(Feedback s) {
     List<Country> allcountry= new List<Country>();
     List<State> allstate= new List<State>();
     using (portalconnectionstring pc = new portalconnectionstring())
                   allcountry= pc.countries.OrderBy(a => a.countryname).ToList();
                   if (s != null && s.towerid > 0)
                        allstate= pc.states.Where(a => a.countryid.Equals(s.countryid)).OrderBy(a => a.statename).ToList();
     ViewBag.CountryID = new SelectList(allcountry, "countryid", "countryname", s.countryid);
              ViewBag.StateID = new SelectList(allstate, "stateid", "statename", s.stateid);
     if (ModelState.IsValid)
                        using (portalconnectionstring pc = new portalconnectionstring())
                            using (NpgsqlCommand pgsqlcommand = new NpgsqlCommand("ddltest", conn))
     pgsqlcommand.CommandType = CommandType.StoredProcedure;
     pgsqlcommand.Parameters.Add(new NpgsqlParameter("countryname", NpgsqlDbType.Varchar));
                            pgsqlcommand.Parameters.Add(new NpgsqlParameter("statename", NpgsqlDbType.Varchar));
      pgsqlcommand.Parameters[0].Value = model.countryname;
                            pgsqlcommand.Parameters[1].Value = model.statename;
     pgsqlcommand.ExecuteNonQuery();
                            ViewBag.Message = "Successfully submitted";
                    else
                        ViewBag.Message = "Failed! Please try again";
                    return View(s);
                [HttpGet]
                public JsonResult GetStates(string countryid = "")
                    List<State> allstate= new List<State>();
                    int ID = 0;
                    if (int.TryParse(countryid, out ID))
                        using (portalconnectionstring dc = new portalconnectionstring())
                            allstate = dc.states.Where(a => a.countryid.Equals(ID)).OrderBy(a => a.statename).ToList();
                    if (Request.IsAjaxRequest())
                        return new JsonResult
                            Data = allstate,
                            JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    else
                        return new JsonResult
                            Data = "Not valid request",
                            JsonRequestBehavior = JsonRequestBehavior.AllowGet
    cshtml:
    @model mvcdemo.Models.Feedback
        ViewBag.Title = "Submit";
    <h2>Submit</h2>
    @using (Html.BeginForm("Submit","cascadedddl",FormMethod.Post)) {
        @Html.ValidationSummary(true)
        @Html.AntiForgeryToken()
        <fieldset>
            <legend>Feedback</legend>
     <div class="editor-label">
                @Html.LabelFor(model => model.countryid)
            </div>
            <div class="editor-field">
                 @Html.DropDownListFor(model => model.countryid,@ViewBag.CountryID as SelectList,"Select country")
                @Html.ValidationMessageFor(model => model.countryid)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.stateid)
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(model => model.stateid, @ViewBag.StateID as SelectList, "Select state")
                @Html.ValidationMessageFor(model => model.stateid)
            </div>
     <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>
                    <script type="javascript">
                        $(document).ready(function () {
                            $("#countryid").change(function () {
                                var countryID = parseInt($("#countryid").val());
                                if (!isNaN(countryID)) {
                                    var ddstate = $("#stateid");
                                    ddstate.empty(); 
                                    ddstate.append($("<option></option").val("").html("Select State"));
                                    $.ajax({
                                        url: "@Url.Action("GetState","cascadedddl")",
                                        type: "GET",
                                        data: { countryID: countryid },
                                        dataType: "json",
                                        success: function (data) {
                                            $.each(data, function (i, val) {
                                                ddstate.append(
                                                        $("<option></option>").val(val.stateid).html(val.statename)
                                        error: function () {
                                            alert("Error!");
                    </script>

    Please post questions related to ASP.NET in the ASP.NET forums (http://forums.asp.net ).

  • How to create trusted emails in java

    Hey guys, I need to create trusted emails with java using 509 certifications, can anyone tell me how can i do this or perhaps give me some direction?
    Thanks on advance.

    Hi,
    what is a textbox, a JTextField? What is the datasource?
    Here are a few links to give you a better start this time:
    [Forums FAQ|http://wikis.sun.com/display/SunForums/Forums.sun.com+FAQ]
    [Getting started|http://wikis.sun.com/display/SunForums/Tips]
    And very important:
    [How to ask smart questions|http://catb.org/~esr/faqs/smart-questions.html]

  • How to create motif Region in Java???

    How can u create Motif Region In Java or Java Swing???
    If you know, please let me know.
    thanks
    Amit

    Regions in motif are arbitrary set of pixel locations. You can locate a point or rectange in a region.

Maybe you are looking for

  • Mini Displayport to Composite/S-Video

    I found a new converter/adapter to convert from Mini Displayport to Composite/S-Video enabling connection of Macbook Pro/Air to an analog TV: http://www.lenkeng.net/Html/Product/DisplayPort-to-Composite-Video-Converter.htm l http://www.gamezhome.com/

  • Using RTTI in table type any

    Hello, i have table type any and i want to know in the loop for every field which type he have ,for instance for field type Date8. what i the best way to do so , i guess that I need to use for instance cl_abap_elemdescr=>get_data_type_kind( <lv_field

  • BSOD on shutdown - Platinum

    Hi, Just built a computer which 80% of the time BSOD's when i shutdown. Instead of shutting down normally it flashes blue then restarts. I sent the error report to microsoft after a serious error msg when i restarted from a bsod and it came up with a

  • How to POST to wiki server through atompub?

    Hi all, I'm trying to use curl to post a new entry to the leopard wiki server through the Atom Publishing Protocol, but I'm not sure if I POSt to the correct address. My server runs Mac OS 10.5 Server. Here's the POST command: curl "http://server.app

  • Lost in Migration

    I've just purchased my first Mac, Macbook Pro 17" ; yea it's a size thing.  Anyway i transferd all files eg; photos music to the Mac using the migration tool after 49 min I can't locate any files, what did I do wrong.