<div dir="ltr">Hmm, yes. I think I like the idea of using the AttachHandler as well. It&#39;s a bit cleaner and simpler. (From a framework perspective.)<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 14, 2013 at 6:49 PM, Christian Sadilek <span dir="ltr">&lt;<a href="mailto:csadilek@redhat.com" target="_blank">csadilek@redhat.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi,<div><br></div><div>I really like the simplicity of our current &quot;template wins&quot; strategy. I just tried the following which seems to work:</div>
<div><br></div><div>In the constructor of TransitionAnchor (or any other widget for that matter) you could add an AttachHandler and change the desired attribute(s):</div><div><br></div><div><div style="margin:0px;font-size:11px;font-family:Monaco">
MyWidget() {</div><div style="margin:0px;font-size:11px;font-family:Monaco">   addAttachHandler(<span style="color:rgb(147,26,104)">new</span> Handler() {</div><div style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(119,119,119)">
<span style="color:rgb(0,0,0)">    </span>@Override</div><div style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:rgb(147,26,104)">public</span> <span style="color:rgb(147,26,104)">void</span> onAttachOrDetach(AttachEvent event) {</div>
<div style="margin:0px;font-size:11px;font-family:Monaco"><div style="margin:0px">      <span style="color:rgb(78,144,114)">//change attributes</span></div></div><div style="margin:0px;font-size:11px;font-family:Monaco">    }     </div>
<div style="margin:0px;font-size:11px;font-family:Monaco">   });</div><div style="margin:0px;font-size:11px;font-family:Monaco">}</div></div><div style="margin:0px;font-size:11px;font-family:Monaco"><br></div><div style="margin:0px;font-size:11px;font-family:Monaco">
e.g.</div><div style="margin:0px;font-size:11px;font-family:Monaco"><br></div><div><div style="margin:0px;font-size:11px;font-family:Monaco">TransitionAnchor(Navigation navigation, <span style="color:rgb(147,26,104)">final</span> Class&lt;P&gt; toPage) {</div>
<div style="margin:0px;font-size:11px;font-family:Monaco">   ...</div><div style="margin:0px;font-size:11px;font-family:Monaco">   addAttachHandler(<span style="color:#931a68">new</span> Handler() {</div><div style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(119,119,119)">
<span style="color:#000000">    </span>@Override</div><div style="margin:0px;font-size:11px;font-family:Monaco">    <span style="color:#931a68">public</span> <span style="color:#931a68">void</span> onAttachOrDetach(AttachEvent event) {</div>
<div style="margin:0px;font-size:11px;font-family:Monaco">      initHref(toPage);</div><div style="margin:0px;font-size:11px;font-family:Monaco">    }     </div><div style="margin:0px;font-size:11px;font-family:Monaco">   });</div>
<div style="margin:0px;font-size:11px;font-family:Monaco">}</div></div><div style="margin:0px;font-size:11px;font-family:Monaco"><br></div><div>This causes the href attribute in the template to be overridden and should work right away without changes to the framework. Eric, I built a quick prototype which worked, but it needs more testing.</div>
<div><br></div><div>The advantage of this programmatic solution is that it&#39;s flexible and also becomes a widget-specific feature which won&#39;t add complexity to the framework (no additional annotations required). Of course, that argument only holds if we consider this requirement an edge case, which I think it is. If this is a more common scenario we could also add an @WidgetAttached annotation to get rid of the AttachHandler boilerplate or implement the suggested @TemplateOverride.</div>
<div><br></div><div>Cheers,</div><div>Christian</div><div><br><div><div><div class="h5"><div>On 2013-01-14, at 4:43 PM, &quot;Lincoln Baxter, III&quot; &lt;<a href="mailto:lincolnbaxter@gmail.com" target="_blank">lincolnbaxter@gmail.com</a>&gt; wrote:</div>
<br></div></div><blockquote type="cite"><div><div class="h5"><div dir="ltr">Rest of the Errai team, what do you think?<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 11, 2013 at 2:08 PM, Eric Wittmann <span dir="ltr">&lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I&#39;d be favor of some annotations to control this aspect of the templates.  I agree that care is needed, though.  :)<br>


<br>
Certainly an @TemplateOverride annotation per widget can make sense. Perhaps the existing @Templated annotation can have an additional attribute?<br>
<br>
Simple set of global attributes that should be widget-favored:<br>
<br>
   @Templated(<br>
      value=&quot;artifacts.html#page&quot;,<br>
      attributeOverrides={&quot;href&quot;, &quot;id&quot;, &quot;src&quot;})<br>
<br>
That will cause the href, id, and src attributes to be widget-favored rather than template-favored.<br>
<br>
Or a more advanced possibility:<br>
<br>
@Templated(value=&quot;artifacts.<u></u>html#page&quot;, attributeOverrides={&quot;@href&quot;, &quot;button@id&quot;, &quot;.help-icon@src&quot;, &quot;#breadcrumbs@class&quot;})<br>
<br>
That will cause the following attributes to be widget-favored:<br>
  * All href attributes<br>
  * The id attribute on button elements<br>
  * The src attribute on any element with class=help-icon<br>
  * The class attribute on the element with id=breadcrumbs<br>
<br>
Support could exist only for the spec:<br>
<br>
&lt;element&gt;[.#]&lt;classOrId&gt;@&lt;<u></u>attribute&gt;<br>
<br>
-Eric<div><br>
<br>
On 01/11/2013 01:36 PM, Lincoln Baxter, III wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
Maybe we need an @TemplateOverride annotation to alter this behavior?<br>
<br>
It wouldn&#39;t be hard to do. Though... we may want the ability to do more<br>
global overrides as well... for instance, maybe you want all href<br>
attributes to default to the widget value instead.<br>
<br>
Getting the experience of this right might be tricky.<br>
<br>
Thoughts?<br>
<br>
---<br>
Lincoln Baxter&#39;s Droid<br>
<a href="http://ocpsoft.org/" target="_blank">http://ocpsoft.org</a><br>
&quot;Keep it Simple&quot;<br>
<br>
On Jan 11, 2013 1:14 PM, &quot;Eric Wittmann&quot; &lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br></div><div><div>
&lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.<u></u>com</a>&gt;&gt; wrote:<br>
<br>
    No worries, Lincoln.  Good luck with the Forge stuff. :)<br>
<br>
    As for the remaining attribute issue, I came up with an acceptable<br>
    workaround.  As I mentioned in the pull request, I want the live<br>
    preview/templates to be as functional as possible, including the<br>
    ability to navigate around the different pages (statically when that<br>
    makes sense - e.g. a primary nav bar).  So I want to have &quot;href&quot;<br>
    attributes that work in the templates.  At the same time, I want the<br>
    application to have the right value set on the href.<br>
<br>
    Since the template code favors attributes in the template (and I<br>
    agree it almost always should!) I figured I had two options.  Either<br>
    modify the templating code to *sometimes* prefer widget attributes<br>
    over template attributes, or else find a way to remove the href<br>
    attributes from the template.<br>
<br>
    I thought about a &quot;data-exclude-attributes&quot; attribute in the<br>
    template, but that didn&#39;t feel right.<br>
<br>
    Instead, I simply removed all the hrefs from my template and<br>
    replaced them with a tiny bit of on-document-load javascript that<br>
    inserts them. This way, when the file is used as an Errai template,<br>
    there&#39;s no &#39;href&#39; attribute to get in the way.  At the same time,<br>
    when viewed directly in the browser, the templates still appear to<br>
    have valid hrefs (because they get added by my little bit of JS code).<br>
<br>
    Seems like a reasonable workaround, assuming there aren&#39;t too many<br>
    static links.  And I think in my applications there won&#39;t be too many.<br>
<br>
    -Eric<br>
<br>
<br>
    On 01/11/2013 12:22 PM, Lincoln Baxter wrote:<br>
<br>
        Hey Eric,<br>
<br>
        Thanks for getting in touch!<br>
<br>
        I&#39;m sorry it took me so long to respond, I&#39;ve been in fire<br>
        fighting mode trying to get Forge ready for our big team meeting.<br>
<br>
        I&#39;ve also copied my preferred email address and the errai-dev<br>
        list, which are two places that will probably get a faster<br>
        response from me, since I don&#39;t always have access to the VPN :)<br>
<br>
        The issue has already been resolved, but I agree with all of<br>
        your changes. The attribute &quot;whacking&quot; can be problematic if you<br>
        actually want to go the &quot;other way.&quot;<br>
<br>
        Sorry again for the late reply. Feel free to email me personally<br>
        (at home) and copy the dev list for best results :)<br>
<br>
        Thanks!<br>
        ~Lincoln<br>
<br>
        ----- Original Message -----<br>
        From: &quot;Eric Wittmann&quot; &lt;<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.com</a><br></div></div><div>
        &lt;mailto:<a href="mailto:eric.wittmann@redhat.com" target="_blank">eric.wittmann@redhat.<u></u>com</a>&gt;&gt;<br>
        To: &quot;Lincoln Baxter&quot; &lt;<a href="mailto:lbaxter@redhat.com" target="_blank">lbaxter@redhat.com</a><br></div><div>
        &lt;mailto:<a href="mailto:lbaxter@redhat.com" target="_blank">lbaxter@redhat.com</a>&gt;&gt;, <a href="mailto:jfuerth@redhat.com" target="_blank">jfuerth@redhat.com</a><br>
        &lt;mailto:<a href="mailto:jfuerth@redhat.com" target="_blank">jfuerth@redhat.com</a>&gt;<br>
        Sent: Wednesday, January 2, 2013 1:31:03 PM<br>
        Subject: Errai navigation + templating discussion<br>
<br>
        Hey Lincoln.  I&#39;m in the JBoss middleware group, specifically<br>
        working on<br>
        the Overlord project.  One of my responsibilities is producing a<br>
        couple<br>
        of UI applications.  To that end, I&#39;ve been digging Errai and<br>
        hope to<br>
        contribute back based on my project needs.<br>
<br>
        Ok, that&#39;s out of the way.  :)  I&#39;ve been discussing a couple of<br>
        Errai 3<br>
        features with Jonathan (via github pull request comments :)).<br>
          One of<br>
        these is a new injectable Transition widget in errai-navigation.<br>
          You<br>
        can see the pull request here:<br>
<br></div>
        <a href="https://github.com/errai/__errai/pull/27" target="_blank">https://github.com/errai/__<u></u>errai/pull/27</a><div><br>
        &lt;<a href="https://github.com/errai/errai/pull/27" target="_blank">https://github.com/errai/<u></u>errai/pull/27</a>&gt;<br>
<br>
        The goal was to really take out a lot of the boilerplate for the<br>
        simple<br>
        case of static hyperlinks from one @Page to another.<br>
<br>
        I think it works well except for one small issue (documented in the<br>
        &quot;What&#39;s Missing&quot; section of the pull request).<br>
<br>
        Jonathan mentioned that you might have some thoughts about the<br>
        templating issue, as it relates to attribute priority.<br>
<br>
        Any thoughts?  I&#39;d like the href to be preserved in this case<br>
        because I<br>
        would like the template&#39;s href to point to some local HTML file<br>
        while<br>
        the live application uses the proper history token as the href.<br>
<br>
        Thanks!<br>
<br>
        -Eric<br>
<br>
</div></blockquote>
</blockquote></div><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.org/" target="_blank">http://ocpsoft.org</a><br>&quot;Simpler is better.&quot;
</div></div></div>
_______________________________________________<br>errai-dev mailing list<br><a href="mailto:errai-dev@lists.jboss.org" target="_blank">errai-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/errai-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/errai-dev</a><br>
</blockquote></div><br></div></div><br>_______________________________________________<br>
errai-dev mailing list<br>
<a href="mailto:errai-dev@lists.jboss.org">errai-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/errai-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/errai-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>&quot;Simpler is better.&quot;
</div>