NetUI select adds zero select option

741 views Asked by At

I have following code:

<netui:select dataSource="actionForm.myType" defaultValue="1">
    <netui:selectOption value="1">Not my stuff</netui:selectOption>
    <netui:selectOption value="2">My stuff</netui:selectOption>
    <netui:selectOption value="4">Random</netui:selectOption>
</netui:select>

I am expecting to get only 3 options for drop-down. Instead I am getting option 4, extra one is a 0 - zero and it is selected by default! Where is this zero coming from? How do I get rid of it? I tried to disable the option, I tried to select something else by default but zero option persists and behaves like a default option.

Here is resulting html:

<select name="somePortlet_2wlw-select_key:{actionForm.myType}">
    <option value="1">Not my stuff</option>
    <option value="2">My stuff</option>
    <option value="4">Random</option>
    <option value="0">0</option>
 </select>

P.S: Please no JavaScript work around, I know it is possible but not desirable right now.

1

There are 1 answers

2
Display Name is missing On BEST ANSWER

The solution to the problem ended up being the following:

In the JPF, for the form bean, are you declaring your id like this?

private int id;

If so, try declaring it with a valid value, like:

private int id = 1;

Found via: https://community.oracle.com/thread/803595?start=0&tstart=0