OGNL Part 5: Projection
This is very important concept in the OGNL very similar to the database projection concept. In the part 4, we’ve already discussed the Arrays. Following code is based on the array.
package au.com.ojitha.ongl; import java.util.List; import ognl.Ognl; import ognl.OgnlException; public class ProjectingExmaple { /** * @param args * @throws OgnlException */ public static void main(String[] args) throws OgnlException { Listclasses =(List )Ognl.getValue("array.{class}", new MyRoot()); for (Class class1 : classes) { System.out.println(class1); } System.out.println("size of the output "+classes.size()); } } class MyRoot { private int[] array = {1,2,3,4}; public int[] getArray() { return array; } public void setArray(int[] array) { this.array = array; } }
Here the output
class java.lang.Integer class java.lang.Integer class java.lang.Integer size of the output 4
Comments
Post a Comment
commented your blog