How to add your custom domain to your Bluemix app

When you want to deploy your app to the real world a mybluemix.net adress might not be the best you probably want your own domain added. Fortunately this is very simple to do with Bluemix.

screen510

Click on the settings icon in the top right corner on your Bluemix Dashboard and select Edit Routes and App Access.

screen511

Click on Manage Domains

screen512

Click on Add Domain

screen514

Write your custom Domain name and press Save

screen515

an upload SSL Certificate appears and if you want to accept SSL to you application, you need to upload a certificate to your application.

screen516

Add your CRT file i the Certificate file upload control and your Key File and password in the next two fields. And press Upload.

Now you are almost done.

Go back to the first screen

screen511

your new domain will now show up as an option instead of mybluemix.net

There are several options too create a SSL cert but for test purposes I use https://www.startssl.com/ it’s a great way to create a free SSL cert or your can get a great price from Digicert that I use for all my professional certs

Is it possible to kill a XPage for Bluemix instance if it’s gone none responsive

I have seen more than once both of own and other developer experience that a loop in XPages gone bad and you have to kill the server. How can this kind of behavior be fixed in XPages for Bluemix will the dashboard work to “kill” the server?

See the answer

Also see my XPages for Bluemix the questions post lot’s of questions is updated with answers

XPages for Bluemix – The questions

When I started to try out XPages for Bluemix I started to create a list of questions for the future because this is in Beta and between now and Gold release some of this questions would be good to have an answer on.

  • What release cycle could we expect to get for the XPages runtime, in relation of getting new versions of extension library and functionality – Answered a monthly release cycle or synced with openntf extension library upgrades
  • Is it possible to install your own OSGI plugins like Debug Toolbar or the OpenNTF Domino API Answer Yes probably already in the next release
  • How do we run scheduled code that we have runned in agents before – Not at this point but the possibility could be there in a future release Answer
  • How to handle Users/Groups/Roles partial answerGroups is not supported and you are limited to 6 web users in the experimental version of XPages for bluemix
  • How to register users thru code, integrate with LDAP, SAMLNot at this point  partial answer
  • How to control JVM Security
  • How to do an automated XPage build process – Could could add git to a Bluemix project and deploy your code the git See post perhaps we will see a ODP git push to Bluemix in the future that would be great. 
  • How to use other Bluemix Services with XPages Answer Answer2
  • How to package an XPage for Bluemix solution as a temple for multi service deployment
  • can a XPages application be run inside a Docker container
  • How does XPages in Bluemix scale – Answer and a very good one
  • Is the database

I will probably get more questions and will then update this post. I will also add any answers I get to this post. If you know any answer please comment.

XPages on Bluemix a first look deploying app

On friday the XPages runtime on Bluemix was released and also the new version of OpenNTF Extension library that enables to work with.

My first impression is that it works great I haven’t had time to do any deep diving into the new possibilities but I thought I should share as long as I have tried it.

To get it to work you need a bluemix account and install the latest extlib into you designer client when you done that you will get a new entry in your preference in the designer.

screen485

I have selected the US South (Don’t know if the XPage engine is deployed in the UK site) write your user name and password and Test Connection

if this is ok your designer is connected to Bluemix

Go to bluemix and setup an XPage Starter app when you have logged in to Bluemix you need to go to catalog and at the bottom click on Bluemix Labs Catalog

screen478

inside this beta catalog you will find the XPage Bluemix engine and also a web starter application click on this entry.

screen480

Fill out an name for you app at the lefthand side and press Create

screen481

Your started application is now being setuped and the next step is to download the webstarter app, I actually don’t know if you need the Bluemix commandline tool and I haven’t been able to download it and had it from before so I couldn’t test with out it, but try without it and let me know.

Snap12

When you have downloaded the starter code go to designer and in the tools menu

screen487

This will start a wizard when you need to specify a path to a bluemix staging area, this area should not be in the client data folder and connect to the bluemix app area.

To deploy your code to bluemix you need to right click on the database and select deploy application remember to sign your database before doing this if you have multiple signers in the application.

screen491

The deployment will take very long time and if you check the Bluemix the application will show as started but it’s not. This might hopefully be improved with better status updates in future releases.

This will add the design database if you want to connect to the data nsf you need to go into Bluemix and download a notes id and connect you will find this information below services in the Bluemix dashboard.

screen492

It seams like the backend data store for the Bluemix is a Linux Domino server because if you browse it you will find regular databases in the root of the server. It will be interesting to see any performance data from the Bluemix setup.

Also read my XPages for Bluemix the questions

Xpages on Bluemix

Finally did the beta arrive and I wasn’t dissapointed. Setting up the web start app was very simple, a few minor things but no error.

  • Deployment takes very long and the bluemix dashboard log says started but overall status say not started. Should say starting
  • Before deploying remember to sign databas otherwise you will get an error
  • You need to manually setup connection to backend database.

But overall great first release will be fun to see what the future will give us.

IBM Domino and Java problem with old applets

All the old Java applets that is YES in some old apps not yet converted used got another problem today on Domino 9 and 9.01. They are now blocked by Oracle because the code signing certificate is outdated, it seams like when they where updated to work with Java 1.7 45 the person who resigned them did that with an old certificate and now that cert is outdated and has been so for 1 month. If IBM or you want to keep track on when your code or SSL certs expires QNova Systems contract management system works really great for this purpose and many more things, contact me if you want to know more. An interesting thing will also to see if the new code cert created with SHA-2, because I don’t think you can get one with SHA-1 anymore and this will make Java 1.6 outdated because it doesn’t have support for SHA-2.

I’ll keep you updated on this matter.screen392

Moving on with Excel Export part 6 : But now we Import

The previous 5 steps in this series (part 1 part 2 part 3 part 4 part 5) has been getting data out to excel in different ways this part will show you how to get data back into Domino again thru your XPage, this will give you the possibility to roundtrip data handling. Export all customers mark the rows you have changed and re import the data. Because Apache POI is installed on the server as an OSGI we have access to these classes in all java code on the server and that is what I’m going to show you today and how to upload an Excel file and read some data from a cell.

In the example database for POI4XPages there is a class you really need and that is the ImportAction this is needed to open up a workbook of a xlsx file you don’t need it if you are only using xls. This class is used for changing the classpath of the jvm and some security stuff so you don’t need to modify the java.policy file on your server (Thanks Christian for pointing this out)

We start with some OpenNTF data in Excel

screen300

We create an java class

public String getData(java.io.File file,Integer row,Integer cell){

try {

 String inputFile = file.getPath();

 String CellVal=””;

 ImportAction ioAction = new ImportAction();

 HashMap<String, String> hsCurrent = new HashMap<String, String>();

 hsCurrent.put(“FILE”, inputFile);

 workbook = ioAction.run(null, hsCurrent);

 if (ioAction.hasError()) {

   Exception exLst = ioAction.getLastException();

   throw(exLst);

 }else{

 Sheet worksheet=workbook.getSheetAt(0); 

 Row rowdata = worksheet.getRow(row);

 Cell celldata = rowdata.getCell(cell);

 CellVal= celldata.getStringCellValue();

}

return CellVal;

}catch(Exception e){

return “”;

}}

lets look at the parts of this class

 ImportAction ioAction = new ImportAction();

 HashMap<String, String> hsCurrent = new HashMap<String, String>();

 hsCurrent.put(“FILE”, inputFile);

 workbook = ioAction.run(null, hsCurrent);

 if (ioAction.hasError()) {

   Exception exLst = ioAction.getLastException();

}

This is the magic call the the ImportAction class that will create a Excel POI workbook Object.

The following rows will get the first sheet in the excel file get the first row and the first cell and return the string

Sheet worksheet=workbook.getSheetAt(0); 

 Row rowdata = worksheet.getRow(row);

 Cell celldata = rowdata.getCell(cell);

 CellVal= celldata.getStringCellValue();

Now we need to create the XPage to enable the upload of the Excel file

screen301

The interesting part is behind the read button onclick event

importPackage(com.xpagedeveloper)

var con = facesContext.getExternalContext();

var request:com.sun.faces.context.MyHttpServletRequestWrapper = con.getRequest();

var map:java.util.Map = request.getParameterMap();

var fileDataName = getClientId(“fileUpload1”) ;

var fileData:com.ibm.xsp.http.UploadedFile = map.get( fileDataName );

if( fileData == null ){

return;

}

var tempFile:java.io.File = fileData.getServerFile();

var Excel=new com.xpagedeveloper.ExcelData()

viewScope.data=Excel.getData(tempFile,0,0)

We get the uploaded file in fileData and retrieve the actual file using fileData.getServerFile() remember that this file is a server based temp file and with that I mean that you will not get the same same on the file as it was when the user uploaded it. And next I create an object of my class and call the getData function with the java io file object the row and the cell number remember that this has a zero based index so 0,0 is actual row 1 and cell 1, this is the result I get when running the code against the Excel sheet

screen302

If you are going to loop thru a full excel sheet you probably need to rewrite the code but this will give you a hint where to begin.

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.

package com.xpagedeveloper;
import java.util.ArrayList;
import java.util.List;
import java.io.Serializable;
import lotus.domino.NotesException;
import lotus.domino.Session;
import lotus.domino.Database;
import lotus.domino.View;
import lotus.domino.ViewNavigator;
import lotus.domino.ViewEntry;
import java.util.Vector;
public class Export implements Serializable 
{
	private static final long serialVersionUID = 1L;
	
	public static List<Exportdata> getData(Session session){
		Exportdata RowData;
		List<Exportdata> Data = new ArrayList<Exportdata>();
		try {
			View v=session.getCurrentDatabase().getView("City");
			ViewNavigator Nav=v.createViewNav();
			ViewEntry VE=Nav.getFirst();
			ViewEntry VE2;
			Vector Col;
			while(VE!=null){
				VE2=Nav.getNext(VE);
				RowData=new Exportdata();
				Col=VE.getColumnValues();
				RowData.setName(Col.get(0).toString());
				RowData.setLanguage(Col.get(1).toString());
				RowData.setCountry(Col.get(2).toString());
				RowData.setRegion(Col.get(3).toString());
				Data.add(RowData);
;				VE.recycle();
				VE=VE2;
			}
		} catch (NotesException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return Data;
	}

}

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://www.xpagedeveloper.com/2015/if-your-user-want-reports-in-excel-you-should-read-this

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