0

during a migration of a project to Primefaces 10 I get a problem with the textareas (p:inputTextarea) - the newline characters are removed before saving and the text is shown on one line.

There is nothing special with my textarea:

       <p:inputTextarea id="offercommentTextareaId" 
            styleClass="m-0 w-100" rows="10" autoResize="true" 
            counter="offerdataCounterTextId"
            counterTemplate="#{components['org.primefaces.component.inputTextarea.counterTemplate']}"
            maxlength="4000"
            value="#{supplierOffer.offercomment}"
            readonly="false"
            disabled="false">
        </p:inputTextarea>

I cannot find any solution for this problem.

Many thx in advance

Update 1:

  1. I have tried also with h:inputTextarea and I got the same result - the newlines are removed before/during validation and before submit;
  2. also with the CSS property "white-space: pre;" - same result;
  3. I removed all CSS files - THEME to none and my CSS files commented - same result;
  4. With ICEfaces 4 is working.

I am using in this migration Primefaces 10.0.3 with MyFaces 2.3 on IBM Liberty 21.0.0.6

Because it is working with ICEfaces 4 I think there is a bug in Primefaces and / or JQuery.

Update 2: After a deeper look into the problem finally I got to the root of it. The problem is given by using the 'enctype="multipart/form-data"' into the h:form. The newline character is used as a delimiter for getting the "parts" out of the textarea. Without this attribute everything is working just fine. On the other hand this attribute is needed for uploading files. This answer explains it better as I do: How to have a working Textarea and a fileUpload in one form

I still don't get it why it is working with ICEfaces 4 (v. 4.3 exactly). Right now I have to split it in 2 forms.

bad_apples
  • 21
  • 6
  • Does this answer your question? [how to make \n work in ](https://stackoverflow.com/questions/9942495/how-to-make-n-work-in-hinputtextarea) – Melloware Sep 10 '21 at 18:35
  • @Melloware: no, that solution didn't make any difference. I made also an update on my question. – bad_apples Sep 11 '21 at 20:07
  • But if it also happens with `` that has nothing to do with PrimeFaces and would be Mojarra or MyFaces doing that right? Can you create a simple PrimeFaces Test reproducer so I can debug? See: https://github.com/primefaces/primefaces-test – Melloware Sep 12 '21 at 12:02
  • Also I just tried newline at IceFaces Showcase and their newline does not appear: http://icefaces-showcase.icesoft.org/showcase.jsf?grp=ace:textAreaEntry – Melloware Sep 12 '21 at 15:28
  • @Melloware: This is not completely true. The newlines are not shown in the h:outputText Tag, but the newlines are there in inputTextarea. This is normal. If one add "white-space: pre;" to the h:outputText Tag then the newlines are shown. – bad_apples Sep 14 '21 at 06:52
  • OK then create a primefaces Test reproducer please so it can be debugged: https://github.com/primefaces/primefaces-test – Melloware Sep 14 '21 at 18:44
  • @Melloware: please read the second update. The problem is now easy to reproduce. If you still need a test project please let me know. – bad_apples Sep 17 '21 at 20:54
  • Yep don't do that. `enctype="multipart/form-data` is only necessary for FileUpload type forms right? So that explains it and there is nothing PF can do about that. The browser is munging it or your server. So not a PF bug. No idea why IceFaces works it should not. Unless they have some hack... – Melloware Sep 24 '21 at 20:33

0 Answers0