EL expression for label not resolved - primefaces

This is a follow up for my FindComponent + set invalid challenge question...
In that question it all worked fine for static strings, like:
<p:inputText id="val2" readonly="true" value="#{cc.attrs.data.val2}" label="label2">
<f:attribute name="someAttribute" value="value2" />
</p:inputText>
...but when I changed to EL it is "not working":
<div class="ui-g-12">
<div class="ui-g-6">
<p:outputLabel value="Val 2: #{cc.attrs.data.label2}"/>
</div>
<div class="ui-g-6">
<p:inputText id="val2" readonly="true" value="#{cc.attrs.data.val2}" label="#{'l2'.concat(cc.attrs.data.label2)}">
<f:attribute name="someAttribute" value="#{'a2'.concat(cc.attrs.data.label2)}" />
</p:inputText>
</div>
</div>
What am I missing here?
I know that #{cc.attrs.data.label2} is not empty, "printing" on p:outputLabel works.
edit 1:
I found this question - Using Omnifaces EL functions in composite component with Mojarra 2.2.5 but I do not know whether it is related or not. My versions are
Initializing Mojarra 2.2.14
Running on PrimeFaces 6.2
Running on PrimeFaces Extensions 6.2.4
Using OmniFaces version 1.14

Related

Why are comopnents of another form validated with JSF 2.3?

I just upgraded to JSF 2.3 & Wildfly 14 (from 2.0 and 13) and primefaces 6.2.5.
I noticed a strange behavior when i use a command button. I have 2 forms and when a push the button of the first form, the input of the second form is validated and the error (in this case required errors) are displayed in a p:message :
<h:form id="form1" prependId="false">
<p:commandButton id="save" value="Save" actionListener="#{myBean.save()}" update="#form">
<f:actionListener binding="#{myBean.reloadResults()}" />
</p:commandButton>
<p:messages id="msgs" severity="error,warn" escape="false">
<p:autoUpdate />
</p:messages>
...
</h:form>
<p:dialog >
<h:form id="form2" >
<p:messages severity="error,warn" escape="false">
<p:autoUpdate />
</p:messages>
<div>
<p:calendar id="myDate" value="#{myBean.myDate}" required="true" />
</div>
...
</h:form>
</p:dialog>
I was expecting only the content of the first form to be processed and validated. This was the case with wildfly 13 and jsf 2.0.
Any idea?
You have not specified attribute process in your command button. Default value of this is #all which will validate all Forms.
Please use process="#form" to avoid validation and process of other form.
Updated code is as below:
<p:commandButton id="save" value="Save" actionListener="#{myBean.save()}" update="#form" process="#form">
<f:actionListener binding="#{myBean.reloadResults()}" />
</p:commandButton>
I have to apologize for not posting the entire code but it would have been to big. I found out what the problem was. It's related to this bug:
https://github.com/primefaces/primefaces/issues/4122
I have a panelgrid of 4 columns but with 10 elements in it.
The whole ajax communication was then broken. Fix is coming in PF 6.3

ajax event not working

I have a form that should appear when the checkbox is true. This won't work. weird thing is : I did exactly the same on another page and there it works. Also when using another boolean property in the backing bean itself it works.
<div class="field">
<p:outputLabel for="company" value="Company" />
<p:selectBooleanCheckbox id="company" value="#{participantDetailBean.participant.isCompany}">
<p:ajax event="change" update="companyFields"/>
</p:selectBooleanCheckbox>
</div>
<p:outputPanel id="companyFields">
<div class="field">
<p:outputLabel for="companyname" value="Company name" rendered="#{participantDetailBean.participant.isCompany}" />
<p:inputText id="companyname" value="#{participantDetailBean.participant.companyName}" rendered="#{participantDetailBean.participant.isCompany}" />
</div>
<div class="field">
<p:outputLabel for="companyform" value="Company form" rendered="#{participantDetailBean.participant.isCompany}" />
<p:inputText id="companyform" value="#{participantDetailBean.participant.companyForm}" rendered="#{participantDetailBean.participant.isCompany}" />
</div>
<div class="field">
<p:outputLabel for="companynumber" value="Company number" rendered="#{participantDetailBean.participant.isCompany}" />
<p:inputMask id="companynumber" value="#{participantDetailBean.participant.companyNumber}" mask="aa 9999.999.999" rendered="#{participantDetailBean.participant.isCompany}" />
</div>
</p:outputPanel>
Sometimes Primefaces has its moments when components that works on one page, simply refuses to work on another page. The code you've posted in your example is correct and most likely if you place a break point on the company getter, when the ajax event change is triggered, the value will update correctly. What's happening is that your component is not refreshing correctly via the ajax (or is not recognized).
A workaround solution that I found is to this scenario is to include JSF's PanelGroup inside the OutputPanel. I used the base of your code and made the below example (obviously replacing tags I have in my project with the objects as per your example.
<div class="field">
<p:selectBooleanCheckbox id="company"
value="# {participantDetailBean.participant.isCompany}">
<p:ajax event="change" update=":companyFields"/>
</p:selectBooleanCheckbox>
</div>
<p:outputPanel id="companyFields">
<h:panelGroup id="companyFields2" rendered="#{participantDetailBean.participant.isCompany}">
<div class="field">
<p:outputLabel value="DISPLAY THIS FIELD"/>
</div>
</h:panelGroup>
</p:outputPanel>
Whilst this is not the cleanest solution, it might help you get out of the rut you're currently stuck in, or guide you in obtaining the correct answer. Oh, and don't forget to include the JSF include tag when using PanelGroup
xmlns:h="http://xmlns.jcp.org/jsf/html"
Try to use the itemSelect event.

Why is my custom selectOneRadio layout not working with PrimeFaces 5.1?

I'm migrating my project from version 5.0 to version 5.1 of PrimeFaces.
I have a p:selectOneRadio with custom layout that works fine with version 5.0 but not with 5.1.
It seems that the itemIndex is not working.
This is my layout:
<p:selectOneRadio id="incidentRadio" value="#{backingBean.option}" layout="custom">
<f:selectItem itemLabel="existingIncident" itemValue="existingIncident" />
<f:selectItem itemLabel="newIncident" itemValue="newIncident" />
</p:selectOneRadio>
...
<p:radioButton id="optIncident1" for="incidentRadio" itemIndex="0"/>
<h:outputLabel for="optIncident1" value="existingIncident" />
...
<p:radioButton id="optIncident2" for="incidentRadio" itemIndex="1"/>
<h:outputLabel for="optIncident2" value="newIncident" />
The behaviour is the following:
When I select the first radio button (optIncident1), it actually passes the value of the second radio button (optIncident2) to the backing bean.
When I select the second button, it gives me a validation error:
formactionCall:tabViewCall:incidentRadio: Validation Error: Value is not valid
Is this a bug in 5.1?
I am using Jboss 7.1.1.Final with javax.faces-2.1.12.

Primefaces p:menuitem with p:confirm not supported

I'm trying to call a confirmation dialog on a p:menuitem:
<p:menuitem value="#{text['button.archive']}" actionListener="#{tasksbacking.archive}" icon="ui-icon-locked">
<p:confirm header="#{text['button.archive.confirm.header']}"
message="#{text['button.archive.confirm.message']}"
icon="ui-icon-alert"/>
</p:menuitem>
but according to the documentation in Primefaces 5:
At the moment p:confirm is supported by p:commandButton and p:commandLink
Is there any way to do this?
I have found better workaround here.
In two words - include commandlink into menuitem like this:
....
<p:menuitem>
<p:commandLink>
<p:confirm>
</p:confirm>
</p:commandLink>
</p:menuitem>
....
And you can use global confirmation with this setup. It tested with PF 5.1. Also, it looks like soon it will be implemented in PrimeFaces.
I've come up with this question today. After a bit of try and error, and respecting the information out of the already posted links in the comments, if tried to do the following, and unexpectedly, this works for me. I'm on PF 5.3
<p:menuitem value="Löschen"
actionListener="#{importerDefinitionView.deleteSelectedFile()}"
update="messages">
<p:confirm header="Datei Löschen"
message="Soll die Datei wirklich gelöscht werden?"
icon="ui-icon-alert" />
</p:menuitem>
The relating confirm-dialog:
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Yes" type="button"
styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
<p:commandButton value="No" type="button"
styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>

primefaces global filter with commandlink

Okay. So I'm trying to implement a global filter using commandLinks. The idea is to have an alphabet of commandLinks, which a user can then use instead of typing a letter.
So far, I've got filtering working on the column (will add the filterStyle none once the commandLinks are working).
Using chromes debug tool (ctrl-shift+i), and clicking on the command link, i can see the datatable refresh the list. However, it doesn't filter anything.
I've been using primefaces showcase, and this stack overflow post to base my code on, which is below:
<p:dataTable id="availableSpecies" var="species" value="#{bbWizardBean.speciesPaletteList}"
emptyMessage="Add First Species" dynamic="true"
width="120"
widgetVar="speciesPaletteVar"
scrollHeight="250" scrollRows="20" scrollable="true"
styleClass="width-fix-spcPal-ie" style="width:150px; margin-left: auto; margin-right: auto;"
filteredValue="bbWizardBean.speciesPaletteListFilter">
<f:facet name="header">
<h:outputText value="Species Palette" />
<p:commandLink id="globalFilter" value="A" onclick="$('speciesColumn_filter').val('A'),speciesPaletteVar.filter()"/>
</f:facet>
<p:column filterBy="#{species.speciesName}"
headerText="Species" style="font-size:13px;" id="speciesColumn">
<h:outputText id="dragIcon" value="#{species.speciesNameSmall}" style="font-size:11px; background-color:silver; cursor:move;"/>
<h:outputText id="dragIconTooltip" value="..." title="Full Name: #{species.speciesName}" rendered="#{species.speciesNameLength > 10}"/>
<p:tooltip for="dragIconTooltip" />
<p:draggable for="dragIcon" revert="true" />
</p:column>
I've removed the rest of the table to make the codebase smaller. I think I'm screwing up the value I should set, but I'm not quite sure how. Any help would be appreciated! First post, so any suggestions to clean up the question is appreciate ;)
Okay, so for some reason (like i thought), the setting of the val for the filter wasn't working right. You need to add two \'s before the : for some reason. If anyone knows, that would be awesome, but the correct code is:
<p:commandLink id="globalFilter" value="A" onclick="$('#positiveRegulationForm\\:availableSpecies\\:speciesColumn_filter').val('A'),speciesPaletteVar.filter()"/>
Where
positiveRegulationForm is the top form
availableSpecies is the DataTable name
speciesColumn_filter is the filter for the column speciesColumn
Really curious as to why you need the two forward slashes