0

I am usin SelectOneMenu, in which the selectItems will load from database. The labele values are very large to fit in browser, So i wanted to split the label into multiple lines. Please let me know wether it is Possibe.

I have added a line break ('\n') in the label text. still it did not work

String description = "22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222";
        StringBuilder sb = new StringBuilder();
        String[] split = description.split("(?<=\\G.................................................)");
        for(String s : split){
            sb.append(s).append("\n");
        }
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Siva
  • 1,938
  • 1
  • 17
  • 36

1 Answers1

1

The element <h:selectOneMenu> is translated into a <select> HTML element while <f:selectItem> and <f:selectItems> are translated into <option> HTML elements.

Browsers don't manage line-break in these elements. See : Line Break in HTML Select Option?

As stated, the only method is to create custom HTML and use JS to make it look like a native <select>

Community
  • 1
  • 1
Thrax
  • 1,926
  • 1
  • 17
  • 32