I want to export a datatable in .txt form with a vertical bar ("|") separator.
Is there any sample code that can be used for this case?
The showcase on primefaces is too complex and doesn't work for me.
You should be able to reuse csv exporter, and define attribute options of p:dataExporter with a new instance of CSVOptions. From there, you'll be able to define your own delimiter.
See a sample here https://primefaces.github.io/primefaces/11_0_0/#/components/dataexporter?id=customization
If txt extension is that important to you, maybe you can try to inherit from DataTableCSVExporter and override DataTableCSVExporter#getContentType and DataTableCSVExporter#getFileExtension methods
See a sample here https://primefaces.github.io/primefaces/11_0_0/#/components/dataexporter?id=custom-export
Related
I have a complex Bean object that I want to update. Because it is too much complex, it can't be edited in the DataTable (inplace editing). Let's say that my page have this structure:
-> Input Form
-> DataTable for Listing
So I save the object using the Input Form and it appears inside the DataTable. This part is easy. Now, I need to edit the object inside the DataTable. Since the object is too much complex, it is not viable to edit in-place. So I must pick the row data and put it in a form to be able to sumbit it.
My problem is, I haven't come to a way of editing the data that I would like.
I've done it in multiple ways.
I've created a page only for the edit. I call the page passing the object's ID in the URL.
I copied the Input Form inside a Dialog. While this is great for editing, using a dialog had led me into problems (complex validations patterns, dialogs inside dialogs, etc).
I put the row data back into the Input Form and use Primefaces-Extensions spotlight component to ensure that the user will only work within the form. I've added a button to cancel edition also.
I didn't like any of them, although the third is the best of them, to me. But I'm also out of ideas of how to design data editing. Do you guys have some edit designs that you would like to share?
Thanks in advance.
I've read a lot of posts about custom renderers, but I can't seem to find, what I am looking for.
It is, again, about the combobox. XPages renders the combobox in read mode as a table and the custom renderers I've found, help to write out just the value of the field.
What I would like to do though, is to wrap the value in HTML input tags, so that in read mode, the Bootstrap styles are applied to it.
Is it possible to do that in a custom renderer and if so, how would I do that?
Your help is greatly appreciated.
Wouldn't it be easier to just use a computed control when in read mode and have that control output the input tag you want? Hide the combobox in read mode and vice-versa?
Howard
Is there any chance to get the html content (mime) from a rich text component without any datasource. I would like to grab the content from the field like this. getComponent("FieldName").value but this dosen't work.
thanks.
You can bind the control to a scoped variable; for example, #{viewScope.comments}. You can then retrieve the submitted value from the scope instead of from the component itself; for example, viewScope.get("comments").
Alternatively, you can set a dataContext variable to a JS expression, e.g. <dataContext var="richText" value="#{javascript:return {value:""};}" />. Then you can bind the control to #{richText.value} and retrieve it via the same expression.
And, of course, you could define a managed bean and bind the control to one of its properties. This option provides the most flexibility, but isn't quite as simple as the other two options above.
The solution for my problem is
getComponent("FieldName").getValue()
thanks for your help.
I have a form which one of it's fields is a code and description, also a button for opening a popup window that contains a list of all of the available codes.
when the user double clickes a row from that table i want to set these values to the code and description. - how can this be done?
Another question, I want to create this popup and table to be initialized dynamically - by that i mean that if i have a few forms in my application, when ever i have a field which has a description i want to be able to open this popup and to see the available list for that field. (every field can be from a diffrent table). is it possible to create something like that? if so, how?
Any help will be appritiated,
Thank's In Advance.
Yes, it is possible. Even more, many component libraries have ready to use popup/dialog components, such as RichFaces with <rich:popupPanel> and PrimeFaces with <p:dialog>.
If you do not want to use a component library for some reason, you would need to create a custom component for this which generates basically an absolutely positioned HTML <div> element with a CSS overlay which get shown/hidden by JS on a particular click/action. The HTML/CSS/JS part should be relatively simple if you are familiar with those languages. The JSF part is somewhat hard if you have never created a custom component before, but it should be possible with a composite component as well, so you could also just create one with pure XHTML. The updating/refreshing can just take place by the usual <f:ajax> means.
Unfortunately, OpenFaces Datatable has not yet an export capability unlike Primefaces or IceFaces.
While Exporting is a piece of cake, filtering an IceFaces or primefaces datatable is less easy, Yet primeFaces's filtering does not work with JSF DataModel (sad but true).
Using OpenFaces DataTable filtering is a piece of cake and so handy and powerful.
But how about The end user who wants to export a datatable that s/he filtered, to a format like CSV or MS Excel.
The great Dmitry from OpenFaces, gave me a hint :
Use OpenFaces DataTable method: getDisplayedRowDatas() that will grab the currently displayed rows from a datatable, then use some thrid library like Itext to export in PDF for example.
In my head, this should go this way:
Create a backing bean for this purpose.
Add Apache POI third library to the classpath
Write code using Apache POI to export the content of the OpenFaces datatable with its method getDisplayedRowsDatas() - but I am afraid this method does not return the names of columns' headers - or grab the HTML table rendered by an OpenFaces Datatable as a buffered string and use Apache POI to produce an Excel file streamed with the Buffer.
In the MyFaces example I came across recently: MyFaces Datatable Export Example, the developer uses Myfaces component <t:buffer value=#{myExportBean.myBufferString}> datatable here </t:buffer /> to transform the content of the datatable to a buffered String which makes things easier. JSF Core does not have such component unfortunately.
Did someone come across this before? Help or better alternatives are much appreciated.
You can check out the experimental DataTable export API, which is available in the current nightly build. We'll declare this API officially if it stands the test of time. For now, only CSV export is available, but you can write your own exporters for other formats. Here's the code that you should put in your action handler to make it work:
DataTable myTable = Faces.component("form:myTable", DataTable.class);
myTable.export(new CSVTableExporter());
It exports the data for all of the rows and columns as currently displayed by the table (only the current page of a paginated table is exported currently).