javaeetutorial
  1. javaeetutorial
  2. JAVAEETUTORIAL-121

technically unspecified default is unspecified not first item

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.7-5
    • Fix Version/s: 7.0.1
    • Component/s: doc
    • Labels:
      None

      Description

      In the second to last paragraph under the "Displaying a Menu Using the h:selectOneMenu Tag" section of the "Adding Components to a Page Using HTML Tags" page at http://docs.oracle.com/javaee/6/tutorial/doc/bnarf.html, it indicates that, "If you don't provide a value, the first item in the list is selected by default." However, this is inaccurate. I have tested this out, and it renders as a <select> element with nested <options>. No <option> is marked as selected. If you look at the HTML 4.01 specification under section 17.6.1 at http://www.w3.org/TR/html4/interact/forms.html#h-17.6.1, you will see that it indicates that "If no OPTION element has the selected attribute set, user agent behavior for choosing which option is initially selected is undefined."

        Activity

        Hide
        Brant Gurganus added a comment -

        This unspecified selection issue also occurs in the following "Displaying Components for Selecting Multiple Values" section as well.

        Show
        Brant Gurganus added a comment - This unspecified selection issue also occurs in the following "Displaying Components for Selecting Multiple Values" section as well.
        Hide
        Kim Haase added a comment -

        I've tried this, and JSF does consider the first item as selected if you use a selectOneMenu tag – but not if you use selectOneListbox or selectOneRadio. (If you output the selected values on a response page, you can see the effect.)

        Show
        Kim Haase added a comment - I've tried this, and JSF does consider the first item as selected if you use a selectOneMenu tag – but not if you use selectOneListbox or selectOneRadio. (If you output the selected values on a response page, you can see the effect.)
        Hide
        Brant Gurganus added a comment -

        JSF considering the first item as selected is incorrect. It is the browser making that judgment. If you look at the HTML specification excerpt, nothing requires the first option to be the selected one. Most browsers will do so though. Because of the implementation detail, the first item gets submitted as the value. It's not a blank value being submitted. However, that is not JSF doing so. That is the browser doing so. Some browsers might pick the third option instead. There's no requirement that it be the first item.

        If you were correct, an <h:selectOneMenu> with no value would render as:
        <select><option selected="selected">a</option><option>b</option></select>

        Instead, it renders as:
        <select><option>a</option><option>b</option></select>

        That second rendering leaves you in unspecified territory for which item to select initially.

        Show
        Brant Gurganus added a comment - JSF considering the first item as selected is incorrect. It is the browser making that judgment. If you look at the HTML specification excerpt, nothing requires the first option to be the selected one. Most browsers will do so though. Because of the implementation detail, the first item gets submitted as the value. It's not a blank value being submitted. However, that is not JSF doing so. That is the browser doing so. Some browsers might pick the third option instead. There's no requirement that it be the first item. If you were correct, an <h:selectOneMenu> with no value would render as: <select><option selected="selected">a</option><option>b</option></select> Instead, it renders as: <select><option>a</option><option>b</option></select> That second rendering leaves you in unspecified territory for which item to select initially.
        Hide
        Kim Haase added a comment -

        Thanks, Brant. I expect you are correct and am checking with the spec leads to confirm, since the misinformation has been in the tutorial since EE 5.

        Show
        Kim Haase added a comment - Thanks, Brant. I expect you are correct and am checking with the spec leads to confirm, since the misinformation has been in the tutorial since EE 5.
        Hide
        Kim Haase added a comment -

        Fixed in 7.0.1.

        Show
        Kim Haase added a comment - Fixed in 7.0.1.

          People

          • Assignee:
            Kim Haase
            Reporter:
            Brant Gurganus
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: