primefaces disable commandButton - primefaces

I have below code for primefaces p:commandButton. I have set update and oncomplete attributes to disable commandButton in p:panelGrid of "panelGrid1s4a3b1" and show messages on p:message of "customMessage1s4". But does not know why these two not working. Anyone can help me to make them work?
<p:commandButton id="cmdVerify1s4a2" widgetVar="cmdVerify1s4a2"
value="Verify" action="approveProfileQualifications"
update="#([id$=panelGrid1s4a3b1]), #([id$=customMessage1s4])"
oncomplete="PF(cmdVerify1s4a2).disable(); PF('cmdReject1s4a2').disable();"/>

You are not updating is right. Change your p:commandButton little
update="panelGrid1s4a3b1 customMessage1s4"
while I believe your p:messages like
<p:messages id="customMessage1s4" showDetail="true" autoUpdate="true" closable="true" />
MORE
You can also use keywords to update:
Keywords are the easier way to reference components, they resolve to ids so that if an id changes,
the reference does not need to change. Core JSF provides a couple of keywords and PrimeFaces
provides more along with composite expression support.
Following are the keywords.
#this Standard Current component. #all Standard Whole view. #form
Standard Closest ancestor form of current component. #none Standard No
component. #namingcontainer PrimeFaces Closest ancestor naming
container of current component. #parent PrimeFaces Parent of the
current component. #composite PrimeFaces Closest composite component
ancestor. #child(n) PrimeFaces nth child. #row(n) PrimeFaces nth row.
#previous PrimeFaces Previous sibling. #next PrimeFaces Next sibling.
#widgetVar(name) PrimeFaces Component with given widgetVar.

Related

PrimeFaces Schedule not showing all times with some SlotDuration configuration

When using the default slotDuration of PrimeFaces Schedule, or "00:15:00" for an example, the component don't show all times. If I change it to some values like "00:45:00" or even "00:15:01", the schedule show all times correctly.
Inspecting the HTML/CSS, in the cases of not showing the time, the <td> tag don't have a <span> tag inside with the time, and has the CSS class "fc-minor"
I couldn't find in documentation about this problem. I already tested with the deprecated slotMinutes, but it has the same behaviour.
Schedule with blank spaces between times:
https://imgur.com/a/TOCey4R
Schedule code:
<p:schedule id="agendaOcupacional" allDaySlot="false" timeFormat="HH:mm" axisFormat="HH:mm"
draggable="false" resizable="false" slotDuration="00:15:00" timeZone="GMT-3"
displayEventEnd="true" value="#{agendamentoBean.lazyEventModel}" locale="br"/>
I'm using Primefaces 6.1.
Thanks.
It appears PF is missing the value for slotLabelInterval which fixes this issue.
I created this GitHub issue: https://github.com/primefaces/primefaces/issues/4896
Submitted this PR: https://github.com/primefaces/primefaces/pull/4897
Hopefully it will be fixed in PrimeFaces 7.1.
For now you can use the Extender to configure it: https://primefaces.github.io/primefaces/7_0/#/components/schedule?id=extender-method

How to show/hide a p:button based on a checkbox selection inside a p:datatable?

I have a simple button,
<h:panelGroup>
<p:commandButton rendered="#{myBean.checkboxSelected}" value="Action" />
</h:panelGroup>
which is set to false and has getters and setters in the bean, that I want to toggle its rendered attribute (or hide/show it) based on whether ANY checkbox inside my p:dataTable is selected. Conversely, if I check one box and uncheck it, I want to be able to hide button as no checkboxes are selected.
My p:dataTable is set up like this.
<p:dataTable id="someID"
selection="#{myBean.mySelectList}"
rowKey="#{myBean.id}">
<p:column selectionMode="multiple" style="text-align:center"/>
....
</p:dataTable>
Any help is appreciated
Short answer: update it when there is more than one item selected.
Longer answer: On each selection, update the number of items server side (or just count the list) and use that value in a 'rendered' attribute of the button (check if > 0, or do that server side and use a boolean) and update the panelgroup on each ajax call or do that from the server as well.
All plain 'logic' when using JSF, nothing special, nothing fancy

primefaces selectManycheck box columns attribute is not working

I am using Primefaces 3.5, as shown in showcase, i am trying to use p:selectManyCheckBox.
<p:selectManyCheckbox layout="grid"
columns="2"
value="#{bean.selectedList}">
<f:selectItems itemLabel="#{bean.value}"
itemValue="#{overrides}"
value="#{bean.overrideValues}"
var="overrides>
</p:selectManyCheckbox>
But columns attribute is not working, is there any way to get column wise disply ?
I had the same problem and I fixed by changing the version of the prime face.
I had 3.2 and changed to 4.0.
For this particular component it seams that it whose added in the last 2 moth.
Requested here and a specific task here.
Is the second time when I also had this kind of problem. I am looking on the prime face showcase website for a specific component and and when I tried that component it didn't work with my version.

Nested use of primefaces datalist and fieldset

Is it possible to use primefaces datalist and fieldset elements in a nested way. My application needs to look something like this:
<p:fieldset>
<p:dataList>
<p:fieldset>
<p:datalist>
</p:datalist>
</p:fieldset>
</p:dataList>
</p:fieldset>
I've tried it as mentioned above but I always get the following error:
javax.faces.view.facelets.TagException: /WEB-INF/flows/mainapp/wholesaleInfo.xhtml #106,105 Tag Library supports namespace: http://primefaces.org/ui, but no tag was defined for name: datalist
The datalist mentioned in the error message is of course the inner one... Any ideas how I could make that work? thanks Nikolaus
Try with dataList camelCase instead of datalist, in the inner one. This should make the error go away. However I am unsure if dataLists can be nested. If it's just for layout - display purpose, you may have a look at p:layout

PrimeFaces DataTable - Row Selection inquiry

How does this code in the PrimeFaces DataTable row selection work?
<p:commandButton update=":form:display" oncomplete="confirmation.show()" image="ui-icon ui-icon-close" title="Delete">
<f:setPropertyActionListener value="#{car}" target="#{tableBean.selectedCar}" />
</p:commandButton>
I am confused by the following: update=":form:display", and image="ui-icon ui-icon-close".
Is this inbuilt into Primefaces? or do I need to create an additional form, or have an external image mapped to it?
update=":form:display" refers to a specific element on the page. The first ':' goes to the root of the page, so there needs to be a component with the id "form" (probably a form) and inside that a component with the id "display". This means after the button actions has completed :form:display will be updated. Note that it's generally not a great idea to use absolute paths as they can be hard to keep up to date when you change the page structure. If the button is on the same level as the "display" component you could just do update="display", or you can do things like update="#form" to update the entire current form.
image="ui-icon ui-icon-close" refers to style classes in your css. These two comes predefined with primeface, but if you want to use custom graphics you can also define your own style classes for them.