primefaces : how to disable html escape in <p:inplace> - jsf-2

i'm using primefaces <p:inplace /> and <p:editor /> to simulate inline editing in my project.
the problem is that when i'm finished editing the inplace shows me html code as a result.
Image of the probleme :
what i want is some thing like this <h:outputtext escape="false"> but in <p:inplace/>
when i searched i found something about averriding the InplaceRendered and i'm beginner and i really don't know how to do that.
can anyone explane to me how to?
thinks.

Editing the PrimeFaces code would be the last option to take.
There was already a similar issue, take a look at this page:
PrimeFaces - Issue 4330
The solution for you could be something like:
<p:inplace editor="true">
<f:facet name="output">
<h:outputText value="#{yourBean.text}" escape="false" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{yourBean.text}" />
</f:facet>
</p:inplace>

Related

Datatable cellEditor functionality in forEach generated Datatable

I am trying to generate a editable datatable dynamically dependend on the resultset of an previously executed SQL-Query.
Depending on which columns would have a constant value I am trying to not render them. That part of the code works just fine, everything is displayed as i would like it to be.
My issues are with the cellEditor. I generate my datable as follows:
<p:dataTable ajax="true" var="mBT" value="#{stammdaten.bbvList}" id="meldeBearbeitungsTable" editable="true" editMode="cell" scrollable="true" scrollHeight="400" style="width:600px">
<p:ajax event="cellEdit" listener="#{stammdaten.onCellEdit}" update=":Mb:message"/>
<c:forEach var="column" items="#{stammdaten.columns}">
<p:column headerText="#{column.header}">
<f:attribute name="myCol" value="#{column}" />
<span>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{mBT[column.property]}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{mBT[column.property]}">
<p:keyFilter regEx="/[0-9]/i"/>
</p:inputText>
</f:facet>
</p:cellEditor>
</span>
</p:column>
</c:forEach>
</p:dataTable>
bbvList is a List of beans with different values.
columns is a List of beans to identify the header-Texts coresponding to the respective variables.
So now the issue itself:
This is how the cellEditor looks like when i click on it:
Issue-Picture
So in that example i tried to edit the field with the value "8" in it. onCellEdit gets triggered (a System.out.println is getting printed on the console) but i cant actually change the value in the respective field.
Does have cellEdit issues with the forEach initialisition of the dataTable? If yes is there a way to fix it? Else what am i doing wrong?
Since only a specific component of the html-side of code isnt working as it should be i won't post unnecessary java-Code for now. If needed i will add that as well.
Hope someone can help :)
Turns out the attribute and/or span where the cause of the problem. Simply removing them solved the issue with the cellEdit.
following works fine :
<p:dataTable ajax="true" var="mBT" value="#{stammdaten.bbvList}" id="meldeBearbeitungsTable" editable="true" editMode="cell" scrollable="true" scrollHeight="400" style="width:600px">
<p:ajax event="cellEdit" listener="#{stammdaten.onCellEdit}" update=":Mb:message"/>
<c:forEach var="column" items="#{stammdaten.columns}">
<p:column headerText="#{column.header}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{mBT[column.property]}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{mBT[column.property]}">
<p:keyFilter regEx="/[0-9]/i"/>
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
</c:forEach>
</p:dataTable>

Primefaces datatable pagination resets filter

I'm using a p:datatable with filters and pagination. Both work fine individually, but if I filter first then move to the second page of results, the filter is removed and I'm seeing the second page of the original data set. Here's what my table looks like :
<p:dataTable value="#{bean.products}" var="product"
paginator="true" paginatorPosition="bottom" rows="5"
filteredValue="#{bean.filteredProducts}"
rowKey="#{product.prdctId}">
<p:ajax event="sort" skipChildren="false" />
<p:column headerText="Description" filterBy="#{product.description}" filterMatchMode="contains"
sortBy="#{product.prdctId}">
<h:outputText value="#{product.description}" />
</p:column>
(other columns)
</p:dataTable>
Any ideas?
Using Primefaces 5.2, JSF 2.0.3
Edit : After searching a bit more, I found another post dealing with the same issue, but it was never answered.
<p:dataTable value="#{bean.products}" var="product"
paginator="true" paginatorPosition="bottom" rows="5"
filteredValue="#{bean.filteredProducts}"
rowKey="#{product.prdctId}">
<p:ajax event="sort" skipChildren="false" />
<p:column headerText="Description" filterBy="#{product.description}" filterMatchMode="contains"
sortBy="#{product.prdctId}">
<h:outputText value="#{product.description}" />
</p:column>
(other columns)
Add in your datatable: widgetVar="productTable"
in your button add this: oncomplete="PF('productTable').clearFilters();"

primefaces dialog box and datatable checkbox selection

I want to display the selected rows of a table in a dialog box but I have an empty dialog box even if I check one or more line nothing is displayed .. I realy don't know what is the cause of my problem .. I hope there will be someone who can help me (I m a beginner in jsf2 and I just discovered primefaces I really want help thanks soo much in advance ) this is my jsf :
<p:outputLabel for="product" value="" />
<p:dataTable id="product" var="ligne" value="#{productBean.myProducts}" selection="#{productBean.selectedProducts}" style="margin-bottom:0" rowKey="#{productBean.id}">
<p:column selectionMode="multiple" style="width:16px;text-align:center"/>
<p:column headerText="Code">
<h:outputText value="#{ligne.code}" />
</p:column>
<p:column headerText="designation" >
<h:outputText value="#{ligne.title}" />
</p:column>
<f:facet name="footer">
<p:commandButton process="product" update=":form:multiProductDetail" icon="ui-icon-search" value="View" oncomplete="PF('multiProductDialog').show()" />
</f:facet>
</p:dataTable>
<p:dialog header="Products" widgetVar="multiProductDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false" width="200">
<p:outputPanel id="multiProductDetail" style="text-align:center;">
<ui:repeat value="#{prodBean.selectedProducts}" var="ligne">
<h:outputText value="#{ligne.code} -- #{ligne.title}" style="display:block"/>
</ui:repeat>
</p:outputPanel>
Did you put a
h:form
inside this page
Is there data inside selection="#{productBean.selectedProducts}" .Can you a debug point there and see or put some sysouts in the getters and setters of selectedProducts.
Can you share your product code and check if selectedProducts is null or not
system.out.println("products"+selectedProducts.get(0))
best
vj

Tooltip for each row in data table

This questions screams to be a duplicate of JSF 2.0 + Primefaces 2.x: Tooltip for datatable row but since this old question has NO working/satisfying solution for me and there's no way (?) to get attention back to it I opened this new one.
It's very simple:
I have a dataTable (with JSF-standard or with primefaces) and I'd like to add a different tooltip for EACH row (not just for one field in it!).
What I tried so far:
<pe:tooltip value="This is row number #{rowIndex}"
for="#(#table1 tr[role=row][data-ri=#{rowIndex}])"
atPosition="top center" myPosition="bottom center"
shared="true" />
where #table1is the ID of my data table . This came to my mind because of this.
And both solutions from JSF 2.0 + Primefaces 2.x: Tooltip for datatable row : the first solutions works, but only for ONE field / id and not for the whole row. The second solution won't work at all for me.
And I'm 100% sure that both - primefaces & primefaces extensions - are working for me, I tested it.
I've done some test and this approach works perfectly:
<p:dataTable var="entry" value="#{....}" styleClass="myTable" rowIndex="rowIndex">
<p:column headerText="Header 1">
<h:outputText value="#{entry.value1}" />
</p:column>
<p:column headerText="Header 2">
<h:outputText value="#{entry.value2}" />
<pe:tooltip value="This is row number #{rowIndex}" forSelector=".myTable tr[role=row][data-ri=#{rowIndex}]"
shared="true" atPosition="top center" myPosition="bottom center" showDelay="500" />
</p:column>
</p:dataTable>
Note that in order to the data-ri attribute to be placed on datatable rows, you need the to add the attribute rowIndex (rowIndex="rowIndex").
It also worked with
<p:tooltip for="#(.myTable tr[role=row][data-ri=#{rowIndex}])" value="This is row number #{rowIndex}" />
You can also do it without using primefaces extensions. This example code works for me with primefaces 5.2.
Be aware that in primefaces 5.2 the p:dataTable attibute is rowIndexVar and not rowIndex as in the example above.
<h:form id="idform">
<p:dataTable var="komp"
id="idDataTable"
value="#{kompselect.listKomponenten}"
rowIndexVar="rowIndex"
selection="#{kompselect.selectedKomponente}"
rowKey="#{komp.name}">
<p:column>
<h:outputText id="otSelKomponente" value="#{komp.name}" />
<p:tooltip rendered="#{komp.displayToolTip}"
for="idForm:iddataTable:#{rowIndex}:otSelKomponente"
value="this is my Tooltip"/>
</p:column>
</p:dataTable>
according to this commment https://stackoverflow.com/a/13327334/4851983 (thaks BalusC )
Let primefaces link the objects automatically. I could show a tooltip for a textArea Primefaces 3.5 , as is show below
<p:dataTable id="commentsTable"
value="#{historyReq.commentsFromReq}" var="comment"
emptyMessage="#{localeMsg.roles_table_empty}"
rows="10"
styleClass="myTable"
rowIndexVar="rowIndex">
<p:column headerText="HEADER A">
<h:outputText value="#{bean.valorA}" />
</p:column>
<p:column headerText="#{HEADER B}">
<p:inputTextarea id="txtArea" cols="45" rows="1"
value="#{bean.valorB}"
readonly="true"
disabled="false"
autoResize="false">
<f:converter converterId="commentsConverter" />
</p:inputTextarea>
<p:tooltip for="txtArea" value="This is row number #{rowIndex}" />
</p:column>

Filter Facet is not working in Richface 4.3x

In the Code below, You can observe two things:
1) Default sorting is getting utilized.
2) Image based custom filter is used.
Problem I am facing : When I click on filter image default sorting is getting triggered.
Need a way by which If I click on filter, default sorting doesn't get triggered. (This was achieved in Richface 3.3 by putting this custom filter in filter facet.)
Any help or hint would be greatly appreciated.
<rich:column sortBy="#{model.modVal}" label="Model Value"
sortable="true" id="modelVal" rendered="#{backingBean.renderMap['modVal']}">
<f:facet name="header">
<h:outputText value="Model Value" />
<h:graphicImage title="Filter"
value="#{backingBean.dataModel.modValFilter }">
<a4j:ajax event="click" render="filterCol"
execute="#form"
listener="#{backingBean.loadModalPanelData('modVal') }"
oncomplete="#{rich:component('filterCol')}.show()">
</a4j:ajax>
</h:graphicImage>
</f:facet>
<h:outputText value="#{model.modeVal}"
title="#{model.modelVal}" />
</rich:column>
Use manual sorting, and place a click-able panel in your header for sorting, and another panel for filtering.
The filter facet has been deprecated in favour of the header facet. So what you used to have in the filter facet, you can place in the header facet:
<f:facet name="header">
<h:panelGrid>
<h:outputText value="Model Value"/>
<h:graphicImage title="Model Filter"/>
</h:panelGrid>
</f:facet>

Resources