332 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Jobs | Twitter | Bookmarks | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
How to recycle Notes objects in XPages
Tue, May 28th 2013 302
OpenNTF webinars for the open source community
Mon, May 6th 2013 338
Using an existing SSL certificate on IBM Domino
Thu, May 2nd 2013 320
How to force a reload of JS and CSS files when changed
Wed, Apr 10th 2013 413
Free 1-day seminar on April 24 hosted by Notesnet.dk
Wed, Mar 20th 2013 116
IBM Connect 2013 Update with Intravision
Tue, Feb 19th 2013 133
My impressions from IBM Connect 2013
Sun, Feb 10th 2013 220
Top 10
How to force a reload of JS and CSS files when changed
Wed, Apr 10th 2013 413
OpenNTF webinars for the open source community
Mon, May 6th 2013 338
Using an existing SSL certificate on IBM Domino
Thu, May 2nd 2013 320
How to recycle Notes objects in XPages
Tue, May 28th 2013 302
My impressions from IBM Connect 2013
Sun, Feb 10th 2013 220
I am now an IBM Certified Advanced Application Developer – Lotus Notes and Domino 8.5
Fri, Sep 21st 2012 209
IBM Notes and Domino 9.0 Social Edition beta now available
Thu, Dec 13th 2012 153
Experience IBM Notes 9.0 Social Edition
Tue, Feb 5th 2013 152
XPages: dynamically updating rich text content in a CKEditor
Wed, Dec 5th 2012 144
Source Control with Domino Designer 8.5.3 and Git (my talk at DanNotes, November 2012)
Thu, Nov 29th 2012 134


Creating your first managed bean for XPages
Per Henrik Lausten    

With Java and managed beans you can make your XPages applications even more powerful. In this blog post I will go through the steps to create and use a managed bean in XPages.

I am using Lotus Notes and Domino Designer 8.5.3 and will therefore use the new Java design element for the Java code located in the Code section.

In short: use "New Java Class" to create a Java class. Give your new class a package name (e.g. com.company) and a class name (e.g. HelloWorld). Add a local variable and let Eclipse generate getter and setter for it by using Source - Generate Getters and Setters. Also, let Eclipse generate a public no-parameter constructor by using Source - Generate Constructor using Fields and deselect your newly created field and omit call to super().

You will then have the following basic skeleton for a Java class:

package com.company;

public class HelloWorld {

	public HelloWorld() {
	}

	private String SomeVariable;

	public String getSomeVariable() {
		return SomeVariable;
	}

	public void setSomeVariable(String someVariable) {
		SomeVariable = someVariable;
	}

}

In order to support the XPages server page persistence option "Keep pages on disk", the Java class needs to be serializable. The Java class therefore needs to implement Serializable. Therefore, add "implements Serializable" after your class name (and Eclipse will automatically add the required import). Then use the Eclipse Quick Fix to "Add generated serial version ID". You now have a basic skeleton for a Java class that can be used as a managed bean:

package com.company;

import java.io.Serializable;

public class HelloWorld implements Serializable {

	private static final long serialVersionUID = 6469339826789980362L;

	public HelloWorld() {
	}

	private String SomeVariable;

	public String getSomeVariable() {
		return SomeVariable;
	}

	public void setSomeVariable(String someVariable) {
		SomeVariable = someVariable;
	}

}

Now we need to tell XPages that we would like to use this Java class as a managed bean. First, Add the Package Explorer view to your Eclipse perspective using Window - Show Eclipse Views - Other and select Package Explorer. Now go to the Package Explorer and navigate to the WebContent/WEB-INF folder where you will find a faces-config.xml file. Open the faces-config.xml file and add the following managed bean section in the <faces-config> section:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
	<managed-bean>
		<managed-bean-name>helloWorld</managed-bean-name>
		<managed-bean-class>com.company.HelloWorld</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
</faces-config>

You now have a basic faces-config for your HelloWorld Java class.

With the Java class and the faces-config in place the managed bean can now be used in an XPage. The bean value (both the getter and setter) can be accessed from an XPage using #{helloWorld.someVariable}.

This very basic example of a bean does not do anything. The Java class would of course have to add values to the SomeVariable property before that value would be useful in an XPage. I will create a 2nd blog post that shows how to use a bean in a repeat control to display values from the managed bean.

For more information on XPages and managed beans have a look at:


Related posts:

  1. Client project: XPages CMS for company website
  2. XSnippets: code snippets for XPages
  3. Presentation: My view on XPages




---------------------
http://feedproxy.google.com/~r/Per_Henrik_Lausten/~3/7PUlRnd1OWQ/creating-your-first-managed-bean-for-xpages.html
Feb 08, 2012
90 hits



Recent Blog Posts
302


How to recycle Notes objects in XPages
Tue, May 28th 2013 2:36p   Per Henrik Lausten
Using Notes objects in XPages and in Java requires that you recycle those objects in order to avoid memory leaks and backend out of memory issues. Here I will summarize how to do proper recycling in XPages for server-side javascript, Java and Java using the new OpenNTF project org.openntf.domino. Server-side JavaScript With server-side JavaScript you have to use the recycle method available on Notes objects and you have to "nullify" your server-side JavaScript variable. Thank you, Tony McGucki [read] Keywords: domino ibm lotus notes notesdomino xpages application database java javascript openntf server
338


OpenNTF webinars for the open source community
Mon, May 6th 2013 12:45a   Per Henrik Lausten
OpenNTF has announced a new initiative called OpenNTF Webinars. The first webinar takes place tomorrow, Tuesday May 7, and is all about OpenNTF. Join the web meeting and hear Bruce Elgort, Serdar Basegmez, Jesse Gallagher, Niklas Heidloff, Peter Tanner and me talk about OpenNTF and about what OpenNTF can offer the open source community. Future webinars will be announced at the webinar landing page. Related posts: PHL Consult supports OpenNTF and open source I am a member director on the OpenNT [read] Keywords: xpages community openntf
320


Using an existing SSL certificate on IBM Domino
Thu, May 2nd 2013 2:22p   Per Henrik Lausten
A customer of mine had an existing wild card SSL certificate running on IIS. They wanted to use this wild card SSL certificate for their IBM Domino server. I had all the SSL certificate files available (the trusted root CA, the certificate and the private key). So I quickly found the guide from Gab Davis and did something similar: I created a key ring using the Server Certificate application on the Domino server and installed the trusted root certificate into the key ring. I then opened the ke [read] Keywords: domino ibm lotus application password server
413


How to force a reload of JS and CSS files when changed
Wed, Apr 10th 2013 2:20a   Per Henrik Lausten
Caching of Javascript and CSS files is great and really improves performance in the browser. But caching also means that changes to the files are not picked up. So how do you get the browser to automatically reload the files when you have updated them because of new requirements, bug fixed etc.? There are several ways to achieve this. On Apache you can for instance use the modpagespeed module that automatically changes links to resources when the backend resource files change. Other ways includ [read] Keywords: domino ibm lotus notes notesdomino xpages application bug css google java javascript openntf server xml
116


Free 1-day seminar on April 24 hosted by Notesnet.dk
Wed, Mar 20th 2013 3:59p   Per Henrik Lausten
I am proud to announce a free 1-day seminar hosted by Notesnet.dk. The purpose of the seminar is to show companies the powerful features of IBM Notes 9, IBM Domino 9, IBM XWork Server 9, IBM Connections 4.5, XPages and much more - including case stories. The seminar is for existing IBM Domino customers and for potential IBM Domino customers, and takes place on April 24. Have a look at the agenda and sign up to attend if the seminar is of interest to you. The seminar and online content is in Dani [read] Keywords: connections domino ibm notes xpages server
133


IBM Connect 2013 Update with Intravision
Tue, Feb 19th 2013 5:32a   Per Henrik Lausten
Intravision is hosting two IBM Connect 2013 Update seminars in Copenhagen on February 25 and in Århus March 6 where speakers from Intravision and from IBM will share news from IBM Connect 2013. I am happy to have been invited by Intravision to speak about news from IBM Connect around XPages. I will be speaking about the IBM Social Business Toolkit, integration between XPages and IBM Connections, Embedded Experiences and more. Remember to register if you are interested in attending one of the [read] Keywords: collaboration connections ibm xpages integration




220


My impressions from IBM Connect 2013
Sun, Feb 10th 2013 1:02a   Per Henrik Lausten
Here are my impressions from IBM connect 2013. Social collaboration IBM connections 4.5 is coming this March and is improved in many areas such as the new file sync feature. Customers with a valid IBM Domino entitlement can continue to use IBM Connections Files and Profiles features for free. Embedded applications in IBM Notes, IBM iNotes (web mail) and IBM Connections activity streams make it possible to act on business applications directly within the context of your mail or your activity str [read] Keywords: collaboration connections domino ibm inotes lotus lotusphere notes sametime xpages applications desktop development exchange exchange instant messaging linux microsoft security server
152


Experience IBM Notes 9.0 Social Edition
Tue, Feb 5th 2013 12:25p   Per Henrik Lausten
IBM Notes 9.0 Social Edition is coming in March 2013. Read all about the new features and download reference sheets with more detailed info at the updated Experience IBM Notes site. No related posts (automatically generated). [read] Keywords: ibm lotus notes
91


Slides from SPOT104 “How We Built CollaborationToday.info in a Matter of Weeks”
Thu, Jan 31st 2013 3:25p   Per Henrik Lausten
Here is the presentation that Bruce Elgort and I used for our IBM Connect 2013 session called "How We Built CollaborationToday.info in a Matter of Weeks". How We Built CollaborationToday.info in a Matter of Weeks from Per Henrik Lausten Thanks to all that attended our session. It was a great experience for me as a 1st time speaker at IBM Connect/Lotusphere. Related posts: I’m speaking at IBM Connect 2013 [read] Keywords: ibm lotusphere
111


I have been nominated as IBM Champion for IBM Collaboration Solutions for 2013
Mon, Dec 17th 2012 12:26p   Per Henrik Lausten
I am truly honored to have been nominated as IBM Champions for IBM Collaboration Solutions for 2013. Thanks! I look forward to seeing a lot of them at IBM Connect 2013. Related posts: I’m speaking at IBM Connect 2013 I have been re-elected for the OpenNTF board of directors My 1st year as self-employed consultant at PHL Consult [read] Keywords: collaboration connections ibm openntf




Created and Maintained by Yancy Lent - About - Blog Submission - Suggestions - Change Log - Blog Widget - Advertising - Mobile Edition