4. Adding workflow with interceptors Flashcards

1
Q

What’s the object called that encapsulates the Action, Result, and all the interceptors?

A

ActionInvocation

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

What’s the method an interceptor needs to implement?

A

public String intercept(ActionInvocation invocation) throws Exception

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

How does an interceptor call the next item in the chain? What does this return?

A

invocation.invoke();

Call the invoke method on the ActionInvocation that’s passed to it.

Make sure to return this value! It returns the result, so we can respond to the result or just pass it along.

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

If you have an interceptor that should not continue, how can you accomplish that?

A

Return a control string rather than calling invoke()

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

How can an interceptor get access to the Action?

A

invocation.getAction();

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

What interceptor will map exceptions to error pages?

What XML properties would you modify to map them?

A

exception – Interceptor

exception-mapping – Holds an exception & result.

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

How can you register application wide results?

A

XML: global-results

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

How do you create an application level exception-mapping?

A

XML: global-exception-mappings

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

How do you declare an interceptor?

A

In XML there’s an interceptors tag, we can add an individual interceptor with name and class parameters.

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

How do you declare an interceptor stack?

A

In XML there’s an interceptor-stack tag with a name parameter, here we add individual interceptor-ref with a name parameter that references an interceptor.

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

How can you add an interceptor to a specific action?

A

Add an interceptor-ref to the action.

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

What happens to the inherited interceptors when you manually set interceptors for an action? Can we fix it?

A

They’re lost, your manually defined interceptors will be all that’s used. You can add it back in by adding the ‘defaultStack’ interceptor.

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

How can you pass parameters to an interceptor?

A

Inside the interceptor-ref tag you can add param with a name and has the value in the tag.

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

How can you get access to user sessions in an Action?

A

implement SessionAware interface. Now you have access to ‘session’ which is a map that you can put/get items.

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

Within an interceptor, how can you get access to the users session?

A

invocation.getInvocationContext().getSession()

First we use the ActionInvocation that’s passed in to get the ActionContext, then use that to get the session.

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