Primefaces 10: newline character in textarea is removed - jsf

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:
I have tried also with h:inputTextarea and I got the same result - the newlines are removed before/during validation and before submit;
also with the CSS property "white-space: pre;" - same result;
I removed all CSS files - THEME to none and my CSS files commented - same result;
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.

Related

h:outputStylesheet not inserted when using FullAjaxExceptionHandler

I'm using the OmniFaces FullAjaxExceptionHandler to display error pages. The error pages are shown correctly, but I'm having issues with the styling of those pages.
My application is using a template which has CSS classes loaded in the <h:body> section like the following. <h:outputStylesheet name="css/theme.css" library="theme" />
I found the BalusC answer at h:body not rerendered when using FullAjaxExceptionHandler to be helpful for changing the body tag. But I'm stumped on why the FullAjaxExceptionHandler isn't replacing the children of individual <head> element. It appears like all <h:outputStylesheet> elements are ignored no matter where they are located.
I know this quite an old question but I have only recently encountered it and it has only just been solved as of 15/May/2021.
The headline is that this issue is solved in the versions of OmniFaces >= 3.11.1. At the time of writing this, OmniFaces 3.11.1 is a Maven Snapshot build.
The problem was caused by the Mojarra implementation of JSF 2.3 attempting to avoid outputting HTML links to CSS resources twice. It does this by recording a list of all of the resources that it thinks have been output. Then if a further attempt is made to output the same resource then the second and further attempts are ignored. The list is stored in a JSF attribute called "/javax.faces.resource", which is the value of ResourceHandler.RESOURCE_IDENTIFIER.
In the case of Primefaces/JSF rendering the response to an Ajax request generated by an Primefaces component, the rendering replaces the entire page including the resources that had already been rendered. In this case the "/javax.faces.resource" attribute should be cleared by OmniFaces' FullAjaxExceptionHandler to allow the re-rendering of the resources.
The problem was tracked and solved in OmniFaces cases 627 & 630

Using p:carousel inside p:dataGrid in PrimeFaces 5.3

Displaying a <p:carousel> inside a <p:dataGrid> using PrimeFaces 5.3 final (community release) something along the following piece of code.
<p:dataGrid var="gridRow" value="#{[1,2,3,4,5]}" columns="1">
<p:carousel var="row" value="#{[1,2,3,4,5]}" numVisible="3">
<p:panel>Panel container : #{row}</p:panel>
</p:carousel>
</p:dataGrid>
Using PrimeFaces 5.2 final, it displays the corresponding UI correctly as shown in the following picture.
Using PrimeFaces 5.3 final, the design is however, severely broken stretching items being held by a <p:carousel> too much horizontally as shown in the following picture.
See the browser's long horizontal scroll bar at the bottom-left corner of the preceding picture.
The problem occurs only when a <p:carousel> is displayed inside a <p:dataGrid> (or likely other iterating components). A <p:carousel> independently displays exactly which it is meant for.
What is the problem with PrimeFaces 5.3? Is there any workaround?
The solution was to set the layout attribute to grid in <p:dataGrid> (due to the responsiveness feature added to PrimeFaces 5.3). The default value of this attribute is tabular.

bootsfaces b:commandButton in ui:repeat not updating h:graphicImage

I'm using the 0.7 version of bootsfaces to create a simple page, which has something like the following:
<h:form id="some_form">
<ui:repeat id="some_elements" var="property" value="#{someBean.properties}">
<b:commandButton value="ShowProp" ajax="true" actionListener="#{someBean.showProperty(property)}" update=":some_form:some_elements:graphic"/>
<!-- This property is true -->
<ui:fragment rendered="#{someOtherBean.showGraphic}">
<h:graphicImage url="gen_image?id=#{property.id}" id="graphic"/>
</ui:fragment>
</ui:repeat>
</h:form>
Now, the idea is that on clicking the button, a property is updated and the image should be re-generated (in this case a jfreechart graph - but this is besides the point.) I tested this with primefaces commandButton and it works fine (the graph is redrawn..) However with bootsfaces commandButton, nothing happens once the ajax call completes (I can see the call on the server side, but the graph is not reloaded.) I think it's down to how it must reference the image in the repeated block, but now sure what is wrong - has anyone come across this?
(NOTE: reason I don't want to use primefaces is that it does not integrate well with bootstrap)
I've opened a bug on the project's bugtracker (https://github.com/TheCoder4eu/BootsFaces-OSP/issues/135).
Actually, why did you expect the update=":some_form:some_elements:graphic" to work in the first place? This expression is an id that doesn't exist. The id is some_form:some_elements:0:graphic. In other words: it contains the row number. PrimeFaces (and Mojarra and MyFaces) recognizes that the command button is part of a UIRepeat group and guesses the correct row number. But that's just a guess. Obviously a reasonable guess, because most of the time you want to update something that's in the vicinity of the command button.
The next version of BootsFaces is going to guess the correct row number, too :).

Primefaces Picklist problem

I am having a text field in my xhtml whose property i have set to required="true" and then i have primefaces picklist.
Now when validations fails like mandatory "textbox" is not filled. I throws an error and my page picklist becomes corrupted (all alignment) and if i see in generated html there will be no imports for primefaces like imports for picklist css and js.
I found the answere for the problem myself.
It was actually bcoz of a very silly problem.
One needs to do "render={SomeId of form element}" in the CommandButton.
All the things will work fine then.

Primefaces Watermark on Rich Calendar

I am using JSF 1.2, Richfaces 3.3.1 and I am trying to display a watermark in <rich:calendar>.
I thought of using Watermark tag of primefaces <p:watermark> and so i have included primefaces1.1.jar in my classpath. It works fine for input text, but when i tried it on Calendar by using forElement of Watermark it didn't work.
Please find the below code snippet, where I used the generated client id in the forElement attribute.
<p:watermark forElement = "#includeId:GroupMasterForm:arrDateInputDate input" value="dd/mm/yyyy"/>
Is there any workaround for that? Thanks in advance.
Some suggestions:
I think the problem is that you try to combine two different component libraries. I am not sure if this works at all.
You could try to use p:calendar instead of rich:calendar in order to test if this is the cause.
Furthermore, I think your forElement content might be a reason. If calendar and watermark are siblings you can simply use the id of the calendar instead of the whole path.
Try this one:
<rich:calendar value="#{dataModel.date}" id="date"
datePattern="dd.MM.yyyy" enableManualInput="true"
showApplyButton="false" inputClass="watermark" required="true"/>
<p:watermark forElement=".watermark" value="TT.MM.JJJJ"/>
remember to define the p:watermark tag outside of rich:calendar

Resources