Hello,
Its to possible to “force” text wrap in label using CONTENT_PREFORMATTED mode? The alternatives presented in forum for this situation are not working in this mode.
–
Thks in advance.
JP.
Hello,
Its to possible to “force” text wrap in label using CONTENT_PREFORMATTED mode? The alternatives presented in forum for this situation are not working in this mode.
–
Thks in advance.
JP.
You can achieve that using CSS.
// Java
myLabel.addStyleName("mystyle");
// CSS
.v-label-mystyle {
white-space: pre-wrap;
}
I try that solution but it is notworking for me.
I created label like this:
new Label(element.getFormattedText(), Label.CONTENT_RAW);
And getFormattedText method replace all \r?\n by
. After this, i added label to VerticalLayout and is working properly.
I dont know if it’s the best solution, but is working,
Thks.
Leave out the Label.CONTENT_RAW) and it should work with the custom style name (we use this method in the Directory add-on description texts). But your solution is working as well, so choose the one you want.