How to fill a DropDownList with custom options?

View: New views
7 Messages — Rating Filter:   Alert me  

How to fill a DropDownList with custom options?

by q5616417 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I want to populate a DropDownList in netbeans 6.0.1 with values from a custom array. I tried to create an adaequate property in the application bean, but "Add" is greyed out in the context menu. It's the same when I try to do it within the session bean.
So, how can I populate the DropDownList with my own values?
Best regards
Thomas

Re: How to fill a DropDownList with custom options?

by Roy Abu Bakar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i gave u an example (in your ApplicationBean1)

private String[] status;

public String[] getStatus() {
    return status;
}

private Option[] statusOptions;

public Option[] getStatusOptions() {
    return statusOptions;
}

public void init() {
        this.status = new String[]{"Enabled", "Disabled"                };
        this.statusOptions = new Option[this.status.length];
        for (int i = 0; i < getStatus().length; i++) {
            statusOptions[i] = new Option(getStatus()[i]);
        }
}

Re: How to fill a DropDownList with custom options?

by q5616417 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you a lot. Of course this works. Do you have any idea why the "add"-item in the context-menu of the beans is not activated?

Re: How to fill a DropDownList with custom options?

by Roy Abu Bakar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I dunno, but you can try Configure Default Options in the context-menu to add item.

q5616417 wrote:
Thank you a lot. Of course this works. Do you have any idea why the "add"-item in the context-menu of the beans is not activated?

Re: How to fill a DropDownList with custom options?

by Roy Abu Bakar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I dunno, but you can add item via Configure Default Options in the
context-menu


q5616417 wrote:
>
> Thank you a lot. Of course this works. Do you have any idea why the
> "add"-item in the context-menu of the beans is not activated?
>

--
View this message in context: http://www.nabble.com/How-to-fill-a-DropDownList-with-custom-options--tp16444465p16480025.html
Sent from the Visual Web - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: How to fill a DropDownList with custom options?

by Rick Fincher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You don't use the add menu for that.  Right-click on the dropdown list
in the visual editor and select: "Configure Default Options..."

A dialog box will pop up that lets you enter both the display (what you
see on the screen) and value (what gets returned by the getValue()
method) items for each menu entry.  You can also select items to be
selected by default and enable multiple selections in this dialog.

You can also add options like this:
dropDownPriceDefaultOptions.setOptions(new
com.sun.rave.web.ui.model.Option[]{new
com.sun.rave.web.ui.model.Option("1000", "$1,000"), new
com.sun.rave.web.ui.model.Option("2000", "$2,000"));

Be aware that the value comes first, then the label in the new Option
constructor, the opposite of the dialog box in the visual editor.

You can set the selected option via:

dropDownPriceDefaultOptions.setSelectedValue("1000");

That can be an array for multiple selections if multiple is enabled.

Rick
       

Roy Abu Bakar wrote:

> I dunno, but you can try Configure Default Options in the context-menu to add
> item.
>
>
> q5616417 wrote:
>  
>> Thank you a lot. Of course this works. Do you have any idea why the
>> "add"-item in the context-menu of the beans is not activated?
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: How to fill a DropDownList with custom options?

by HandyGeek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Rick,
I am using NB6.0.1, and the "Configure Default Options..." displays for
the Radio Button Group as you state below; but does not exist for the
Drop Down box.  Were you aware of this behavior, or is my NB
installation messed up?
/David

Rick Fincher wrote:

> You don't use the add menu for that.  Right-click on the dropdown list
> in the visual editor and select: "Configure Default Options..."
>
> A dialog box will pop up that lets you enter both the display (what
> you see on the screen) and value (what gets returned by the getValue()
> method) items for each menu entry.  You can also select items to be
> selected by default and enable multiple selections in this dialog.
>
> You can also add options like this:
> dropDownPriceDefaultOptions.setOptions(new
> com.sun.rave.web.ui.model.Option[]{new
> com.sun.rave.web.ui.model.Option("1000", "$1,000"), new
> com.sun.rave.web.ui.model.Option("2000", "$2,000"));
>
> Be aware that the value comes first, then the label in the new Option
> constructor, the opposite of the dialog box in the visual editor.
>
> You can set the selected option via:
>
> dropDownPriceDefaultOptions.setSelectedValue("1000");
>
> That can be an array for multiple selections if multiple is enabled.
>
> Rick
>      
> Roy Abu Bakar wrote:
>> I dunno, but you can try Configure Default Options in the
>> context-menu to add
>> item.
>>
>>
>> q5616417 wrote:
>>  
>>> Thank you a lot. Of course this works. Do you have any idea why the
>>> "add"-item in the context-menu of the beans is not activated?
>>>
>>>    
>>
>>  
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...