Archives for July, 2012

25 Jul 2012
9

XPages Tip: Determine the Object Type of your Scoped Variable in Java

Hi All. I’m still relatively new to Java, so I landed up in a scenario where I thought my object was a Vector, but it was actually a String Object.

This cost me some time as I was trying to pass the Scoped Variable into one of my existing Vector Objects. I had checks to see if the Scoped Variable was null or blank, but I needed a check to see if it was in fact a Vector or just a String.

It’s the old problem of if you only have 1 value, then it’s a String, and when you start having more than 1, it’s an Array.

So in Java, when faced with this problem, you can use the .getClass() and .getName() method to check what you actually have.

The example below shows how I used this. I’m sure there’s a much better ways of doing this check, but for now, it works.

Cheers all.

 

EXAMPLE:

Vector myarray = new Vector();

if (viewScope.get(“ScopeName”).getClass().getName().equals(“java.lang.String”))

     //It’s a String value, not an Array

     myarray.add(viewScope.get(“ScopeName”).toString());

} else {

     //It’s an Array. Yippee!!

     myarray = (Vector) viewScope.get(“ScopeName”);

}

UPDATE NOTE:

Thanks to Tommy Valand, below is another example of how to achieve this (See Red Text below). It’s also noted that the below method is preferred to what I show above.

Thanks Tommy for your feedback.

 

Vector myarray = new Vector();

if (viewScope.get(“ScopeName”) instanceof String)

     //It’s a String value, not an Array

     myarray.add(viewScope.get(“ScopeName”).toString());

} else {

     //It’s an Array. Yippee!!

     myarray = (Vector) viewScope.get(“ScopeName”);

}

23 Jul 2012
10

Important note if building an XPages application gives dodgy results

Hi everyone. So I’ve been faced with a dumb problem these past few days where if I build an XPages application, it feels like not all the changes I made get noticed by the build.

I also sometimes get Java Errors on stuff I know works. I usually manage to fix this by opening, saving and closing the Java Classes. Obviously not the preferred practice.

Thanks to Jesse Gallagher, who pointed out a hidden setting, this has resolved most of my issues. When I say hidden, i mean it’s not visible in the Standard Application Properties of your XPages Application in Domino Designer.

Do the following:

1. Open your Application in Domino Designer.

2. Expand your Application in the Package Explorer. (Note: If you don’t have the Package Explorer, change your Designer Perspective to XPages)

3. Expand WebContent, then WEB-INF, and double click on xsp.properties. This will open up what looks like your Application Properties Form.

4. Under the Timeouts section, select the Option “Refresh entire application when design changes“.

5. Save, Close and Build.

IMPORTANT UPDATE: Thanks to feedback from Dan O’Connor and Scott Horwood, it seems my Java error is an actual problem in Domino 853, and is resolved by upgrading to 853 FP1. Thanks Guys for the feedback.

And that should do the trick. It seemed to worked for my current problem. According to Jesse it was a property introduced in Notes/Domino 853.

Thanks again Jesse for pointing this out.

Cheers all.

20 Jul 2012
4

A quick example of the Dynamic Content & Data View Controls used in an XPages App

Hi Everyone. I’ve finally made some time to test out a few features from the XPages Extension Library. It was a bit of a learning curve, but it’s looking good.

Click here to view a Demo of these Controls.

I apologize in advance if there’s a small delay when using this App. It’s been hosted on a Server in South Africa…so the Internet Line is to blame.

Anyways…below is a list of Controls I’m using in the XPages App:

1. On top you’ll see the XPages Debug Control that was created by Mark Leusink and is available on OpenNTF. It’s very cool in the sense that it allows you to print messages directly to the Control and not via the Server Console. It also allows you to see all Scoped Variables that are being used in the XPage. Finally, it has an awesome feature where you can execute SSJS Scripts and view the result. I am very happy with this Control.

2. I’m using the Application Layout to control the Look and Feel of the XPage. It’s always a massive time saver. Click here to view the Video from NotesIn9 that explains the Application Layout in more detail.

3. in the Left Section I’m using the Navigation Control made available in the XPages Extension Library. This was a trick and a half, but I managed to use Partial Refreshes for all my onclick events. This allows me to use 1 XPage and multiple Custom Controls.

4. Depending on loading time, you might see the XPage go into Standby during the Partial Refresh. This is thanks to the Standby Custom Control which is available for download from OpenNTF. This is an awesome feature that needs no additional resources to function.

5. I have 2 views in the Main Content Section. These are Data Views that I am using from the XPages Extension Library. It’s safe to say that I am currently using very basic functionality from the Data View. There’s a lot more that you can do with it.

6. The 2 Data Views exist in a Dynamic Content Control, also from the XPages Extension Library. I won’t go into too much detail about this except that the Dynamic Control keeps your XPage light, and only loads Controls when they are needed. Very awesome stuff.

I am quite happy with what I’ve achieved in the last 3 hours. I had to put a few hacks in place to make everything work with Partial Refreshes, but all in all it was quite easy to implement.

I highly recommend the XPages Extension Library Book. It’s a life saver.

Till next time. Enjoy :)

12 Jul 2012
0

How to check your OS X Version, Processor and Memory Information on your Mac

Hi All. I thought I’d add this to my Blog. It’s simple enough if you’re an inquisitive person, but for those who just want to know….in order to view your Processor and Memory Details, as well as the current version of OS X, simply click on the Apple icon, followed by clicking on About This Mac.

Please note, I’m not sure how it works on previous versions of Mac OS. I assume it’s similar.

Cheers.

 

About This Mac

About This Mac