Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Dmitrii Tikhomirov
    @treblereel
    @hpehl cool, thanks !
    Dr. Lofi Dewanto
    @lofidewanto_twitter
    👍👍👍
    Daniel Korbel
    @masterdany88
    Hi. How to use this class with elemento?: https://developer.mozilla.org/en-US/docs/Web/API/URL/URL
    ?
    I cant find valid import
    Colin Alworth
    @niloc132
    @masterdany88 elemental2.dom.URL
    Rob Newton
    @rob5n
    Hi! A question about elemento templates: I have a @DataElement class field called say "user_id". And in the corresponding HTML template file I have an element with attribute 'data-element="user_ID"' so I mistakenly used the wrong case for id/ID. It appears that the elemento annotation processor at compile time doesn't flag this mismatch at compile time. But at runtime the element is not found and not bound to the java object field!? Is this known behaviour? I must confess that I am using a hacked version of elemento-template-* 0.9.6 that depends on elemento-core 1.0.2. I wonder if I have broken something in my hack.
    Colin Alworth
    @niloc132
    @rob5n not an elemento expert, but annotation processors aren't smart enough to handle changes in code, they rely on whatever is calling them to know what actually changed
    so, what is your build tool, and are you sure it is running the processor when you make any chance at all to the html template?
    Rob Newton
    @rob5n
    @niloc132 I do a clean build from maven. I can see the elemento processor compiling the templates in the compile output. If it cannot find a match it logs:
    Cannot find a matching element in AuditLogEnq.html using "[data-element=user_id]" as selector
    But I am finding that the compiler finds a case-insensitive match and compiles the template. But at runtime it comes unstuck.
    Of course I should be careful to get the cases matching in the first place, but sometimes mistakes are made and I am confused by it compiling OK but not running.
    Colin Alworth
    @niloc132
    even from a clean? that's very weird, definitely sounds like a bug in elemento's processor
    Rob Newton
    @rob5n
    From TemplatedProcessor:
        private void verifySelector(String selector, Element element, TemplateSelector templateSelector,
                org.jsoup.nodes.Element root) {
            // make sure to use the same logic for finding matching elements as in TemplateUtils!
            Elements elements = root.getElementsByAttributeValue("data-element", selector);
    Which calls the jsoup library:
        /**
         * Find elements that have an attribute with the specific value. Case insensitive.
    ...
         */
        public Elements getElementsByAttributeValue(String key, String value) {
    Colin Alworth
    @niloc132
    yep, that looks like a bug :)
    Rob Newton
    @rob5n
    So the compile checker does case insensitive.
    Rob Newton
    @rob5n
    And the generated code calls TemplateUtil.resolveElementAs(...) which calls:
    context.querySelector("[data-element=" + identifier + "]");
    which would be case sensitive .
    So yes @niloc132 it looks like a bug
    Colin Alworth
    @niloc132
    yep - gotta fix one or the other
    Rob Newton
    @rob5n
    OK, the way to use JSoup to do a case-insensitive match on attribute name and a case-sensitive match on attibute value is:
            //Elements elements = root.getElementsByAttributeValue("data-element", selector);
            Elements elements = root.getElementsByAttribute("data-element");
            long matchCount = elements.stream().filter(elem -> elem.attributes().getIgnoreCase("data-element").equals(selector)).count();
    I'll add an issue to the crysknife-io project, which is where the maintained templating code now lives, @treblereel
    Harald Pehl
    @hpehl
    Thanks @rob5n for looking into this. Looks like a bug to me. And thanks for adding an issue to crysknife.
    Daniel Korbel
    @masterdany88
    Hi. I found out in newest version that method click() has disapeared from HTMLElement and HTMLAnchorElement
    How this can be replaced?
    Dmitrii Tikhomirov
    @treblereel
    maybe after elemental2 has been updated to 1.1.0
    Daniel Korbel
    @masterdany88
    I am using elemental2-dom 1.1.0 version
    Daniel Korbel
    @masterdany88
    How to simulate programatically click operation?
    Daniel Korbel
    @masterdany88

    I use to do this approach https://blog.jayway.com/2017/07/13/open-pdf-downloaded-api-javascript/

    showFile(blob){
      // It is necessary to create a new blob object with mime-type explicitly set
      // otherwise only Chrome works like it should
      var newBlob = new Blob([blob], {type: "application/pdf"})
    
      // IE doesn't allow using a blob object directly as link href
      // instead it is necessary to use msSaveOrOpenBlob
      if (window.navigator && window.navigator.msSaveOrOpenBlob) {
        window.navigator.msSaveOrOpenBlob(newBlob);
        return;
      } 
    
      // For other browsers: 
      // Create a link pointing to the ObjectURL containing the blob.
      const data = window.URL.createObjectURL(newBlob);
      var link = document.createElement('a');
      link.href = data;
      link.download="file.pdf";
      link.click();
      setTimeout(function(){
        // For Firefox it is necessary to delay revoking the ObjectURL
        window.URL.revokeObjectURL(data);
      }, 100);
    }
    
    fetch([url to fetch], {[options setting custom http-headers]})
    .then(r => r.blob())
    .then(showFile)

    but it is no longer possible
    My current impl:

    public class BlobDownload {
    
        private BlobDownload() {
        }
    
        public static <T> void downloadBlob(T data, String contentType, String fileName) {
            BlobPropertyBag blobPropertyBag = BlobPropertyBag.create();
            blobPropertyBag.setType(contentType);
            Blob blob = new Blob(new Blob.ConstructorBlobPartsArrayUnionType[]{Blob.ConstructorBlobPartsArrayUnionType.of(data)}, blobPropertyBag);
            downloadBlob(blob, fileName);
        }
    
        public static void downloadBlob(Blob blob, String fileName) {
            String url = URL.createObjectURL(blob);
            HTMLAnchorElement anchor = a()
                    .attr("href", url)
                    .attr("download", fileName)
                    .style("display: none;")
                    .element();
    
            DomGlobal.document.body.appendChild(anchor);
            anchor.focus();
            anchor.remove();
            DomGlobal.setTimeout(p0 -> URL.revokeObjectURL(url), 5000);
        }
    }
    how to download it?
    Daniel Korbel
    @masterdany88
    here also click method disapeared:
    Daniel Korbel
    @masterdany88
    solution:
    anchor.dispatchEvent(new MouseEvent('click'));
    Daniel Korbel
    @masterdany88
    Hi. How I can manually trigger/ consume event: elemental2.dom.EventListener
    ?
    I do not have event object. I am getting success response and I wanna trigger it. How to do it?
    Harald Pehl
    @hpehl
    Don’t know exactly your context. But shouldn’t https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click work?
    Harald Pehl
    @hpehl

    @/all After quite some while of silence, I've just released Elemento 1.0.10.

    There are no noteworthy new features. This release mainly updates the dependencies and moves the samples to its own repository. I've also setup a release workflow based on GitHub actions to speed up releasing new versions.

    Starting with release 1.0.8, Elemento comes in two variants:

    1. Normal versions depend on org.gwtproject.event:gwt-event and org.gwtproject.safehtml:gwt-safehtml
    2. Versions ending in -gwtcom depend on com.google.gwt:gwt-user

    This makes it possible to use Elemento in both GWT.com and GWT project / J2CL projects. The samples have been updated and show how to use Elemento in different setups.

    As always, any comments and feedback is highly appreciated.

    Dmitrii Tikhomirov
    @treblereel
    @hpehl good work, thanks !
    Harald Pehl
    @hpehl
    @treblereel Though I still can’t get the crysknife sample to compile.
    Dmitrii Tikhomirov
    @treblereel
    yeah, i am working on it, it ll be fixed this week
    Harald Pehl
    @hpehl
    👍
    Tino Desjardins
    @TDesjardins
    Sounds nice! Thanks @hpehl !
    Rob Newton
    @rob5n
    :plus1:
    Ignacio Baca Moreno-Torres
    @ibaca
    🍻