Getting selected value of a SelectOneMenu

前端 未结 1 522
感情败类
感情败类 2020-12-17 02:47

I\'m testing the component \"SelectOneMenu\" on a jsf page. I\'m populating this component dinamically though my ManageBean (that will get all Animals from database).

<
1条回答
  •  旧时难觅i
    2020-12-17 03:10

    There are many solutions to the presented problem. I present here two basic ideas.

    1. Server-side solution. Simply attach tag inside your to update selected values and rerender user's choice, like in

      
          
          
          
      
      
      

      If you like, you may also do some custom logic with selected element in ajax listener by specifying listener="#{animalsManage.performCustomAjaxLogic}" of tag.

    2. Client-side solution. Simply update element with id="textbox" on basic change event. So, if you use jQuery the solution will be

      $('#combo').change(function() {
          $('#textbox').val($('#combo').val());
      });
      

      Thought the client-side solution will bind only text value of your input component.

    0 讨论(0)
提交回复
热议问题