Skip to Content
author's profile photo Former Member
Former Member

Changing the value of the dropdownListBox as per the selection of the previ

Hi all,

there are three dropdownListBox in my application.

if i select the listitem from first dropdownlistbox accordingly the listitems of the second dropdownlistbox should be updated.

for eg: if i select vegetables in my first dropdownlistbox then accordingly the second dropdownlistbox should get the vegetable names from the vegetable table in the database and display....and so on...

if i select fruits in my first dropdownlistbox then accordingly the second dropdownlistbox should get the fruits names from the fruits table in the database and replace the vegetable list before and display......

kindly help me in this regard.

regards,

Joshua

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 21, 2005 at 07:25 AM

    From what I understood you need to know how to update those dropdownListBoxes, isn't it?

    If these is your question, here's what you have to do:

    If you create the dropdownListBoxes in jsp, the htmlb tag dropdownListBox has an atribute <b>onSelect</b>. If you create the dropdownListBoxes in java there is a method in DropdownListBox class named <b>setOnSelect</b>.

    The value has to be the name of a function where you will define the action that will be processed when the user clicks on the enabled dropdownListbox. If for example the name you have chosen is <i>selectFirstList</i>, in the class that extends JSPDynPage you will need to have

    public void selectFirstList(Event event) throws PageException

    or

    public void onSelectFirstList(Event event) throws PageException

    In this function you will have to acces the database, obtain the result and pass it to the dropDownListBox. You will also need to create a model for the dropdownListBox.

    My suggestion is to consult the java development content. There you will find some examples.

    For the htmlb tags check this site: http://www.sapdesignguild.org/resources/htmlb_guidance/index.html

    Hope I made my self understood and Good Luck.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 21, 2005 at 07:29 AM

    Hi Joshua,

    When you define your drop down list box, use something like this;

    <code>

    DropdownListBox myDd = new DropdownListBox("myDd");

    myDd.setModel(getListModel());

    myDd.setOnSelect("onFolderSelect");

    </code>

    because you've set a 'setOnSelect', when your user selects something from the dropdown an event occurs and the iView is refreshed. I'm sure you know that much already.

    You can see that the drop down model is being assigned from a method, this method will obviously return a DefaultListModel. Inside just have some logic that determines what the DefaultListModel that is returned contains.

    <pseudo-code>

    if(dropdown1.getSelection()==fruit){

    return a ListModel containing fruit;

    }else if(dropdown1.getSelection()==vegetables){

    return a ListModel containg vegetables;

    </pseudo-code>

    I hope this helps,

    Patrick.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.