'Check' not displayed on selected items from a p:selectManyMenu - jsf

I'm using the selectManyMenu widget from Primefaces 5.3 to display the list of roles users can have in each of our apps.
<p:outputLabel value="Roles:" rendered="#{controller.enabledApp[app.id] and not empty app.roles}"/>
<p:selectManyMenu converter="#{roleConverter}" var="r" filter="true" filterMatchMode="contains" showCheckbox="true"
rendered="#{controller.enabledApp[app.id] and not empty app.roles}" value="#{app.selectedRoles}">
<f:selectItems value="#{app.roles}" var="role" itemLabel="#{role.name}" itemValue="#{role}"/>
<p:column>
<h:outputText value="#{r.name}"/>
</p:column>
</p:selectManyMenu>
The problem is, when I preload these roles from the database, populating the selectedRoles field of the app entity, Primefaces adds the ui-state-highlight CSS class to the table rows used to represent these selected roles, but it doesn't add the ui-state-active to the div that represents the checkbox.
This is what I get:
<tr class="ui-selectlistbox-item ui-corner-all ui-state-highlight" style="">
<td>
<div class="ui-chkbox ui-widget">
<div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default">
<span class="ui-chkbox-icon ui-icon ui-icon-check ui-c"/>
</div>
</div>
</td>
<td>Admin</td>
</tr>
And this is what I should get:
<tr class="ui-selectlistbox-item ui-corner-all ui-state-highlight" style="">
<td>
<div class="ui-chkbox ui-widget">
<div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active">
<span class="ui-chkbox-icon ui-icon ui-c ui-icon-check"/>
</div>
</div>
</td>
<td>Admin</td>
</tr>
I could just change the CSS to display a checked checkbox when the parent tr has the ui-state-highlight class, but I'd much rather solve the problem.
Can this be a bug in Primefaces? Do I have some error that I'm not aware of?

Related

How to change enable/disable a <p:calendar> and an <p:inputTextarea> when a <p:selectBooleanCheckbox> is checked or not, using primefaces?

I have this part of code:
<!-- /row -->
<div class="row" style="margin-top: 15px">
<div class="span8">
<div class="control-group">
<label class="hcg-control-label span5">Ημερομηνία Ανάκλησης Ποινής</label>
<div class="controls span7">
<p:calendar id="recallDate" styleClass="hcg-full-width cursor-pointer" pattern="dd/MM/yyyy"
value="#{penaltiesView.penalty.recallDate}" disabled="true"/>
<i class="fa fa-calendar hcg-input-icon"></i>
</div>
</div>
</div>
<!-- /span -->
</div>
<!-- /row -->
<div class="row" style="margin-top: 15px">
<div class="span8">
<div class="control-group">
<label class="hcg-control-label span5">Σχόλια Ανάκλησης Ποινής</label>
<div class="controls span7">
<p:inputTextarea rows="6" id="recallComments" styleClass="hcg-full-width" value="#{penaltiesView.penalty.recallComments}" disabled="true"/>
</div>
</div>
</div>
<!-- /span -->
</div>
<!-- /row -->
<div class="row">
<div class="span8">
<div class="control-group">
<label class="hcg-control-label span5">Ανάκληση - Ολοκλήρωση Πειθαρχικής Ποινής</label>
<div class="controls span7">
<p:selectBooleanCheckbox id="RevocationOrCompletion" styleClass="hcg-checkbox margin-bottom-10" value="#{penaltiesView.penalty.revocationOrCompletion}" disabled="#{!penaltiesView.canEdit()}" >
<p:ajax event="change" update="recallDate,recallComments"/>
</p:selectBooleanCheckbox>
</div>
</div>
</div>
<!-- /span -->
</div>
which produces the following components:
Now, what I want to do, is to make the calendar component and the Textarea to get enabled when I check the checkBox and if I uncheck it, they must be disabled again. The use of javascript due to requirements is not a valid way. I am having some difficulties on how to make this happen.
Any suggestions are appreciated.
Thank you in advance.
Your elements can't be updated because you have in your code disabled=true for calendar and textArea. If you want to change disable parameter depending on boolean checkbox than disabled value needs to be a value of boolean checkbox. Your boolean field also needs to have geters and setters.
<p:calendar id="recallDate" styleClass="hcg-full-width cursor-pointer" pattern="dd/MM/yyyy"
value="#{penaltiesView.penalty.recallDate}" disabled="#{penaltiesView.penalty.revocationOrCompletion}"/>
<p:inputTextarea rows="6" id="recallComments" styleClass="hcg-full-width" value="#{penaltiesView.penalty.recallComments}" disabled="#{penaltiesView.penalty.revocationOrCompletion}"/>
<p:selectBooleanCheckbox id="RevocationOrCompletion" styleClass="hcg-checkbox margin-bottom-10" value="#{penaltiesView.penalty.revocationOrCompletion}" disabled="#{!penaltiesView.canEdit()}" >
<p:ajax update="recallDate recallComments" process="#this"/>
</p:selectBooleanCheckbox>

How to update a form that contains pivot tables with timer?

I am using a bootstrap carousel to pass the tables (these are generated from the db), I tried to use the prime-faces poll but it only recharges me once and after that the first table remains static and loses transition effect . Any recommendation...
psdta: Primefaces 4.0, and bootstrap 4 are part of the design.
<h:form id="tablas">
<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
<p:dialog modal="true" widgetVar="statusDialog" resizable="false" draggable="false" closable="false"
showHeader="false" style="border: none; opacity: 0.75;">
<p:graphicImage id="refreshTable" value="./../resources/images/cargandoLogin.gif" style="width: 100px; height: 100px; " />
</p:dialog>
<div id="carouselExampleInterval" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="limiter">
<div class="container-table100">
<h:outputText value="#{beansSeguimientoRelease.dateTable}" escape="false"/>
<div class="carousel-item" data-interval="#{beansSeguimientoRelease.contTabla}">
<div id="main-container">
<div class="tituloN">NOTAS</div>
<table class="table table-bordered" style="text-orientation: upright;">
<thead>
<tr>
<th scope="col" style="background-color: #0f7ff4">TEMAS PENDIENTES</th>
<th scope="col" style="background-color: #0f7ff4">NOTAS</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left; border-left: 15px black !important;">
<h:outputText value="#{beansSeguimientoRelease.itemNotas.tareas}" escape="false"/> </td>
<td style="text-align: left;">
<h:outputText value="#{beansSeguimientoRelease.itemNotas.notas}" escape="false"/></td>
</tr>
<tr>
<td style="text-align: right;">Disponibilidad:</td>
<td><h:outputText value= "#{beansSeguimientoRelease.itemNotas.disponibilidad}" escape="false"/></td>
</tr>
<tr>
<td style="text-align: right;">Operador Noc:</td>
<td><h:outputText value="#{beansSeguimientoRelease.itemNotas.operador_noc}" escape="false"/> </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<a id="aPrev" class="carousel-control-prev" href="#carouselExampleInterval" role="button" data-slide="prev" style="width: 5%">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a id="aNext" class="carousel-control-next" href="#carouselExampleInterval" role="button" data-slide="next" style="width: 5%">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<p:poll id="Tpoll" interval="#{beansSeguimientoRelease.cont}" update="tablas"/>
</h:form>
I assume that problem is caused by fact that p:poll is inside h:form and that, by updating entire form, it updates itself too and stops working (maybe you can see something in JS debug console).
Try to wrap up carousel div into h:panelGroup like this
<h:panelGroup id="wrapper" layout="block">
<div id="carouselExampleInterval" class="carousel slide"...>
...
</div>
</h:panelGroup>
and then, when poll interval expires, update only newly added h:panelGroup
<p:poll id="Tpoll" interval="#{beansSeguimientoRelease.cont}" update=":tablas:wrapper"/>

Primefaces Row-expansion not working

I am using primeface rowExpansion
<div class="row">
<div class="col-xl-1 col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right">Notes:</div>
<div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-xs-6">#{order.comments}</div>
<div class="col-xl-3 col-lg-3 col-md-3 col-sm-3 col-xs-3">Requestor: #{order.requestorFullName}<h:outputText value="#{order.requestorFullName}"></h:outputText>
<!-- <p:spacer width="5" height="5" />
<h:outputText value="#{order.currency}"></h:outputText> -->
</div>
<div class="col-xl-2 col-lg-2 col-md-2 col-sm-2 col-xs-2">
Added:
<h:outputText value="#{order.requestedDate}">
<f:convertDateTime pattern="MM/dd/yy" />
</h:outputText>
</div>
</div>
</p:rowExpansion>
I have 3 records in data-table,when I am using the row-expansion,only the first row is showing the data rest 2 other rows are not showing the data ,the data is available in all the 3 records but it shows only in first row expansion in next 2 rows it is coming empty.
Can you help me on that
Thanks

How to open multiple component in p:inplace at once

i need to make all component editable when i clicked on h:commandLink
This my code
<p:dataTable styleClass="borderless" id="projectsTable" var="o" value="#{order.orderList}">
<p:column>
<div class="tasks">
<div class="task-item task-success">
<h:form>
<div class="task-text">
<div class="form-group">
<h:outputLabel for="projectName" value="Project Name:" />
<p:inplace effectSpeed="fast" editor="true">
<p:inputText styleClass="form-control" value="#{o.productName}" required="true" label="text" />
</p:inplace>
</div>
<div class="form-group">
<h:outputLabel for="projectURL" value="Project URL:" />
<p:inplace effectSpeed="fast" editor="true">
<p:inputText styleClass="form-control" value="#{o.price}" required="true" label="text" />
</p:inplace>
</div>
</div>
<div class="task-footer">
<div class="pull-left">
<h:commandLink >
<span class="glyphicon glyphicon-ok-circle" aria-hidden="true"></span> EDIT
</h:commandLink>
</div>
<div class="pull-right">
<h:commandLink action="#{order.deleteAction(o)}" >
<span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span> Delete
</h:commandLink>
</div>
</div>
</h:form>
</div>
</div>
that's link i need to click on it and open all h:inputText
<h:commandLink action="#{order.update(o)}">
<span class="glyphicon glyphicon-ok-circle" aria-hidden="true">
</span> EDIT
</h:commandLink>
Such as linkedIn in editProfile page when click on button appear all editable components
Examples:
Befor click button
After clicked button
First of all, every PrimeFaces component has a javascript representation which is acessible through the widgetVar.
The Inplace's widget has a method called show() that you can use to show the input field for it. Check this code out:
<p:inplace ... widgetVar="myinplace">
<p:inputText ... />
</p:inplace>
<!-- this button's click will show the input -->
<button onclick="myinplace.show()">Click Me</button>
I suggest you to set the widgetVar attribute for the inplace components and call the show method on each one of them inside a function that you can use everywhere you want:
<script>
function showInplaces() {
myinplace1.show();
myinplace2.show();
...
}
Cheers
During my lunchbreak I was curious, so I did have a quick look.
I looked at the generated source in the showcase of the first item:
<span id="j_idt88:basic" class="ui-inplace ui-hidden-container" data-widget="widget_j_idt88_basic">
<span id="j_idt88:basic_display" class="ui-inplace-display" style="display:inline">Edit Me</span>
<span id="j_idt88:basic_content" class="ui-inplace-content" style="display:none">
<input id="j_idt88:j_idt91" name="j_idt88:j_idt91" value="Edit Me" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" role="textbox" aria-disabled="false" aria-readonly="false" type="text" />
</span>
</span>
I noticed the class='ui-inplace-display' class which is on each 'component. The following jquery code selects all inplace components that can be clicked:
$('.ui-inplace-display')
I tried this in the FireFox developer console resulting in the following output:
Object { length: 5, prevObject: Object, context: HTMLDocument → inplace.xhtml, selector: ".ui-inplace-display", 5 more… }
I know you can enable the editing by clicking on an item and so I had to find a way to click on each one. Fortunately, you can give each of them a click by just appending .click() to the selector. It will be applied to each of the components:
$('.ui-inplace-display').click()
And like mentioned, you do not need any jsf button for this, just a plain html one to execute the javascript in an onlclick:
<input onclick="$('.ui-inplace-display').click()" value="Click to edit" type="button">
works perfectly.
As you can see, it pays to learn the basics of webdevelopment before diving into using more complex frameworks since no framework ever solves all of your problems and from time to time (more often then you think), you do need a little low-level javascript

java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Arrays$ArrayList with modifiers "public"

I have such an p:selectManyCheckbox and it works ok:
<p:selectManyCheckbox id="groups" value="#{myBean.selectedGroups}">
<f:selectItems value="#{myBean.myGroups}" var="group" itemValue="#{group.id}" itemLabel="#{group.name}"/>
</p:selectManyCheckbox>
Now I have to convert it to the Tree component (adding Group parent to data), but my PrimeFaces version 3.4.1. doesn't support such a functionality. For better customization I decided to make this selectManyCheckbox manually with html and <ui:repeat>):
<div id="j_idt25groups" class="ui-scrollpanel ui-scrollpanel-native ui-widget ui-widget-content ui-corner-all" style="height: 200px;">
<table id="groups" class="ui-selectmanycheckbox ui-widget">
<tbody>
<ui:repeat value="#{myBean.myGroups}" var="group" varStatus="status">
<tr>
<td>
<div class="ui-chkbox ui-widget">
<div class="ui-helper-hidden-accessible">
<ui:fragment rendered="#{myBean.selectedGroups.contains(group.id)}">
<input id="groups:#{status.index}" name="groups" type="checkbox" value="#{group.id}"
checked="checked">
</input>
</ui:fragment>
<ui:fragment rendered="#{not myBean.selectedGroups.contains(group.id)}">
<input id="groups:#{status.index}" name="groups" type="checkbox" value="#{group.id}">
</input>
</ui:fragment>
</div>
<div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default">
<span class="ui-chkbox-icon"></span>
</div>
</div>
</td>
<td>
<label for="groups:#{status.index}">#{group.name}</label>
</td>
</tr>
</ui:repeat>
</tbody>
</table>
</div>
Now i have a problem with this code #{prpBean.selectedGroups.contains(group.id)}:
java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Arrays$ArrayList with modifiers "public"
Is it possible to solve this problem?
Does it exists an easier way to convert such a structure to the Tree?
The contains() method of java.util.Arrays$ArrayList is not immediately accessible by Java reflection. This could be a (corner case) bug in the EL implementation being used. It may work in a different EL implementation. It may be worth a bug report to the EL implementation vendor, but it is what it is.
When creating selectedGroups, use new ArrayList() instead of Arrays#asList() and all should be well.

Resources