The disadvantage of part 1 is overloaded getter/setter when there are many fields. In this part 2 example, I am going to introduce the model layer using data object. By using data object, you don't need to configure the getter/setter.
Also, part 2 has included doclock and data validation functionality.
Download the database here:
https://drive.google.com/open?id=1vWWvqNlVOtV-ftUpvKYK-XJMiVcmOb5y
Notesin9:
http://www.notesin9.com/2014/01/13/notesin9-133-using-java-in-xpages-part-2/
OpenNTF DocLock:
https://www.openntf.org/main.nsf/project.xsp?r=project/XPage%20Document%20Locker
Thursday, August 8, 2019
Wednesday, July 31, 2019
CRUD using Java Bean binding (Getter / Setter) in XPages
It is build using Model-Control-View (MVC) architecture.
https://drive.google.com/open?id=1ZTITEjvp_YNakEkUhFn05PCcRWd0olQF
Part 1 Includes:
http://blog.redturtle.it/2014/02/06/xpages-javabean-new-way-to-bind-notes-document
How to use Managed Beans in XPages:
https://docs.google.com/document/d/1XFXEmXH8KFcXEHcs2qvbWqOs_TqJWJ8Dbs9CMMKLszI/mobilebasic?pli=1
Notesin9:
http://www.notesin9.com/2013/12/17/notesin9-132-using-java-in-xpages-part-1/
Quick Java Course for XPages Developers:
https://docs.google.com/document/d/1jjZIvkGQWjwYfTJBGVaE_0CyOiskLeOJ_3vlOWUjVNk
https://docs.google.com/document/d/1IdhQvybM47EMUjC8WN8vOkeGyBrirjdOk_DYbeICHRU
https://docs.google.com/document/d/1gywwFtmAdgTtGJt-LxUbxaH0yJFtbQleJlLtWzZNZpI
- Model – Field binding, configure the getter/setter, and business logic.
- Controller – Serving the request.
- View – XPages for UI and Form.
https://drive.google.com/open?id=1ZTITEjvp_YNakEkUhFn05PCcRWd0olQF
Part 1 Includes:
- Bootstrap 4 Theme
- Create, Read, Update, Delete using Java Bean
- Text Field
- Date Field
- Dropdown Field
- Checkbox Field (Multiple Value)
- Backend Computed Data
http://blog.redturtle.it/2014/02/06/xpages-javabean-new-way-to-bind-notes-document
How to use Managed Beans in XPages:
https://docs.google.com/document/d/1XFXEmXH8KFcXEHcs2qvbWqOs_TqJWJ8Dbs9CMMKLszI/mobilebasic?pli=1
Notesin9:
http://www.notesin9.com/2013/12/17/notesin9-132-using-java-in-xpages-part-1/
Quick Java Course for XPages Developers:
https://docs.google.com/document/d/1jjZIvkGQWjwYfTJBGVaE_0CyOiskLeOJ_3vlOWUjVNk
https://docs.google.com/document/d/1IdhQvybM47EMUjC8WN8vOkeGyBrirjdOk_DYbeICHRU
https://docs.google.com/document/d/1gywwFtmAdgTtGJt-LxUbxaH0yJFtbQleJlLtWzZNZpI
Wednesday, July 17, 2019
Why I use Vanilla (Native) Javascript, not Underscore.js or Lodash?
Underscore.js and Lodash are javascript utility library written using functional programming. Lodash is the level up version from Underscore.js. Most of its ideas and contributors are from Underscore.js. Both libraries used to be my favourite until ECMA 2016 where developers can code ECMA 2016 without using Underscore.js and Lodash. Here are a few examples:
Underscore.js and Ladash maintenance by public and no promise on the future roadmap. Vanilla javascript maintenances by various organizations involved Mozilla, Google, Microsoft, etc. Every year has a new release since the year 2015, the current version is ECMA 2019.
In term of speed, some methods in Ladash are faster than vanilla javascript because of functional programming.
https://underscorejs.org/
https://lodash.com/
https://en.wikipedia.org/wiki/ECMAScript
https://codeburst.io/why-you-shouldnt-use-lodash-anymore-and-use-pure-javascript-instead-c397df51a66
https://blog.bitsrc.io/you-dont-need-lodash-or-how-i-started-loving-javascript-functions-3f45791fa6cd
const users = [
{ 'user': 'joey', 'age': 32 },
{ 'user': 'ross', 'age': 41 },
{ 'user': 'chandler', 'age': 39 }
]
// Native
users.find(function (o) { return o.age < 40; })
//lodash
_.find(users, function (o) { return o.age < 40; })
// Native
users.filter(function (o) { return o.age < 40; })
//lodash
_.filter(users, function (o) { return o.age < 40; })
// Native
users[0]
//lodash
_.first(users)
// Native
users.forEach((value, index) => { console.log(value) })
//lodash
_.each(users, (value, index) => { console.log(value) })
I am not here to against Underscore.js or Ladash. Whatever the decision, think about future maintenance and support, and speed.Underscore.js and Ladash maintenance by public and no promise on the future roadmap. Vanilla javascript maintenances by various organizations involved Mozilla, Google, Microsoft, etc. Every year has a new release since the year 2015, the current version is ECMA 2019.
In term of speed, some methods in Ladash are faster than vanilla javascript because of functional programming.
https://underscorejs.org/
https://lodash.com/
https://en.wikipedia.org/wiki/ECMAScript
https://codeburst.io/why-you-shouldnt-use-lodash-anymore-and-use-pure-javascript-instead-c397df51a66
https://blog.bitsrc.io/you-dont-need-lodash-or-how-i-started-loving-javascript-functions-3f45791fa6cd
Wednesday, June 19, 2019
Servlet Implementation in Domino
In this article, I am going to show you how to implement the servlet in Domino. The implementation is using DesignerFacesServlet, not the tradition HttpServlet. The DesignerFacesServlet allows us to use the XPages scope variable.
1. Import servlet library into the database. The servlet library can find in <NOTES>\framework\shared\eclipse\plugins\com.ibm.domino.xsp.adapter_<VERSION>.
2. Create Servlet factory to map the URL “https://server/database/xsp/myservlet” to “test.servlet.HelloWorldServlet”.
4. Create the HelloWorld Servlet.
5. Test the servlet by entering URL https://server/database/xsp/myservlet.

6. The implement is easy by creating three files.

Download Sample Database
References:
https://edm00se.io/xpages-servlets/servlet-implementation/
https://www.ibm.com/developerworks/cn/lotus/xpage-servlet/index.html
1. Import servlet library into the database. The servlet library can find in <NOTES>\framework\shared\eclipse\plugins\com.ibm.domino.xsp.adapter_<VERSION>.

2. Create Servlet factory to map the URL “https://server/database/xsp/myservlet” to “test.servlet.HelloWorldServlet”.
package test.servlet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import com.ibm.designer.runtime.domino.adapter.ComponentModule;
import com.ibm.designer.runtime.domino.adapter.IServletFactory;
import com.ibm.designer.runtime.domino.adapter.ServletMatch;
public class ServletFactory implements IServletFactory {
private static final Map<String, String> servletClasses = new HashMap<String, String>();
private static final Map<String, String> servletNames = new HashMap<String, String>();
private ComponentModule module;
public void init(ComponentModule module) {
System.out.println("TestFactory:init");
servletClasses.put("myservlet", "test.servlet.HelloWorldServlet");
servletNames.put("myservlet", "Hello World");
this.module = module;
}
public ServletMatch getServletMatch(String contextPath, String path) throws ServletException {
try {
String servletPath = "";
// iterate the servletNames map
Iterator<Map.Entry<String, String>> it = servletNames.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> pairs = it.next();
if (path.contains("/" + pairs.getKey())) {
String pathInfo = path;
return new ServletMatch(getWidgetServlet(pairs.getKey()), servletPath, pathInfo);
}
}
} catch (Throwable t) {
t.printStackTrace();
}
return null;
}
public Servlet getWidgetServlet(String key) throws ServletException {
return module.createServlet(servletClasses.get(key), servletNames.get(key), null);
}
}
3. Enable servlet factory services.
3.1 Open the database in Package Explorer.
3.2 Go to folder “Code/Java/META-INF/services/ and create a text file name “com.ibm.xsp.adapter.servletFactory”.
3.3 In the text file, fill “test.servlet.ServletFactory” to enable the servlet factory.
package test.servlet;
import com.ibm.xsp.webapp.DesignerFacesServlet;
import java.io.*;
import javax.faces.context.FacesContext;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldServlet extends DesignerFacesServlet {
@Override
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
// Set up handy environment variables
HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse res = (HttpServletResponse) servletResponse;
ServletOutputStream out = res.getOutputStream();
FacesContext facesContext = this.getFacesContext(req, res);
try {
res.setContentType("text/plain");
System.out.println("User hit the service.");
} catch(Exception e) {
e.printStackTrace(new PrintStream(out));
} finally {
facesContext.responseComplete();
facesContext.release();
out.close();
}
}
}

6. The implement is easy by creating three files.

Download Sample Database
References:
https://edm00se.io/xpages-servlets/servlet-implementation/
https://www.ibm.com/developerworks/cn/lotus/xpage-servlet/index.html
Subscribe to:
Posts (Atom)