Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Formating text in TextArea using EL

 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello;

I have the following code:

<textarea cols="" rows="50" name="emailList" style="width: 500; text-align: left;"><c:forEach var="email" items="${list.emailList}">${email},/n</c:forEach></textarea>

The problem is the list of elements get written in one long string. I would like each element to be on it's own line. Does EL have something like a println() that would do this for me? Is there some JSTL tag I should look into?

Thanks,

Luke
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The newlines should be in your markup. E.g.:


[ October 15, 2004: Message edited by: Bear Bibeault ]
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that, however the new line symbols get printed as text:

luke@lukeshannon.com,/nlukeshannon@hotmail.com,/n
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the View Source show?
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<textarea rows="50" name="emailList" style="width: 500; text-align: left;">luke@lukeshannon.com,/n lukeshannon@hotmail.com,/n xxxxxx@auctionsfind.com,/n xxxxxx@auctionsfind.com,/n </textarea>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the hard-coded "/n" characters
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I put a space in the text to be written directly after the comma, and remove the hard coded characters, I get a list of 2 emails by 2 emails. This is much better than a big long string.

Still not sure how to get them each on their own line, but this is close enough.

Thanks!

Luke
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The generated JSP will preserve any newlines in the source. So you could also write:



If you want complete control over the format, write a formatting bean.
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A formatting bean... sounds interesting. I will look into that.

Thanks again.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, if the list is being provided by a controller servlet, the servlet could tack a pre-formatted block onto the request rather than the raw list.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic