Tapestry: How to write HTML from java page -
i need write html .java page. here have tried
this tml code fragment
${testfunction()}
this java code fragment
public string testfunction() { return "<input type='checkbox' name='leaf' id='leaf' value='leaf'/>" }
the result want checkbox. string "input type='checkbox' name='leaf' id='leaf' value='leaf'".
appreciated thanks.
if want render string html need use markupwriter#writeraw() method:
void beginrender(markupwriter writer) { writer.writeraw("<input type='checkbox' name='leaf' id='leaf' value='leaf'/>"); }
or can use outputraw component:
<t:outputraw value="testfunction()"/>
or can use renderable write markup:
@property(write = false) private final renderable checkbox = new renderable() { public void render(markupwriter writer) { writer.element("input", "type", "checkbox", "id", "leaf", "name", "leaf", "value", "leaf"); writer.end(); // if need checked attribute // writer.getelement().attribute("checked", "checked"); } };
and on template:
<t:delegate to="checkbox"/>
Comments
Post a Comment