| 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.ModelBody; |
| 10 | |
import org.apache.tiles.autotag.core.runtime.AutotagRuntime; |
| 11 | |
import org.apache.velocity.context.InternalContextAdapter; |
| 12 | |
import org.apache.velocity.runtime.directive.Directive; |
| 13 | |
import org.apache.velocity.runtime.parser.node.Node; |
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | 0 | public class InsertAttributeDirective extends Directive { |
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | 0 | private org.apache.tiles.template.InsertAttributeModel model = new org.apache.tiles.template.InsertAttributeModel(); |
| 46 | |
|
| 47 | |
|
| 48 | |
@Override |
| 49 | |
public String getName() { |
| 50 | 0 | return "tiles_insertAttribute"; |
| 51 | |
} |
| 52 | |
|
| 53 | |
|
| 54 | |
@Override |
| 55 | |
public int getType() { |
| 56 | 0 | return BLOCK; |
| 57 | |
} |
| 58 | |
|
| 59 | |
|
| 60 | |
@Override |
| 61 | |
public boolean render(InternalContextAdapter context, Writer writer, Node node) |
| 62 | |
throws IOException { |
| 63 | 0 | AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.velocity.autotag.VelocityAutotagRuntime(); |
| 64 | 0 | if (runtime instanceof Directive) { |
| 65 | 0 | ((Directive) runtime).render(context, writer, node); |
| 66 | |
} |
| 67 | 0 | org.apache.tiles.request.Request request = runtime.createRequest(); |
| 68 | 0 | ModelBody modelBody = runtime.createModelBody(); |
| 69 | 0 | model.execute( |
| 70 | |
runtime.getParameter("ignore", java.lang.Boolean.class, false), |
| 71 | |
runtime.getParameter("preparer", java.lang.String.class, null), |
| 72 | |
runtime.getParameter("role", java.lang.String.class, null), |
| 73 | |
runtime.getParameter("defaultValue", java.lang.Object.class, null), |
| 74 | |
runtime.getParameter("defaultValueRole", java.lang.String.class, null), |
| 75 | |
runtime.getParameter("defaultValueType", java.lang.String.class, null), |
| 76 | |
runtime.getParameter("name", java.lang.String.class, null), |
| 77 | |
runtime.getParameter("value", org.apache.tiles.Attribute.class, null), |
| 78 | |
runtime.getParameter("flush", java.lang.Boolean.class, false), |
| 79 | |
request, modelBody |
| 80 | |
); |
| 81 | 0 | return true; |
| 82 | |
} |
| 83 | |
} |