hal / elemento Goto Github PK
View Code? Open in Web Editor NEWBuilder API and other goodies for Elemental2
Home Page: https://hal-console.gitbook.io/elemento/
License: Apache License 2.0
Builder API and other goodies for Elemental2
Home Page: https://hal-console.gitbook.io/elemento/
License: Apache License 2.0
Hi!
I'm just getting started w/ this awesome project. Although I don't plan to use primarily the templates feature, some colleagues of mine might use it, as they prefer the readability of a HTML vs DSL.
When importing a project (e.g. sample/gin
) in Eclipse, it won't work out of the box. After a clean + build, there are compile errors because of the processor. E.g. for ApplicationElement.java
= Unable to read template "org/jboss/gwt/elemento/sample/gin/client/Todo.html": Java Model Exception: Core Exception [code 368] Resource '/gin/target/classes/org/jboss/gwt/elemento/sample/gin/client/Todo.html' does not exist.
.
When I look there, Todo.html
does exist. But it was probably copied during the compile phase, and probably ApplicationElement.java
was compiled (thus processor invoked) before. So maybe at that time the file didn't exist.
The work around: go to ApplicationElement.java
, modify something meaningless => incremental build only on this file => error gone. However, a full clean + build will lead to the initial situation.
My question: are there users that successfully use the template processors in Eclipse? If yes, then somehow there is something wrong w/ my setup. If no => the processor may need to be adapted for use in Eclipse. I assume that it works correctly during a maven build.
I have experience w/ processors and APT. And there are many compatibility issues between execution within maven and within Eclipse. Some of them due to the incremental approach of Eclipse, but the majority due to the fact that "illegal" operations are done from within processors. Normally, a processor should only output content based on the content of the annotated file. In this case, the content is based on the *.html
file, which is something that's not officially supported by the APT API.
Cheers!
Cristian
One method that I'm adding to all my builders is a css( String... classes) method. I'm just joining the class names using Guava at the moment, but I think this is probably something we should handle in the Builder. PR?
Assume that we have a classes annotaed as templated like below
@Templated("beneficiaries-list.html")
abstract class Foo implements IsElement<VaadinGridElement>
in the generated template the the generic type will not be used and HTMLElement
will be used instead, and will cause a compilation error.
in the generated file we will see this code
private final HTMLElement templated_foo_root_element;
@Override
public HTMLElement asElement() {
return templated_foo_root_element;
}
while it should be
private final VaadinGridElement templated_foo_root_element;
@Override
public VaadinGridElement asElement() {
return templated_foo_root_element;
}
When trying to build elemento, maven are unable to resolve org.jboss.auto:apt-tools:jar:0.0.1. Is there a separate repo I need to add or something?
I want to migrate my code that is depending on UiBinder and some custom widgets to Elemento. I really like the design.
What is not clear to me if it is possible to still use some old widgets inside an Elemento template ? Or if there is a way to insert a widget as a child of an HTMLElement somehow ?
All I am missing is support for a binding framework (2-way) in combination with javax.validation support and I think I will have a nice replacement for the old GWT widgets and features.
Acording to https://developer.mozilla.org/en-US/docs/Web/API/Element/classList IE11 does not support "Multiple arguments for add() & remove()".
Therefor get().classList.add(failSafeClasses.toArray(new String[]{}));
should be re-written to add classes via foreach to get it work.
Changing from
/** Adds the specified CSS classes to the class list of the element. */
public B css(String... classes) {
if (classes != null) {
List<String> failSafeClasses = new ArrayList<>();
for (String c : classes) {
if (c != null) {
if (c.contains(" ")) {
failSafeClasses.addAll(asList(c.split(" ")));
} else {
failSafeClasses.add(c);
}
}
}
if (!failSafeClasses.isEmpty()) {
get().classList.add(failSafeClasses.toArray(new String[]{}));
}
}
return that();
}
to
/** Adds the specified CSS classes to the class list of the element. */
public B css(String... classes) {
if (classes != null) {
List<String> failSafeClasses = new ArrayList<>();
for (String c : classes) {
if (c != null) {
if (c.contains(" ")) {
failSafeClasses.addAll(asList(c.split(" ")));
} else {
failSafeClasses.add(c);
}
}
}
for (String failSafeClass : failSafeClasses) {
get().classList.add(failSafeClass);
}
}
return that();
}
will fix the issue under IE11.
in the generated templated java file there is a GWT.create that creates an InnerHtml object from the template, i think its a good idea to replace this GWT.create with an APT processor.
I am experiencing a Maven dependency conflict between hal/elemento
and intendia-oss/autorest
.
The hal/elemento
template processor relies on auto-common 0.3, while intendia-oss/autorest
relies on auto-common 0.4. In my project, Maven ends up using the 0.4 version of auto-common, but because of a method signature change, the hal/elemento
TemplatedProcessor crashes with java.lang.NoSuchMethodError
. The method signature of MoreTypes.asTypeElemen()
changed between auto-common 0.3 and 0.4.
Relevant intendia-oss/autorest
dependency tree:
com.intendia.gwt.autorest:autorest-processor:jar:0.6:provided
+- com.google.auto:auto-common:jar:0.4:provided
Relevant hal/elemento
dependency tree:
org.jboss.gwt.elemento:elemento-template:gwt-lib:HEAD-SNAPSHOT
+- com.google.auto.service:auto-service:jar:1.0-rc2:compile
\- com.google.auto:auto-common:jar:0.3:compile
Method signature in auto-common 0.3:
public static TypeElement asTypeElement(Types types, TypeMirror mirror)
Method signature in auto-common 0.4:
public static TypeElement asTypeElement(TypeMirror mirror)
(Here is the commit that implemented the change: google/auto@a428e7b#diff-117761445d686cc88f0b75d965af5a1a)
In my project, I can explicitly set the auto-common dependency to either 0.3 or 0.4. However, when I set it to 0.3, the intendia-oss/autorest
processor similarly breaks with java.lang.NoSuchMethodError
since it is using the newer method signature for MoreTypes.asTypeElement()
.
There are several lines in TemplatedProcessor.java
that call MoreTypes.asTypeElement()
. It appears that deleting the first parameter from these calls fixes the problem when used with auto-common 0.4.
What is the best practice for dealing with this type of conflict? Would it be reasonable for hal/elemento
to explicitly set its auto-common dependency to 0.4 and update the MoreTypes.asTypeElement()
calls to match? If so, I can submit a pull request.
One alternative is suggesting that intendia-oss/autorest
downgrade its auto-common dependency to 0.3 instead of 0.4, but I feel better pushing a project like hal/elemento
forward rather than intendia-oss/autorest
backwards.
Are there any other solutions I'm missing that I could implement in any of these projects (or my own)?
Since Chrome 69 we got the following ClassCastExceptions when we use
org.jboss.gwt.elemento.core.Elements.onAttach(HTMLElement, ObserverCallback)
Uncaught Error: java.lang.ClassCastException
at qGc_g$.ah_g$ [as createError_0_g$] (Throwable.java:120)
at qGc_g$.kh_g$ [as initializeBackingError_0_g$] (Throwable.java:112)
at qGc_g$.Vg_g$ (Throwable.java:66)
at qGc_g$.zh_g$ (Exception.java:29)
at qGc_g$.Hh_g$ (RuntimeException.java:29)
at new qGc_g$ (ClassCastException.java:27)
at r1d_g$ (InternalPreconditions.java:154)
at D1d_g$ (InternalPreconditions.java:138)
at C1d_g$ (InternalPreconditions.java:133)
at lvb_g$ (Cast.java:155)
at C7d_g$.H7d_g$ [as test_1_g$] (Elements.java:818)
at JYd_g$.LYd_g$ [as lambda$0_50_g$] (StreamImpl.java:425)
at PYd_g$.QYd_g$ [as accept_1_g$] (StreamImpl.java:424)
at vhd_g$.Ehd_g$ [as tryAdvance_0_g$] (Spliterators.java:463)
at JYd_g$.MYd_g$ [as tryAdvance_0_g$] (StreamImpl.java:422)
at EZd_g$.GZd_g$ [as tryAdvance_0_g$] (StreamImpl.java:317)
at Lhd_g$ (Spliterator.java:52)
at EZd_g$.zjd_g$ [as forEachRemaining_1_g$] (Spliterator.java:51)
at vVd_g$.eWd_g$ [as reduce_6_g$] (StreamImpl.java:663)
at vVd_g$.AVd_g$ [as collect_5_g$] (StreamImpl.java:587)
at A4d_g$ (BodyObserver.java:67)
at y4d_g$ (BodyObserver.java:30)
at Function.O4d_g$ (BodyObserver.java:28)
at MutationObserver.lambda_0_g$ (Runtime.java:166)
The bug is in class org.jboss.gwt.elemento.core.Elements.FilterHTMLElements<T>
:
FilterHTMLElements<T extends Node>
should be replaced with FilterHTMLElements<T>
I don't know what they changed in chrome 69 but if there is a or something, it will fail with the above ClassCastException.
org.jboss.gwt.elemento
to org.elemento
.org.jboss.gwt.elemento
to org.elemento
.Hey Harald,
So I've got another enhancement idea. If I've got a bunch of Builders being thrown around, I tend to forget to close things (enough .end()
). While this is fairly simple to debug, the messaging doesn't give me any indication as to WHICH builder is still open.
In my branch, I've added a String to the default constructor. In the case of an exception getting thrown, it simply prepends this string if it's not null. This way, I can tell where the issue is coming from.
I've been trying to figure out a way to add this automatically, but without any reflection cases it makes it quite difficult. What do you think?
If I put a @DataElement
annotation on a field with a misspelled name that doesn't match the name in the template, I get a compile error, which is great. However, if instead the field name is spelled correctly, but the type is incorrect, e.g. HTMLButtonElement instead of HTMLAnchorElement, instead of a compile error, I get a hard to read exception at runtime. Can the data element type be verified at compile time the same way that the field name is verified? I spent a few minutes looking in the TemplatedProcessor.java code, but I'm having a difficult time understanding how it works.
The Document.createTreeWalker()
method creates a TreeWalker object. TemplateUtil
uses this to walk
nodes to replace expressions.
The createTreeWalker
specification documents an optional third argument,
filter
, which is described as a NodeFilter
object containing an
acceptNode
method. The Elemental2 implementation of createTreeWalker
follows
this specification.
However, Internet Explorer expects the filter
argument to be a function,
not an object with an acceptNode
method. When an object is passed in instead,
Internet Explorer throws a JavaScriptException on the first call to the
nextNode()
method of the tree walker object.
See the answer to:
https://stackoverflow.com/questions/32163076/createtreewalker-in-ie-is-there-a-limit
This issue affects applications using HTML templates with expressions
in Internet Explorer. I've tested IE11 but believe older versions are
similarly affected.
The issue exists in the template-based samples, such as dagger
, and
templated
. These samples fail to load in Internet Explorer.
My proposed solution is to pass in null
as the filter
argument when calling
createTreeWalker
and handle the filtering within the while loop
after each call to nextNode()
.
I will submit a pull request with the proposed solution.
I'm fairly new to all this stuff so I apologize if this is more of a question than an issue...
I noticed the org.gwtproject.safehtml:safehtml still has a transitive dependency on gwt-user:
[INFO] | \- org.gwtproject.safehtml:safehtml:jar:1.0-SNAPSHOT:compile
[INFO] | \- com.google.gwt:gwt-user:jar:2.8.2:compile
[INFO] | +- com.google.jsinterop:jsinterop-annotations:jar:sources:1.0.2:compile
[INFO] | +- javax.validation:validation-api:jar:sources:1.0.0.GA:compile
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] | \- org.w3c.css:sac:jar:1.3:compile
Wasn't the purpose of using this library to specifically avoid depending on gwt-user? or does it not matter because it is not actually being used?
Also, it would be helpful in the Getting Started section to mention that anyone declaring a dependency on elemento-core will also need to declare the Vertispan snapshot repository, otherwise it won't be able to resolve the 1.0.0-SNAPSHOT version of safehtml. It is easy to figure this out, but would save people a little bit of time.
if the template file is moved from the resources folder and placed next to the template class the processor will fail to locate the template file and application wont compile.
intellij ide will not copy the resource until a manual rebuild is executed while the application is running
having the template in the resources folder, this will produce a stale copy of the template file in the target folder.
meanwhile the html template is meant only for gwt compilation, tbroyer plugin does not copy these resources from the sources folder, which prevent the creation of a stale copy anyway, and to be aligned with tbroyer setup we need the templates to be in the sources folder not the resources folder.
Thanks
My understanding is that gwt-user.jar doesn't need to be included in the war file, but it is getting included in my project's war. I believe this is because elemento lists gwt-user.jar as a compile scope dependency rather than a provided scope dependency, but I'm not confident that changing the scope to provided is the correct solution. Would making this change cause other problems?
There is a problem with JsInterop that it facilitates and do not propose a solution about the gwt $entry function wrapping. This will make the standard scheduler, error handling and maybe something else to produce unexpected behavior.
I have created this issue just to remember and apply the GWT solution when it gets chosen. There are various pull requests to fix the same problem in the GWT SDK itself (https://gwt-review.googlesource.com/#/q/user/src/com/google/gwt/core/client/internal/Entry.java).
This is probably going to be tricky to get right, so it might be worth making this into a documentation bug, rather than a fault in the library.
A GWT Widget does not attach its event listeners to the dom until the widget it attached. Being attached means that its root node has a parent node, and so on until a RootPanel instance - so the root element of the widget is actually attached to the page's body
.
This solves a memory leak that old browsers had - ancient versions of firefox had this issue, as did most every version of IE until Edge came around (I am certain that IE9 has the bug, IE10 and 11 haven't been tested by me).
This also provides a set of lifecycle methods to Widget which normal Elements do not have (though WebComponents do, in the form of the custom element's connected/disconnected callbacks - this could be one way to implement this in general).
However, when Widgets.asElement is called on a widget, it returns the root element of that widget, and the widget will never be marked as attached, so none of its event listeners will ever be attached to the DOM. If Widgets.asElement were to trigger the attach lifecycle when called, this could break the widget, since its own handlers would not be able to find a parent element, and would not be able to check the element's sizes, etc. That said, this is what gwtquery does in cases like this, where there is no higher widget in the page's structure, or the element this is being attached to is not yet itself connected to the document: https://github.com/gwtquery/gwtquery/blob/master/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java#L176-L217
--
Other cases to consider:
In this case, the widget isn't directly attached to another widget, and if the elements at (3) were not connected to the widget at (2) when (4) is added to them, you'll get different behavior than if they were. Likewise, removing (2) from the dom should cause (4) to be told it has detached.
--
Not all widgets are going to care if you get this exactly right, so I think this library needs to describe what level of correctness is offered, and possibly offer some utility methods to enable projects to attain their preferred level of correctness from there.
Currently finder methods are provided as static methods in org.jboss.gwt.elemento.core.Elements
. The element which is used for the underlying querySelector()
method has to be provided as first parameter:
import static org.jboss.gwt.elemento.core.Elements.body;
import static org.jboss.gwt.elemento.core.Elements.find;
HTMLElement foo = find(body(), By.classname("foo"));
The finder methods could also be provided for HTML builders. This would be the more object-oriented way and the first parameter would no longer be necessary:
import static org.jboss.gwt.elemento.core.Elements.body;
HTMLElement foo = body().find(By.classname("foo"));
Normally I'm a friend of clear API design and like to avoid ambiguity. I'd like to get your feedback whether I should duplicate the finder methods for HTML builders (vote with ๐) or leave it as it is and only provide static finder methods in org.jboss.gwt.elemento.core.Elements
(vote with ๐)
Occasionally I get the following exception in the Eclipse IDE. I am using elemento 0.8.1 .
@Templated processor threw an exception: java.lang.NullPointerException at org.jboss.gwt.elemento.processor.TemplatedProcessor.ancestorIsTemplated(TemplatedProcessor.java:669) at org.jboss.gwt.elemento.processor.TemplatedProcessor.validateType(TemplatedProcessor.java:278) at org.jboss.gwt.elemento.processor.TemplatedProcessor.onProcess(TemplatedProcessor.java:243) at elemento.shaded.org.jboss.auto.AbstractProcessor.process(AbstractProcessor.java:115) at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139) at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:110) at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159) at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:135) at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:937) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:447) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:423) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:383) at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:368) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:315) at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.incrementalBuildLoop(IncrementalImageBuilder.java:183) at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:140) at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:276) at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:197) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:795) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:216) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:259) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:312) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:315) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:367) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:388) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:142) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:232) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:60)
The TemplateProcessor currently adds injection annotations only if GIN is in the classpath. However, GIN is no longer maintained and the movement appears to be towards Dagger 2 as an annotation processor-based replacement.
However, when I switch to Dagger and remove GIN as a dependency, Elemento's TemplatedProcessor no longer generates Templated_* classes with the injection annotations.
I can keep GIN as a dependency in my project in the meantime, even though it is only being used to indicate to Elemento's TemplatedProcessor that the inject annotation should be applied to generated template classes.
I'd like to propose the following change in Elemento's Templated
annotation and the TemplatedProcessor
.
Add an injectiable
attribute on the Templated
annotation:
public @interface Templated {
enum Injectable { TRUE, FALSE, IF_GIN_PRESENT };
String value() default "";
Injectable injectable() default Injectable.IF_GIN_PRESENT;
}
And then in TemplatedProcessor,
String inject = ginInClasspath() ? "@javax.inject.Inject" : "";
becomes something determined for each type
boolean isInjectable = templated.injectable() == Injectable.TRUE
|| (templated.injectable() == Injectable.IF_GIN_PRESENT && ginInClasspath());
String inject = isInjectable ? "@javax.inject.Inject" : "";
This would maintain backwards compatibility for existing Templated classes that rely on the IF_GIN_PRESENT-type functionality, but would also add the ability to explicitly declare whether (or not) to include the inject annotation.
An alternative would be to make the injectable
attribute a simple boolean defaulting to false where true
means to include the Inject annotation and false
means to exclude it. This would be a breaking change that no longer checks for GIN in the classpath. Any classes relying on GIN would then need to explicitly declare injectable=true
.
If one of these approaches seems reasonable to you, I would be happy to put together a pull request.
Comming from gwt widgets something i hardly miss is the "onAttached/Detached" functionality gwt widgets provides to the developer: You can override to get notified when the widget is added/removed to the dom.
We need this to, e.g. focus and select input when it's attached, initialize Split.js, ...
This i something that would fit perfect into the org.jboss.gwt.elemento.core.Elements
class.
Here's the code i've wrote for onAttach:
private static String UID_KEY = "onattach-uid"; //$NON-NLS-1$
/**
* Utility method to listen when a element is attached to the dom
*
* @param element
* the element to listen for
* @param callback
* will be called when the element has been attached to the dom
*/
public static void onAttach(HTMLElement element, Consumer<HTMLElement> callback) {
String uid = Elements.createDocumentUniqueId();
element.setAttribute(UID_KEY, uid);
MutationObserver observer = new MutationObserver((records, o) -> {
for (MutationRecord record : records) {
if (record.addedNodes != null && record.addedNodes.length > 0) {
if (DomGlobal.document.body.querySelector("[" + UID_KEY + "='" + uid + "']") != null) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
element.removeAttribute(UID_KEY);
o.disconnect();
callback.accept(element);
}
}
}
return null;
});
MutationObserverInit ops = MutationObserverInit.create();
ops.setChildList(true);
ops.setSubtree(true);
observer.observe(DomGlobal.document.body, ops);
}
Cleanup the code and remove all deprecated classes and methods.
Is there a reason why published jars are compiled to target Java 11? From what I can see, elemento can be compiled using Java 8 as well.
I hope I'm not the only one still on Java 8 with need to use elemento :)
Widget
and IsWidget
com.google.gwt:gwt-*
, but only on com.google.elemental2:elemental2-*
After going thru the sources, these are the classes we use from gwt-user
:
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.google.web.bindery.event.shared.HandlerRegistration;
Additional Resources:
I was looking for a GWT sample and found this source.
I am very grateful to you for teaching me the latest coding.
I downloaded this and mavened but got a little error.
I modified pom.xml for gwt28.
<elemental2.version>1.0.0</elemental2.version>
<elemento.version>1.0.3</elemento.version>
Then I did "mvn gwt: devmode" at gwt28.
I got the following error. (Translating Japanese to English)
Main.java:[33,70] Can't find symbol. method getHash()
Location: Variable location of type elementary2.dom.Location
Main.java:[34,36] Can't find symbol. method getHash()
Location: Variable location of type elementary2.dom.Location
I'm using adopt open jdk8.
Can this source be compiled on Windows 10 ?
If I can compile on Linux, which distribution should I use?
Make sure Elemento works with J2CL / GWT3 and GWT2. Most of this should already be fixed by #48.
Link to the latest? Elemental2 snapshot: https://oss.sonatype.org/service/local/repositories/google-releases/content/com/google/gwt/elemental2-experimental/16-06-30/elemental2-experimental-16-06-30.jar
In IE TreeWalker.nextNode()
throws an exception. This method is used as part of the Handlebars processing.
The MSDN documentation for this method talks about a node parameter for nextNode()
: https://msdn.microsoft.com/en-us/library/ff975281(v=vs.85).aspx
Whereas the MDN documentation does not: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker/nextNode
Test whether adding an additional parameter just for IE solved this issue.
The following code breaks in Safari, as KeyboardEvent.key is not supported in Safari (https://www.w3schools.com/jsref/event_key_key.asp):
if (!Key.Enter.match(event)) {
doStuff();
}
Is there a work-around?
Thanks,
Harsh
Remove deprecated samples and add new samples for J2CL and Nalu.
(Iuff... I'll update this comment later)
https://github.com/ibaca/elemento
https://github.com/ibaca/rxtodo-gwt
This also revealed various problems with the old testing strategy, I have fixed using gwtmokito and making a dynamic mock of elements, but I'm not sure this is practical in the long term.
I plan to move the templating part of Elemento to Crysknife. Crysknife already contains most of the templating code of Elemento, integrates nicely with CDI and offers some extra features like GSS support on top of that.
The motivation behind this is that we don't want to have two very similar and competing template solutions. Please feel free to comment on this issue if you have a different opinion.
Now GWT project depends on annotation processor and vice versa 'maven-compiler-plugin' has GWT related classes in 'annotationProcessorPaths'
If I make a change to a template while running in super dev mode, I have to restart the super dev mode server to get the updated template to take effect. Is there any way to make the templates update automatically when I refresh the page using super dev mode, just like code changes update automatically without restarting the server?
I have given Elemento a try in myproject. I have tried to use HTML templates, but when I compile, the following error is thrown:
Cannot find template "path/to/template". Please make sure the template exists and resides in the source path.
The resource does exist in the path specified.
Does this sound familiar ? anybody have an idea ?
Hello! So I've finally resolved all my 2.8 funny business and have begun using Elemento in my application. I really like the API; however, I was wondering why Elements.Builder is final?
I would like to extend Builder to have some more application specific helpers. In a bunch of places, I create a lot of nav
elements and then there's the case of a list of links, which could nicely be wrapped, helping reduce the boiler plate even further.
I've seen people use recurring generics to have inheritable builders. Would this be something that Elemento could handle?
Thanks for such a helpful library!
Assume we have the following template
<div id="${item().title()}">
${item().title()}
</div>
and the following template class
@Templated
public abstract class Foo implements IsElement<HTMLDivElement>{
interface Item{
String icon();
String title();
}
abstract Item item();
public static Foo create(Item item){
return new Templated_Foo(item);
}
}
the generated templated class wont have the code to replace the expressions of the root element
@Generated("org.jboss.gwt.elemento.processor.TemplatedProcessor")
public final class Templated_Foo extends Foo {
private final somepackage.Item item;
private final elemental2.dom.HTMLDivElement templated_foo_root_element;
public Templated_Foo(somepackage.Item item) {
this.item = item;
this.templated_foo_root_element = (elemental2.dom.HTMLDivElement)DomGlobal.document.createElement("div");
this.templated_foo_root_element.setAttribute("id", "${item().title()}");
}
@Override
public elemental2.dom.HTMLDivElement asElement() {
return templated_foo_root_element;
}
@Override
somepackage.Item item() {
return item;
}
}
After updating my Elemento Plugin, I can no longer edit my pages.
I saw a message like "Database update process is running in the background.", I don't know what it means.
pls help
i'm getting an error while compiling when i have log4j on the classpath:
ERROR elemento.shaded.freemarker.log.LoggerFactory: Unexpected error when initializing logging for "Log4j". Exception: java.lang.RuntimeException: Unexpected error when creating logger factory for "Log4j". Caused by: java.lang.ClassNotFoundException: elemento.shaded.freemarker.log._Log4jLoggerFactory
sample: https://github.com/halkosajtarevic/elemento-log4j-issue
is there any way to workaround this? thanks in advance!
Is there also support for datalist for intput ?
Command line generation is Ok, but in the Eclipse I see the error.
template class:
@Templated("Todo.html#todos")
abstract class ApplicationElement implements IsElement<HTMLElement> {
static ApplicationElement create() {
return new Templated_ApplicationElement();
}
}
html template:
<section data-element="todos" class="todoapp">
<h1>Hi</h1>
</section>
Stacktrace:
@Templated processor threw an exception: java.lang.IllegalArgumentException: Unsupported location: CLASS_PATH
at org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl.getFileFromOutputLocation(IdeFilerImpl.java:186)
at org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl.getResource(IdeFilerImpl.java:154)
at org.jboss.gwt.elemento.processor.TemplatedProcessor.parseTemplate(TemplatedProcessor.java:366)
at org.jboss.gwt.elemento.processor.TemplatedProcessor.processType(TemplatedProcessor.java:296)
at org.jboss.gwt.elemento.processor.TemplatedProcessor.onProcess(TemplatedProcessor.java:245)
at elemento.shaded.org.jboss.auto.AbstractProcessor.process(AbstractProcessor.java:115)
at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139)
at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:121)
at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159)
at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:135)
at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:933)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:443)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:419)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:372)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:331)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:305)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:136)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:267)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:195)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:142)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:232)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Hi All,
elemento-core 1.0.1 has a dependency to gwt-safehtml with SNAPSHOT version. This should not happen, I also don't know why Maven Central allows a RELEASE artifact to be dependent on SNAPSHOT artifact.
This is not good for all the developers who are in the enterprise environment and can only access Maven through Nexus with only RELEASES artifacts.
iterate over a node list received from mutation observer with foreach
for (Node node : nodes) {
}
it throws class cast exception
and this happens when the node is not an element, but a text or comment node
in firefox it works without errors
the solution for this is to use normal loops and do Js.uncheckedCast()
to node, then we check the type of the node if it is an element node.
if you have $ in your template like this example <paper-button class$='[[something]]>test</paper-button>
the generator will produce a compile error
the use of $ is common in polymer and is being used to dynamically bind and inject css styles and image sources.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.