| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
package org.apache.tiles.velocity.template; |
| 5 | |
|
| 6 | |
import java.io.IOException; |
| 7 | |
import java.io.Writer; |
| 8 | |
|
| 9 | |
import org.apache.tiles.autotag.core.runtime.AutotagRuntime; |
| 10 | |
import org.apache.velocity.context.InternalContextAdapter; |
| 11 | |
import org.apache.velocity.runtime.directive.Directive; |
| 12 | |
import org.apache.velocity.runtime.parser.node.Node; |
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | 0 | public class SetCurrentContainerDirective extends Directive { |
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | 0 | private org.apache.tiles.template.SetCurrentContainerModel model = new org.apache.tiles.template.SetCurrentContainerModel(); |
| 23 | |
|
| 24 | |
|
| 25 | |
@Override |
| 26 | |
public String getName() { |
| 27 | 0 | return "tiles_setCurrentContainer"; |
| 28 | |
} |
| 29 | |
|
| 30 | |
|
| 31 | |
@Override |
| 32 | |
public int getType() { |
| 33 | 0 | return LINE; |
| 34 | |
} |
| 35 | |
|
| 36 | |
|
| 37 | |
@Override |
| 38 | |
public boolean render(InternalContextAdapter context, Writer writer, Node node) |
| 39 | |
throws IOException { |
| 40 | 0 | AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.velocity.autotag.VelocityAutotagRuntime(); |
| 41 | 0 | if (runtime instanceof Directive) { |
| 42 | 0 | ((Directive) runtime).render(context, writer, node); |
| 43 | |
} |
| 44 | 0 | org.apache.tiles.request.Request request = runtime.createRequest(); |
| 45 | 0 | model.execute( |
| 46 | |
runtime.getParameter("containerKey", java.lang.String.class, null), |
| 47 | |
request |
| 48 | |
); |
| 49 | 0 | return true; |
| 50 | |
} |
| 51 | |
} |