inputText inside table header: how to render only dataTable content - jsf

I have a dataTable with a list of employees.
One column of the dataTable is the names of the employees.
I want to have an inputText inside the header of the column which the user can use to filter the employees by their names, e.g. when the user writes "smi" in the inputText, the dataTable should only show the employees with the name starting with "smi" like Smith. The table data should update while the user is writing into the inputText, that is why I am using ajax here.
This is my column:
<h:column>
<f:facet name="header">Name
<h:form>
<h:inputText id="suchString" class="suchString"
value="#{mitarbeiteransicht.suchString}">
<f:ajax event="keyup" execute="suchString" render="ma-tabelle" />
</h:inputText>
</h:form>
</f:facet>
#{ma.bezeichnung}
</h:column>
ma-tabelle is my dataTable.
Everytime the table is rendered, the inputText inside the header is losing the focus and the user needs to click it again.
Is there a way around this? Is it possible to exclude the table headers when rerendering?

Related

How to export data table results in primefaces?

In my application we are using primefaces 6.0, here we are having one data table. To export that table values we are using primefaces data exporter.
In that table am having one column value has hyperlink, on click of the hyperlink we will display some data in model panel.
Now what is my issue is , at the time of export, i want to export the content what i am showing in the model panel instead of hyperlink. How can i achieve this?
We can achieve this by CSS styles, i know the data to export, That is in my current object so i have added in output label and applied style as display none. when i export, the display none output label data exported.
<p:column>
<f:facet name="header">
Header
</f:facet>
<p:commandLink styleClass="linkStyle" action="#{controller.opendialog(tc.optTagInfo)}">
<i class="fa fa-info-circle" aria-hidden="true"></i>
<h:outputLabel value="#{tc.optTagInfo}" style="display:none;"/>
</p:commandLink>
</p:column>

How to avoid reload entire table while deleting a single row in p:dataTable

I'm using a web application with Prime Faces.
In my datatable, in which a column is an image, I've the pagination. So I never load too many rows.
For each row I've the button "delete row". Here the code
<p:dataTable id="dataTableUploadedImages" var="singleRow">
...
...
<p:column headerText="#{msg['azioni']}" width="70">
<div align="center">
<p:commandButton icon="ui-icon-trash"
title="delete Row"
ajax="true"
action="#{myController.deleteRow(singleRow.id)}"
update="dataTableUploadedImages">
</p:commandButton>
</div>
</p:column>
</p:dataTable>
After clicking over the button, the application refresh the entire table instead of simply remove the single row.
In this page, refreshing all the rows is expensive (because a column contains an image) and slow down the application.
Is it possible to remove a row without reloading the entire table?

primefaces selectonemenu and f:selectonemenu in datatable

I am using primefaces 3.5
I have a p:selectonemenu in one of the column in datatable. and also I have a submit button on another column of same datatable. When I do a submit the row will get removed.
Here when I am selecting 'Other' then do a submit action and updating the form, the p:selectonemenu items in other rows is getting 'other' as first value. What is way to set 'other' to last value everytime
<p:column headerText="Buyer Response" style="white-space:pre-line;">
<p:selectOneMenu value="#{buyerInProcessBean.subject}"
id="buyerResponseId" >
<f:selectItems
value="#{buyerInProcessBean.subjectMap[trans.decisionrule.ruleId]}"
var="subject" itemLabel="#{subject}" itemValue="#{subject}"></f:selectItems>
<f:selectItem itemLabel="Other" itemValue="Other" ></f:selectItem>
</p:selectOneMenu>
</p:column>
Since you have
<p:selectOneMenu value="#{buyerInProcessBean.subject}">
The subject is shared between all rows, of course, other select menus will have the same value as the one selected (other in your case). For that, I suggest a simple fix, you have to move the subject attribute to the objects you are iterating on.
Another fix, is to set the subject attribute to "Other" once your method executed on submit is finished. But with this, even the changed selectmenu will lose "Other" as value.
So in conclusion, you have to change your logic, so that subject won't be shared between rows

Is it possible the preselect a cell in Primefaces DataTable component?

is it possible to preselect a cell in the Primefaces DataTable component? How do I do that? Tried it already with a Primefaces Cell object with a Getter, but this is not called by my data table :-(.
I need this because I have to restore the selection of the cell done a request before, if validation tells me, that a required field in the form was not filled.
This is my xhtml code snippet:
<p:dataTable id="select-start-pos" var="item"
selectionMode="singlecell"
value="#{frankingController.startposItems}"
selection="#{frankingController.selectedCell}"
styleClass="startPosGrid">
<p:column id="startposcol1">
<h:outputText value=""/>
</p:column>
<p:column id="startposcol2" rendered="#{frankingController.startposColumns > 1}">
<h:outputText value=""/>
</p:column>
</p:dataTable>
Thank you for your help!
Mike
No and 3.x doesn't have cell selection feature
You can use Sheet control instead of Datatable, it has row selection feature.
http://www.primefaces.org/showcase-labs/ui/sheet.jsf

Expand functionality for rows in Richfaces DataTable

I am looking for a way to implement a expand functionality to the rows of a Richfaces DataTable. The user would click a "+" link located in the first column (of each row) of the Datatable and the row would "expand" (meaning new text would be shown between the current row and the next).
I have that working, the only problem is that all the information in the expanded view is displayed in the first column section of that row. What I am trying to do is to show the "expanded" text in the whole row (as if the "expanded" text row is not divided by the columns).
Any suggestions? I'm a bit new at jsf/richfaces, so any sample code would be appreciated.
You can do this with the breakBefore attribute on the rich:column component. There is an example of its use on the RF demo page.
It would work for you if you had the last column define the breakBefore attribute. An example:
<rich:dataTable id="mytbl" value="#{mybean.mydata}" var="row">
<rich:column>
<a4j:commandLink reRender="mytbl">
<h:graphicImage value="#{row.toggleImage}"></h:graphicImage>
<a4j:actionparam name="shown" value="#{not row.expand}" assignTo="#{row.expand}"/>
</a4j:commandLink>
</rich:column>
<rich:column>
<f:facet name="header">col 2</f:facet>
<h:outputText value="#{row.col2}"/>
</rich:column>
<rich:column breakBefore="true">
spans all the other columns
</rich:column>
</rich:dataTable>
One way for this is you can use the JQuery feature.
Demo link http://jsfiddle.net/BU28E/1/ .
One extra overhead here is you need to check how the rich:dataTable renders as Html and provide the DOM model for jQuery. It is bit tricky to have such feature in richfaces and it needs some complex workarounds.

Resources