java - Unable to determine reason for inappropriate formatting -


the text formatting breaks when text copy pasted ms word document. when same text typed in text box issue not occur.

a jsf inputtext tag used receive text containing maximum of 140 chars. text processed server-side remove whitespaces , insert html <br> tags when word inside text big , un-wrappable browser.

the text displayed on jsf page using outputtext tag inside <li> element.

<ul>      <hx:viewfragment id="msgfragprn" rendered="#{pc_pagecode.enabled}">          <f:verbatim><li class="datarowprintonly"><span class="row"></f:verbatim>         <h:outputtext value="message"></h:outputtext>         <f:verbatim></span></f:verbatim>         <h:outputtext value=":" styleclass="printonly"></h:outputtext>         <h:outputtext  escape="false" styleclass="printinline" value="#{pc_pagecode.transobj.formattedmsg}">         </h:outputtext>         <f:verbatim> </li></f:verbatim>      </hx:viewfragment>  </ul> 

css styles used

.printinline{display:inline-block; word-wrap:break-word; padding-left:2px; } .printonly{padding-right:4px; width:2%; vertical-align:top;} 

the above code , styles allow following display

display format when text typed text box

  • message : text displayed when typed text box. however, same not                  case when text copy pasted word doc.

display format when text typed text box

  • message :
    text displayed when typed text box. however, same not case when text copy pasted word doc.

since difference between 2 text inputs cr/lf/invisible characters. tried following things

string whitespace_chars = "" /* dummy empty string homogeneity */ + "\\u0009" // character tabulation                              + "\\u000a" // line feed (lf)                              + "\\u000b" // line tabulation                              + "\\u000c" // form feed (ff)                              + "\\u000d" // carriage return (cr)                              + "\\u0085" // next line (nel)                              + "\\u001c" // file separator.                              + "\\u001d" //  group separator.                              + "\\u001e" // record separator.                              + "\\u001f" //  unit separator.                              + "\\u00a0" // no-break space                              + "\\u1680" // ogham space mark                              + "\\u180e" // mongolian vowel separator                              + "\\u2000" // en quad                              + "\\u2001" // em quad                              + "\\u2002" // en space                              + "\\u2003" // em space                              + "\\u2004" // three-per-em space                              + "\\u2005" // four-per-em space                              + "\\u2006" // six-per-em space                              + "\\u2007" // figure space                              + "\\u2008" // punctuation space                              + "\\u2009" // thin space                              + "\\u200a" // hair space                              + "\\u2028" // line separator                              + "\\u2029" // paragraph separator                              + "\\u202f" // narrow no-break space                              + "\\u205f" // medium mathematical space                              + "\\u3000" // ideographic space              ; 

using pattern & matcher , replaceall method replaced above occurrences " " (blank space). matcher.find() not find occurrence of above characters.

i tried replacing occurrence of below " ".

"\\r\\n|\\r|\\n"  

the above mentioned issue observed when text continuous string of 140 chars without spaces or when text consists of word has length of more 50 chars. in such cases tokenized text [\s+] delimiter , inserted <br/>. display format expected in both cases after insertion of break tags.

i'm still wondering reason behind breaking of display format when text copy pasted. pointers please?

the thing seems work insertion of <br/> tag within text when text content bigger length.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -