Tag Archives: XPages - Page 3

Moving on with Excel Export part 5 : XPages Export

In the previous parts (Part 1 Part 2 Part 3 Part 4) we covered plain export, styling your exports and doing selective exports. Today I want to show you how to create more advanced and flexible way to get your data using a java object that we use for the export.

We start by creating 2 java classes one for the export and one of the Export Data

screen247

Then in each class add implements Serializable and the private variable on the row below. This is so the java VM can swap the data out disk if needed.

screen245screen246

 

 

 

 

 

We will start by creating our data class, very simple. Check what type of data you want to export in each column, in my case I want to export

screen248

And then we use the generate setters/getters function in DDE by right clicking in the source window

screen249

And select all variables you want to autogenerate setter and getters for an click on OK

screen251

Time to create the getData function in the Export class the important thing here is that we return a a java object of the type List.

screen257

I also create the function as static because I will only run this function and return the data once. This is the code for the export class. The important thing to point out is

The I create the Exportdata object on each row and store it in the RowData variable

And when I have populated it I add it to the Data ArrayList Object the is returned from the function at the end.

In my Excel export component in All properties datarowexport and I select to create a wgpoi:ListObjectDataSource.screen194

And click on the buildValues property to add some source

screen258

And we add this simple code to get the data from the Java objects returned you can expand you getData class and sending in filter parameters from the XPage as we did in Part 4 of this series but in this case the filtering will be done in java.

screen259

But wait, you might say how do we populate the column data. That’s the great part of the implementation. You write the name of you variable in you data class and the getter will do the rest. so in this case it will call getName from your row class that is returned.

screen260

With this new way of exporting you can combine the data from different sources not only one as I’ve shown in the past parts of this series of posts and giving even better exports to you users.

Integrating a better export into your application will make your users happier

Moving on with Excel Export part 4 : XPages Export

The recent parts of this series has shown you how to create excel exports from a view and also changing the layout of the reports with headers and logos. This post will show you how to filter the data in your excel reports both using keys and fulltext searches. Let’s get started.

To get some filtered export we add an combobox into our XPage and in this case to show both a Export with a key and search we have two buttons for the different export options.

screen237

 

 

 

 

 

 

The code behind the combobox is a standard lookup fro the value data

screen235

 

 

 

 

 

And storing the information within a viewScope variable ExportData

screen233

 

 

 

 

 

 

 

 

The setup behind the buttons is the same as we done in the previous posts but we add a scriptblock before doing the actual export

screen231

 

 

 

 

 

 

 

If we look at the simple formula for a key based export.

screen232

 

 

 

 

 

 

 

 

 

 

 

 

We clear the ExportSearch viewScope var I’ll explain this later and assign the ExportData var into the ExportKey var. The view we are working against is an ordinary view with a categorized first column.

screen236

 

 

 

 

 

 

What you need is assigning the key param with the viewScope.ExportKey. In this case I’ve also assigned the search param. But in an ordinary case you would probably assign only one of them. Depending on if you want to get all documents by category or by Fulltext search.

screen238

 

 

 

 

 

 

The code behind the search export button is this

screen230We place a standard FT search formula inside the ExportSearch viewScope variable. Selecting all documents that the field Region has the value stored in the ExportData viewScope variable.

So exporting to excel with user customized data has never been easier. 

Apache POI for XPages has more options up it sleave so this series will continue so stay tuned in.

Moving on with Excel Export part 3 : XPages Export

Making you report look a bit nicer with some formatting.

Excel reporting from views can be so dull and boring the XPages for POI can give you more options in this matter and help you create some design to your report.

1. Customizing your template

Because POI is using a copy of you template you can customize your temple with logos and predefined information.

screen210

 

 

 

 

 

We need to import this new template and change the startRow and template name

screen213

In this case we start at row 12 below the logo and we assign the new template with the logo that we created. Note that the data will be placed on the row below the one you specified, don’t know why but good to know.

screen214

 

 

 

 

 

 

 

 

 

And the Export will be a combined with the logo from the template and the data from the Domino view.

But we want more

2. Setting up a header for you data

This can be done in two ways 1 directly in your template but that isn’t good in if you want to add a column that you need to change the template or if you want to use the template for multiple exports.

So what we do is that we add columns to our Export above the data, we need 4 columns for this example.

screen215

We click on add on cellValues and add 4 items of cellValue and as you can see we could also add data to Excel bookmarks. Could be handy if you have a multi sheet excel file.

screen216

We specify the columnNumber, rowNumber and because we know the header value we write it but we could actually compute the value also. But a header in plain text is quite dull so we click on cellStyle, scroll down and set the property to get bold on the font and a bigger size.

screen218

Your Excel export with a custom logo and a styled header is now ready. There is lots of stuff to cover with POI and application integration so this series will continue, the more I dig into POI for XPages the more I love it.

screen219

 

 

 

 

 

 

 

 

 

Part 1: http://xpagedeveloper.com/2015/if-your-user-want-reports-in-excel-you-should-read-this

Part 2: http://xpagedeveloper.com/2015/moving-on-with-excel-export-part-2

Moving on with Excel Export part 2 : XPages Export

In my last post I wrote about how to in some simple steps generate an automated export of an view to excel. In this post I will show you how to fine grain this using the excel component instead.

Start by creating a blank excel file note what the sheet you want to place data on is called usually Sheet1 if you have an english version of Excel. Save and import it as a file resource in the database, name it export.xlsx

Now create a new XPage add a button and the Excel component POI Workbook

 

 

 

 

 

This is how the result should look

screen188

 

 

 

 

 

Now add a simple action to the Export button

screen189

 

 

 

 

 

 

 

 

 

 

 

Select the Excel Component and go to all properties and create a new resource template

screen190

In the resource template specify the name of your excel template

screen191

 

 

 

The template is now ready to be used and we can now move over to setup the actual data that should be added to the spreadsheet. create a new dominoViewSource

screen194

Specify your view name in my case Images

screen195

Look at your view and note down the column headers, I have 4 columns with the names Topics, Size, Created and last a calculated column called Ext

screen198

Add four columns in your component

screen196

 

 

 

On each column add the Column number in the Excel sheet where the data should be placed and the name of the column.

screen201

 

 

 

 

In my case I ended up with this

screen200And now to we need to add the name of the exportfile and the easiest thing to forget the sheet name where you want to place the export data, Sheet1 in my case.

screen202

Now you view export is a bit more advance and you can specify what to export and in what column.

I will continue the series and show you more about the power of POI for XPages, stay tuned.

2016 Update that I got from a developer Lisa Gerlich that you might run into
I was having problems exporting more than 1000 documents using the
poi4Xpages excel workbook widget. I ended up posting on OpenNTF and
got an answer.
There is a property under the datasource property called maxRow. It
defaults to 1000. You can set the value as high you dare.

If your user want reports in Excel you should read this

XPages did get a great addon more than a year ago to be more exact 13:th of September 2013. It was when Christian Güdemann uploaded the first version of POI for XPages. Apache POI is a rather old apache project, 13 years to be exact. And there have even been a Notes in 9 show by Paul Calhoun on how to use the standalone version of Apache POI.

But Christians version makes everything that much simpler to get the Excel file out to the end user, start by going to poi4xpages.openntf.org/ or essentials.openntf.org/ if you want lots of more great XPage addons. Download the latest version of one of the project.

Now you need to install the OSGI plugins into your designer and to the server, and David Leedy as recently created a notes in 9 video on how to install plugins into the designer and the server.

And when you have installed POI for XPages in both places you are good to try it out.

It’s very simple, Add the poi library to the database you want to use it in you do this in xsp.properties in the  Page Generation tab

 

 

 

 

 

 

Now you are ready to create a new XPage, when you have created the XPage.

 

 

 

 

 

Drag the simple View Export into you new Export XPage also create a button on your XPage

screen183

 

 

 

 

 

Click on the button and create a simple action

screen184

 

 

 

 

 

 

 

 

 

 

 

 

Select the sveId, you should find the ID of your simple Export control in the list.

Select you export component and select “All properties”

screen185

Fill out the downloadFileName with a name of you choice i.e export.xlxs

 

also select if you want if the view headers should be exported includeHeader and write the name of the view you want to export view.

Open up the XPage and click on the button and you export will be sent to you client.

Some performance tips for your Domino / XPages servers

When your applications has grown very big you might face a problem with performance in this case I had a customer with quite a large crm system that in some cases got very high disk io but the cpu didn’t spike.

neither did the memory almost 50% not used by the system.

So what I did was I increased the memory available for the XPage runtime JVM using HTTPJVMMaxHeapSize

and to get get better database performance I increased the database IO buffers using

NSF_BUFFER_POOL_SIZE_MB

also using cacheset tool I increased the amount of memory that Windows will cache files using, this can give you quite a lot of performance because Windows will keep more files in memory instead of reading everything from disk and if you have a newer server with more than 8GB of memory why not use the memory. You can change this when the server is running and find your optimal settings.

You need to trim this depending on how much free memory your server has and you don’t want to run out of memory.

If you have some more tips for the community feel free to comment.

Maximum file upload size in HCL Domino all the places to edit

If you ever wanted to increase the file upload size in Domino you have probably seen that there are several places to update depending on the configuration. I was increasing this on a server this week and missed one of the places and couldn’t understand where I missed, Per-Henrik Lausten pointed me what I missed. So I though I would write a post about this I might help someone else, or help me the next time I forget.

Open up the Server document and go to the “Internet Protocols” tab and the “HTTP” tab

FileUpload1

 

 

 

 

 

 

At the bottom right corner, to the “HTTP Protocol Limits” Section

FileUpload2

 

 

 

 

 

 

 

And change the “Maximum size of request” to the size you want to increase to

Now move to the basic tab and check if the server is using “Internet Sites”

FileUpload3

 

 

 

 

 

 

 

 

If your server doesn’t load from “Internet sites” you need to open the “Internet protocols” tab again

and follow the same instruction as in “Internet Site” document.

in other case close the server document and open up the view “Server\Internet Sites”

FileUpload4

 

 

 

 

 

 

 

 

 

Open up the corresponding Internet Sites that you want to change or open all of them and change if you want the same size on everybody. On the “Domino Web Engine” tab

FileUpload5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

On the “POST Data” section change the Max post size to the new maximum file size you want to have.

If you are using an old Domino application you are done now. After reloading the HTTP task on the server.

But if you application is an XPage application there is another place you need to control the file size, and that is in Application Configurations and xsp.properties file in you database and the File Upload Option.

Or if you want to add it globally add it to the xsp.properties file in the Domino\Data\Properties folder in xsp.properties.

FileUpload6

 

 

 

 

If you want to increase the size for iNotes there is a third place that you might need to increase and that is in the Servers\Configurations document for the server. Click on the “iNotes” tab and update the “Mamimum attachment size” and save the document. Restart the http task on the server to make the changes get affect.

FileUpload7

 

 

 

 

 

 

 

 

 

 

 

If you got any problems some Domino configuration or got help from this post, make a comment.

Long live Domino just give us TLS 1.3 support NOW!!

Evolving the easy XPage keyword bean

The first part of the easy keyword bean can be found here

When working with keywords in XPages your application could greatly take advantage of the possibilities in the XPage Engine. Thru caching of data, What do I mean with caching?

Well today the keyword bean is located in viewScope and that means that it lives only on the current page that is opened. If you move the bean to applicationscope and add some caching functionality we only need to go into the database if the keyword never have been fetched before.

But there is a problem when moving things into applicationscope that is multi user access, and that can easily be solved using synchronization or threadsafe objects.

Another thing is that you need to maintain is keyword updates because they need to be maintained but that is also easy to solve because if you write the Keyword edit save using XPages that you can update the keyword when saving a keyword.

OK so how do we change the code so we get a common applicationscope keyword bean.

first we add a Global CacheObject and next we check against the GlobalCache Object before accessing the database. And we also need a recache option for a certain keyword to get it refreshed when you have saved a keyword.

Let’s Look at some code

we start by importing java.util.concurrent.ConcurrentHashMap and setting up the hasmap object as a cache object. I use the concurrenthashmap to get a threadsafe Cache object in my application scope bean.

We also need to change the object from static to be an ordinary Java object because it will live in the applicationscope. Another thing we also need to implement is serializable if the server want to store the object on disk for any reason.

Let’s move over to the getKeyword function. What we need to do is to check if the keyword is in cache and if it is, return the cached data. If it isn’t found get the data like before and store it in cache and return the data.

And because I call getKeword from the function getKeywordString I only need to change getKeyword when implementing this new functionality.

The last thing we need to add is the recache function, and that one will be a function that clears the data in cache so the next request to get the data will do it from the database.

I almost forgot, we need to change our managebean also and move if from viewScope to Application Scope in the faces-configt.xml file

If you want the full code for this check out this xSnippet on openntf.org

Creating an easy XPage keyword bean

Flexibility in applications is always a great thing, to adapt the application to the business needs without recoding things. And if adding this flexibility can be done without lots of code, you will probably use it.

This is one way of creating a keyword data bean for you XPages.

Start by creating a form named Keyword, in this form add the fields Name and Data, add the multivalue checkbox in the datafield question079

 

 

 

Save the form

Now you need to create the lookup view, create a view called byKeyword

question080

 

 

 

 

Add 2 columns name and data. The name column should display the name of the Namefield and it must be sorted and the second view should show the data field, Save the new view.

Let move over to the interesting code, create a new java class named FormHelper and place it in a package, I call mine com.xpagedeveloper.

question081

 

 

 

 

 

 

 

 

I create two functions, the first one will return return a vector with the data from the keyword.

And my Second function returns string from the array separated with a string of your choice

After I add the bean init setup in the faces-context.xml in the WebContent\WEB-INF folder from the package explorer.

Now it’s very simple to get keyword values to you fields and functions inside your XPages.

Create a Keyword using the Keyword form, in this case I’ve created a Keyword named Category and added some values to it.

Snap2

 

 

 

And in my XPage I have added an Combobox

question094

 

 

 

 

 

 

 

 

And in the values tab click on the “Add Formula Item” button

question095

 

 

 

 

 

 

 

And write the following code

question096

question097

 

 

 

 

 

 

 

 
If you want the full code for the bean, it can be found here as an xSnippet

Now your XPage application is more flexible without lots of code.

Creating your first XPage Repository using GitBlit

If you read my last article about setting up your own GitBlit Server with Domino credentials this is the next step. Creating your first repository and pushing up an xpage application to the server.

Login to your git blit server and click on the repositories tab

Snap64

 

 
 

Click on new Repository at the right hand side of the UI

Snap66

Give your new repository a name, and write a description if you like.
There is lot’s of other options that you can setup but they are not needed for this example.

Click on the access permission tab

Snap71

 

Add owners to the repository, change the access restrictions so your users can view, clone and push.

Also change the authorization control for the users. Now your repository is ready to be saved, so Click on Save.

When the repository is saved, it’s time to get the Repository URL that we need to clone the repository.

Click on your prefered git client software, my prefered client is SourceTree
Snap68

 

 

 

 

 

 

Copy this URL into your application and clone the repository.

And you are ready to get the most out of your development.