javaserverfaces-spec-public
  1. javaserverfaces-spec-public
  2. JAVASERVERFACES_SPEC_PUBLIC-329

Add new single HTML radio button component that isn't bound to a list

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.3
    • Component/s: Components/Renderers
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      329
    • Status Whiteboard:
      Hide

      cat2 renderkitdoc size_medium importance_small

      Show
      cat2 renderkitdoc size_medium importance_small

      Description

      The selectOneRadio component requires that all radio buttons be grouped
      together. This is very inflexible when creating user interfaces. Many times I
      have encountered screens where I need multiple radio buttons in the same group,
      but each radio button exists in a separate area of the screen. This can be done
      in HTML easily, but not with JSF's default component set.

      I've read that Apache MyFaces has created a component to solve this issue, and
      so has Sun's Woodstock component set. Please standardize this fundamental
      component in JSF 2.0 so that all implementations come with it.

        Activity

        Hide
        balusc added a comment - - edited

        Summarized: best approach would be to modify the existing renderer in such way so that at least the below cases are possible:

        1:

        <h:dataTable value="#{bean.items}" var="item">
            <h:column>
                <h:selectOneRadio group="foo" value="#{bean.selectedItem}">
                    <f:selectItem itemValue="#{item}" />
                </h:selectOneRadio>
            </h:column>
        </h:dataTable>
        

        2:

        <ui:repeat value="#{bean.items}" var="item">
            <h:outputLabel for="radioId" value="#{item.label}" />
            <h:selectOneRadio id="radioId" group="foo" value="#{bean.selectedItem}">
                <f:selectItem itemValue="#{item.value}" />
            </h:selectOneRadio>
            <br/>
        </ui:repeat>
        

        3:

        <h:selectOneRadio group="foo" value="#{bean.selectedItem}">
            <f:selectItem itemValue="one" />
            <f:selectItem itemValue="two" />
            <f:selectItem itemValue="three" />
        </h:selectOneRadio>
        <h:selectOneRadio group="foo" />
        <h:selectOneRadio group="foo" />
        

        4:

        <h:selectOneRadio group="foo" value="#{bean.selectedItem}">
            <f:selectItem itemValue="one" />
        </h:selectOneRadio>
        <h:selectOneRadio group="foo">
            <f:selectItem itemValue="two" />
        </h:selectOneRadio>
        <h:selectOneRadio group="foo">
            <f:selectItem itemValue="three" />
        </h:selectOneRadio>
        

        5:

        <h:selectOneRadio group="foo" value="#{bean.selectedItem}">
            <f:selectItems value="#{['one', 'two', 'three']}" />
        </h:selectOneRadio>
        <h:selectOneRadio group="foo" />
        <h:selectOneRadio group="foo" />
        

        The group attribute is new. When group is specified, it must render solely a <input type="radio"> element (no table, no list). The group value must be relative to the UIForm and represent the common HTML name.

        If there are multiple components with same group in the UIForm, and the value attribute and/or UISelectItem child is absent, then the one of the first component must be considered. The UISelectItem values will be assigned to the components having same group in the same order as components appear in the UIForm.

        If the UISelectItem has a item label, then a <label> will be rendered directly after the <input> element, without any additional markup.

        Show
        balusc added a comment - - edited Summarized: best approach would be to modify the existing renderer in such way so that at least the below cases are possible: 1: <h:dataTable value= "#{bean.items}" var = "item" > <h:column> <h:selectOneRadio group= "foo" value= "#{bean.selectedItem}" > <f:selectItem itemValue= "#{item}" /> </h:selectOneRadio> </h:column> </h:dataTable> 2: <ui:repeat value= "#{bean.items}" var = "item" > <h:outputLabel for = "radioId" value= "#{item.label}" /> <h:selectOneRadio id= "radioId" group= "foo" value= "#{bean.selectedItem}" > <f:selectItem itemValue= "#{item.value}" /> </h:selectOneRadio> <br/> </ui:repeat> 3: <h:selectOneRadio group= "foo" value= "#{bean.selectedItem}" > <f:selectItem itemValue= "one" /> <f:selectItem itemValue= "two" /> <f:selectItem itemValue= "three" /> </h:selectOneRadio> <h:selectOneRadio group= "foo" /> <h:selectOneRadio group= "foo" /> 4: <h:selectOneRadio group= "foo" value= "#{bean.selectedItem}" > <f:selectItem itemValue= "one" /> </h:selectOneRadio> <h:selectOneRadio group= "foo" > <f:selectItem itemValue= "two" /> </h:selectOneRadio> <h:selectOneRadio group= "foo" > <f:selectItem itemValue= "three" /> </h:selectOneRadio> 5: <h:selectOneRadio group= "foo" value= "#{bean.selectedItem}" > <f:selectItems value= "#{['one', 'two', 'three']}" /> </h:selectOneRadio> <h:selectOneRadio group= "foo" /> <h:selectOneRadio group= "foo" /> The group attribute is new. When group is specified, it must render solely a <input type="radio"> element (no table, no list). The group value must be relative to the UIForm and represent the common HTML name. If there are multiple components with same group in the UIForm , and the value attribute and/or UISelectItem child is absent, then the one of the first component must be considered. The UISelectItem values will be assigned to the components having same group in the same order as components appear in the UIForm . If the UISelectItem has a item label, then a <label> will be rendered directly after the <input> element, without any additional markup.
        Hide
        kito75 added a comment -

        +1 for this approach

        Show
        kito75 added a comment - +1 for this approach
        Show
        balusc added a comment - https://java.net/projects/mojarra/sources/git/revision/1edee483ce009c929d11f8c5a53dc11688c10cf5
        Hide
        balusc added a comment -
        Show
        balusc added a comment - Implementation follows in https://java.net/jira/browse/JAVASERVERFACES-4188
        Hide
        balusc added a comment -

        When https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1433 is enabled, the <h:selectOneRadio group="..." required="true"> displays multiple required message, one per component, instead of only once. Due to this, UISelectOne#processValidators() needed to be altered to cover this case, which is done in this commit: https://java.net/projects/mojarra/sources/git/revision/554d49e57c62143287521cef879b3444601cca5a

        Improved implementation and IT follows in https://java.net/jira/browse/JAVASERVERFACES-4188

        Show
        balusc added a comment - When https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1433 is enabled, the <h:selectOneRadio group="..." required="true"> displays multiple required message, one per component, instead of only once. Due to this, UISelectOne#processValidators() needed to be altered to cover this case, which is done in this commit: https://java.net/projects/mojarra/sources/git/revision/554d49e57c62143287521cef879b3444601cca5a Improved implementation and IT follows in https://java.net/jira/browse/JAVASERVERFACES-4188

          People

          • Assignee:
            balusc
            Reporter:
            rdelaplante
          • Votes:
            7 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: