5. Data transfer: OGNL and type conversion Flashcards

1
Q

What does OGNL stand for?

A

Object Graph Navigation Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What’s the OGNL escape sequence?

A

%{expression}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s the difference between these fields when OGNL converts them to Java?

A
  • ages – Sets the whole array.
  • names – Sets individual index with value (calls get, then sets value). SO array MUST be initialized!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do we tell OGNL what types to convert values to?

A

Create a ClassName-conversion.properties file next to the Java Class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Regarding OGNL convertions properties file, how would you convert values named ‘weights’ from a generic list to a list of Doubles?

A

Add a line:

Element-weights=java.lang.Double

Note: Prefix of ‘Element-‘ and the full path to the Type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What’s the syntax for using OGNL to populate a map from HTML?

A

Two ways you can do it:

map.key

or

map[‘key’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Regarding HTML -> Java OGNL is the -conversion.properties NEEDED when dealing with List/Set/Map?

A

If you’re not using a typed generic, yet. But you should be using generics in which case it will work wihtout the properties file!

Ex: Map

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What interface must be implemented to give OGNL ability to convert types? What 2 methods need to be implemented?

A

–Interface–

StrutsTypeConverter

–Methods–

convertFromString(Map context, String[] values, Class toClass)

String convertToString(Map context, Object o)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the OGNL properties file that’s used globally? Where should it be located?

A

xwork-conversion.properties

Place it in the root of the classpath.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly