-
1. Re: errai templates from database
jfuerth Dec 18, 2013 10:36 AM (in response to vascoas)Hi Vasco,
Using a self-provided template isn't quite possible with Errai today, but it wouldn't be a very big change to the framework if you wanted to add this feature. The generated code that performs the parse-and-composite process uses a hardcoded call to GWT.create() to get the String containing the HTML template. After that, everything is done in a way that would work fine with HTML that was fetched (or even generated) at runtime.
So the trick would be to modify Errai UI's code generator in a way that lets you specify something other than a filename as the source of the template. Perhaps something like this:
@Templated(provider=MyDynamicTemplateProvider.class) public class MyDynamicTemplatedWidget extends Composite { @Inject @DataField TextBox blah; // etc. }
Then Errai would have a TemplateProvider interface that template providers would implement:
public interface TemplateProvider { String templateFor(Class<? extends Composite> widgetClass); }
Passing the widget type to the provider method gives application developers the option to implement one super-provider for all dynamic template types, but leaves open the possibility to create a separate provider class for each dynamic templated widget.
With this idea, the net change to the generated code would only be two lines (the line that invokes GWT.create(), and the line after that gets the text out of the resource). But this is just one possible implementation idea. Maybe you or others have a counersuggestion about how to do this
The downside to all of this is that compile-time type safety goes out the window. There's no way to prove at compile time that the provider will always provide a template that contains all the elements required by the @DataField fields of the widget class.
Is this something you'd be interested in taking on? We love pull requests!
-Jonathan
-
2. Re: errai templates from database
vascoas Jan 6, 2014 7:21 PM (in response to jfuerth)Jonathan, thank you for your answer - it was right on the spot - and sorry for my delay answering this thread. I've been looking with my colleagues to include this development in the project that needs this. Once we do it (may take a couple of month) we'll do a pull request.
Thanks once again.
-
3. Re: errai templates from database
magick93 Jan 7, 2014 9:36 AM (in response to jfuerth)Hi Jonathan!
Great idea! This would be a great feature for Errai!
-
4. Re: errai templates from database
pere.fernandez Jun 12, 2014 4:48 AM (in response to jfuerth)Hi Jonathan,
is there any new about this?
I work on the jbpm-form-modeler and it would be great if we can develope the new version based on this.