Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-11606

rich:select : doesn't cast selectItem value

    XMLWordPrintable

    Details

    • Steps to Reproduce:
      Hide
      • Declare an Integer property in a managed bean and set a default value;
      PagerBean.java
      private Integer page = 20;
      
      public Integer getPage() {...}
      public Integer setPage(Integer page) {...}
      
      • Bind the property to a rich:select;
      • Define f:selectItem(s);
      page.xhtml
      <rich:select value="#{pagerBean.page}">
        <f:selectItem itemValue="5" itemLabel="5" />
        <f:selectItem itemValue="10" itemLabel="10" />
        <f:selectItem itemValue="20" itemLabel="20" />
        <f:selectItem itemValue="40" itemLabel="40" />
      </rich:select>
      
      • Render the page and the value 20 will not be selected, but it will be rendered in the input:hidden of the component in the page source.
      page.xhtml source
      <div class="rf-sel" id="j_idt114:j_idt187:j_idt165">
        <span class="rf-sel-cntr">
          <input id="j_idt114:j_idt187:j_idt165selValue" name="j_idt114:j_idt187:j_idt165" type="hidden" value="20" />
          <input autocomplete="off" class="rf-sel-inp rf-sel-dflt-lbl" id="j_idt114:j_idt187:j_idt165Input" name="j_idt114:j_idt187:j_idt165Input" readonly="readonly" type="text" />
          <span class="rf-sel-btn" id="j_idt114:j_idt187:j_idt165Button">
            <span class="rf-sel-btn-arrow"></span>
          </span>
        </span>
        <div class="rf-sel-lst-cord" id="j_idt114:j_idt187:j_idt165List">
          <div class="rf-sel-shdw">
            <div class="rf-sel-shdw-t"></div>
            <div class="rf-sel-shdw-l"></div>
            <div class="rf-sel-shdw-r"></div>
            <div class="rf-sel-shdw-b"></div>
            <div class="rf-sel-lst-dcrtn">
              <div class="rf-sel-lst-scrl" style="min-height: 20px;max-height: 100px;width: 30px">
                <div id="j_idt114:j_idt187:j_idt165Items">
                  <div id="j_idt114:j_idt187:j_idt165Item0" class="rf-sel-opt">5</div>
                  <div id="j_idt114:j_idt187:j_idt165Item1" class="rf-sel-opt">10</div>
                  <div id="j_idt114:j_idt187:j_idt165Item2" class="rf-sel-opt">20</div>
                  <div id="j_idt114:j_idt187:j_idt165Item3" class="rf-sel-opt">40</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <script type="text/javascript">new RichFaces.ui.Select("j_idt114:j_idt187:j_idt165", {"clientSelectItems":[{ 'id' : "j_idt114:j_idt187:j_idt165Item0" , 'label' : "5", 'value' : "5"},{ 'id' : "j_idt114:j_idt187:j_idt165Item1" , 'label' : "10", 'value' : "10"},{ 'id' : "j_idt114:j_idt187:j_idt165Item2" , 'label' : "20", 'value' : "20"},{ 'id' : "j_idt114:j_idt187:j_idt165Item3" , 'label' : "40", 'value' : "40"}] ,"itemCss":"rf\u002Dsel\u002Dopt","selectItemCss":"rf\u002Dsel\u002Dsel","onselectitem":function(event){RichFaces.ajax(this,event,{"parameters":{"javax.faces.behavior.event":"selectitem","org.richfaces.ajax.component":"j_idt114:j_idt187:j_idt165"} ,"sourceId":this} )}} );</script>
      </div>
      
      • If you change the property page's type in the PageBean to String, the value will be selected after rendering the page.
      Show
      Declare an Integer property in a managed bean and set a default value; PagerBean.java private Integer page = 20; public Integer getPage() {...} public Integer setPage( Integer page) {...} Bind the property to a rich:select; Define f:selectItem(s); page.xhtml <rich:select value= "#{pagerBean.page}" > <f:selectItem itemValue= "5" itemLabel= "5" /> <f:selectItem itemValue= "10" itemLabel= "10" /> <f:selectItem itemValue= "20" itemLabel= "20" /> <f:selectItem itemValue= "40" itemLabel= "40" /> </rich:select> Render the page and the value 20 will not be selected, but it will be rendered in the input:hidden of the component in the page source. page.xhtml source <div class= "rf-sel" id= "j_idt114:j_idt187:j_idt165" > <span class= "rf-sel-cntr" > <input id= "j_idt114:j_idt187:j_idt165selValue" name= "j_idt114:j_idt187:j_idt165" type= "hidden" value= "20" /> <input autocomplete= "off" class= "rf-sel-inp rf-sel-dflt-lbl" id= "j_idt114:j_idt187:j_idt165Input" name= "j_idt114:j_idt187:j_idt165Input" readonly= "readonly" type= "text" /> <span class= "rf-sel-btn" id= "j_idt114:j_idt187:j_idt165Button" > <span class= "rf-sel-btn-arrow" ></span> </span> </span> <div class= "rf-sel-lst-cord" id= "j_idt114:j_idt187:j_idt165List" > <div class= "rf-sel-shdw" > <div class= "rf-sel-shdw-t" ></div> <div class= "rf-sel-shdw-l" ></div> <div class= "rf-sel-shdw-r" ></div> <div class= "rf-sel-shdw-b" ></div> <div class= "rf-sel-lst-dcrtn" > <div class= "rf-sel-lst-scrl" style= "min-height: 20px;max-height: 100px;width: 30px" > <div id= "j_idt114:j_idt187:j_idt165Items" > <div id= "j_idt114:j_idt187:j_idt165Item0" class= "rf-sel-opt" >5</div> <div id= "j_idt114:j_idt187:j_idt165Item1" class= "rf-sel-opt" >10</div> <div id= "j_idt114:j_idt187:j_idt165Item2" class= "rf-sel-opt" >20</div> <div id= "j_idt114:j_idt187:j_idt165Item3" class= "rf-sel-opt" >40</div> </div> </div> </div> </div> </div> <script type= "text/javascript" > new RichFaces.ui.Select( "j_idt114:j_idt187:j_idt165" , { "clientSelectItems" :[{ 'id' : "j_idt114:j_idt187:j_idt165Item0" , 'label' : "5" , 'value' : "5" },{ 'id' : "j_idt114:j_idt187:j_idt165Item1" , 'label' : "10" , 'value' : "10" },{ 'id' : "j_idt114:j_idt187:j_idt165Item2" , 'label' : "20" , 'value' : "20" },{ 'id' : "j_idt114:j_idt187:j_idt165Item3" , 'label' : "40" , 'value' : "40" }] , "itemCss" : "rf\u002Dsel\u002Dopt" , "selectItemCss" : "rf\u002Dsel\u002Dsel" , "onselectitem" :function(event){RichFaces.ajax( this ,event,{ "parameters" :{ "javax.faces.behavior.event" : "selectitem" , "org.richfaces.ajax.component" : "j_idt114:j_idt187:j_idt165" } , "sourceId" : this } )}} );</script> </div> If you change the property page's type in the PageBean to String, the value will be selected after rendering the page.

      Description

      If you define f:selectItem(s) directly in the xhtml file as children of a rich:select, the values of the selectItem(s) are not cast to the bound value of the rich:select.

      This results in the value to be not selected by the rich:select after rendering the page.

      As the documentation of the component says: "The rich:select component is designed to replace standard h:selectOneMenu."

      The h:selectOneMenu casts and selects the value in this case.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                michpetrov Michal Petrov
                Reporter:
                psychobaatezu Frederic Allard
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: