How to get both label and value from f:selectItems

前端 未结 5 1230
长发绾君心
长发绾君心 2020-11-30 06:05

I am working on a JSF page which has a dropdown based on List:


    <         


        
5条回答
  •  無奈伤痛
    2020-11-30 06:36

    Instead of Using Map I tried like this and it's perfectly working for me to get both ItemValue and ItemLabel in the same property by using "ItemValue" attribute in selectItems tag.How ever provided no extra commas in the ItemLabel(@asfas....i had the same problem u mentioned so i selected this approach).

    
           
         
          
    
    

    Basically IssueDesc is String type in Bean Company

        public Class Company{
    
          private String issueDesc;    // getters and setters
          private int code;  // getters and setters
          private ListissueList; // getters and setters.
    
    
             public void getLblandVal(){
    
               String desc=getIssueDesc();
               String[] str_ary=desc.split(",");
               String s1=str_ary[0];
               String s2=str_ary[1];
              // parse **s1** to int;
        }
    
    
    }
    

提交回复
热议问题