Support #4857
openHow to get XML working?
0%
Description
I'm trying to use the example code found here: https://www.webtoolkit.eu/widgets/layout/html-templates
My application has the approot and docroot set, and it has a wt_config.xml file and a separate WTemplate-example.xml file. I have app~~messageResourceBundle().use(app~~>appRoot() + "WTemplate-example"); in my main file.
Unfortunately all I see is WTemplate-example since it can't find my resource. I am using the same code in the xml file as in the example and the same C code, with the template bound to my parent container. Can someone tell me what I am doing wrong?
Updated by Koen Deforche over 8 years ago
- Status changed from New to Feedback
That looks all fine. How are you starting your wt process? It needs to know the location of the approot? What do you see exactly? You should see 'something-here' if it couldn't resolve the template from the message resource bundle?
Updated by ZAITAO HUANG over 4 years ago
me too, I also encountered this problem
i don't how to solved.
Updated by ZAITAO HUANG over 4 years ago
I have solved this problem.
first. XML code snippet incompete https://www.webtoolkit.eu/widgets/layout/html-templates Example: HTML Templates XML code snippet incomplete.¶
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="WTemplate-example">
<div class="form">
<p>
<label>Please enter your name: ${name-edit}</label>
</p>
<p>
${save-button} ${cancel-button}
</p>
</div>
</message>
</messages>
in c code :
messageResourceBundle().use("html_temp");
auto t = root()->addWidget(Wt::cpp14::make_uniqueWt::WTemplate(Wt::WString::tr("WTemplate-example")));
t->bindWidget("name-edit", Wt::cpp14::make_uniqueWt::WLineEdit());
t->bindWidget("save-button", Wt::cpp14::make_uniqueWt::WPushButton("Save"));
t->bindWidget("cancel-button", Wt::cpp14::make_uniqueWt::WPushButton("Cancel"));
put the xml file: html_temp.xml project current directory