Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6609321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:42:14+00:00 2026-05-25T19:42:14+00:00

I have a primefaces textarea. User simply enters multiple lines in it and submits

  • 0

I have a primefaces textarea. User simply enters multiple lines in it and submits the form. In my backing bean, value is split at line-breaks. Each line is validated. The valid lines are removed from the string and invalid lines are kept, and again sent to the user.

Split code:

StringTokenizer tokens=new StringTokenizer(value,"\n\r");

Re-fill value with invalid lines:

valueStrBldr.append(invalidLine).append("\n\r");

The problem is that when value is reloaded to text area it has a lot of unwanted line breaks and empty lines. Does it have to do something with platform dependent line breaks?

When I remove \r , the problem is solved, but then the value is not split correctly — I mean why inconsistency?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:42:15+00:00Added an answer on May 25, 2026 at 7:42 pm

    I suggest to use BufferedReader#readLine() instead to read lines on linebreaks. This covers all possible platform specific linebreaks such as \r\n, \r and \n without that you need to worry about (please note that \n\r is not a valid linebreak sequence).

    BufferedReader reader = new BufferedReader(new StringReader(value));
    String line = null;
    
    while ((line = reader.readLine()) != null) {
        // ...
    }
    

    When writing lines, I suggest to use \r\n. It should work fine in all clients (webbrowsers).

    valueStrBldr.append(invalidLine).append("\r\n");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data entry form where user enters lots of data. When user
I have a primefaces datatable: <p:dataTable id=idCrawledDataTable var=crawledData value=#{crawlerCorpusTreatmentBean.crawledDataModel} rowKey=#{crawledData.id} rows=10 scrollable=true scrollHeight=300 selection=#{crawlerCorpusTreatmentBean.crawledData}
I'm using primefaces and jstl to loop a datatable.I have a List in backing
I have an input field taking an email address: <h:inputText value=#{register.user.email} required=true /> How
I'm using Primefaces 3.0.RC1 and on a form I have a <p:fileUpload mode=advanced auto=true>
I have a a button that is setting a property to a backing bean
Primefaces 2.2.1 Mojarra 2.1.2 I have a sophisticated method in my jsf bean :
I have problem firing an ajax request with Primefaces <f:metadata> <f:viewParam name=token value=#{clientBean.token}/> <f:event
I have a question regarding primefaces datatable component. I want to bind a DataTable
I am working with MyFaces/Primefaces and I have a problem to get information using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.