[ListUtils.lazyList] create on demand elements with lazyList

When the index passed to the returned list’s get method is greater than the list’s size, then the factory will be used to create a new object and that object will be inserted at that index.

For example,

List<Date> list = ListUtils.lazyList(new ArrayList<Date>(), new Factory() {
public Object create() {
return new Date();
Date d = list.get(3);

After the above code is executed, obj will contain a new Date instance. Furthermore, that Date instance is the fourth element in the list. The first, second, and third element are all set to null.

We use this in template. Instead of declare it using normal java array, the lazylist object is used. Let’s see another example that is not related with above example,

<forEach items="${invoice.lineItems}" varStatus="i">
<form:input path="lineItems[${i.index}].productName" />

This will solve problem when user submit the form.

ref : apache, eggsy84

[ Greasemonkey ] Hello World

1. named the file ends with .user.js

The file content begin with some configuration, see example below.


// ==UserScript==
// @name          Auto Login PAM
// @namespace     http://dsin.blogspot.com
// @description   auto login to PAM page
// @include
// @include*
// ==/UserScript==

NOTE : can add many include ( ref ), and can use wildcard ( i.e. * )

2. drag-and-drop to firefox page. Firefox will pop-up to ask for installation

ref : greasespot