Truncate long text in dropdown jsf h: selectOneMenu

there is a quick way to truncate long texts displayed in h: selectOneMenu without having to encode it from scratsh. what I would like to achieve is truncating the long text and adding a tooltip to display all the text.

thank

+3


source to share


2 answers


You can create a utility function that will be used to truncate long text. Example:

function shortText(String data,int length){
     return data.subString(0,length);
}

      



Now, instead of directly displaying the value, pass the value and length to this function and use the return value in the UI.

+1


source


There are many simpler ways in css to truncate longer text, like

text-overflow: ellipsis;

      

OR



text-overflow: hidden;

      

And the 'title' attribute adds a tooltip to select OneMenu

+1


source







All Articles