split data(Text) of a text field into two strings, and use each string on different section of a visualforce page

StackOverflow https://stackoverflow.com/questions/19776772

質問

I have an account with a Note in notesandattachment related list. I want to display the text of 8 lines, out of 50 lines on a section of visualforce page. And remaining 42 lines in another section of same visualforce page.

what i know : I need to split the notes.body into two substrings. One, with 8 lines of text and second one with 42 line.I need to use div tags to get this done on the visualforce page. I might be wrong.

Please suggest me, how do i achieve this. Appreciate the help.

役に立ちましたか?

解決

You can split the text in controller by using split() method like this

String allLines[] = allText.split('\n');
String first8Lines = '';
String restLines ='';
for(Integer i =0; i<8 ; i++){
    first8Lines += allLines[i];
}
for(Integer i =7; i<50 ; i++){
    restLines += allLines[i];    
}

And then put {!first8Lines} in one place and {!restLines} in another

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top