<div dir="ltr">Sweet! We should add this to the Errai UI docs! Anyone have an example of the code (And or a test case?)<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 15, 2013 at 7:28 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+1 for AttachHandler!<br>
<br>
When I impl&#39;d the TransitionAnchor I tried @PostConstruct to do just<br>
what you described, but obviously that didn&#39;t work.  I didn&#39;t realize<br>
there was an attach handler capability.<br>
<br>
-Eric<br>
<div class="im"><br>
On 01/14/2013 08:02 PM, Lincoln Baxter, III wrote:<br>
&gt; Hmm, yes. I think I like the idea of using the AttachHandler as well.<br>
&gt; It&#39;s a bit cleaner and simpler. (From a framework perspective.)<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Jan 14, 2013 at 6:49 PM, Christian Sadilek &lt;<a href="mailto:csadilek@redhat.com">csadilek@redhat.com</a><br>
</div><div><div class="h5">&gt; &lt;mailto:<a href="mailto:csadilek@redhat.com">csadilek@redhat.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Hi,<br>
&gt;<br>
&gt;     I really like the simplicity of our current &quot;template wins&quot;<br>
&gt;     strategy. I just tried the following which seems to work:<br>
&gt;<br>
&gt;     In the constructor of TransitionAnchor (or any other widget for that<br>
&gt;     matter) you could add an AttachHandler and change the desired<br>
&gt;     attribute(s):<br>
&gt;<br>
&gt;     MyWidget() {<br>
&gt;         addAttachHandler(new Handler() {<br>
&gt;     @Override<br>
&gt;     public void onAttachOrDetach(AttachEvent event) {<br>
&gt;     //change attributes<br>
&gt;          }<br>
&gt;         });<br>
&gt;     }<br>
&gt;<br>
&gt;     e.g.<br>
&gt;<br>
&gt;     TransitionAnchor(Navigation navigation, final Class&lt;P&gt; toPage) {<br>
&gt;         ...<br>
&gt;         addAttachHandler(new Handler() {<br>
&gt;     @Override<br>
&gt;     public void onAttachOrDetach(AttachEvent event) {<br>
&gt;            initHref(toPage);<br>
&gt;          }<br>
&gt;         });<br>
&gt;     }<br>
&gt;<br>
&gt;     This causes the href attribute in the template to be overridden and<br>
&gt;     should work right away without changes to the framework. Eric, I<br>
&gt;     built a quick prototype which worked, but it needs more testing.<br>
&gt;<br>
&gt;     The advantage of this programmatic solution is that it&#39;s flexible<br>
&gt;     and also becomes a widget-specific feature which won&#39;t add<br>
&gt;     complexity to the framework (no additional annotations required). Of<br>
&gt;     course, that argument only holds if we consider this requirement an<br>
&gt;     edge case, which I think it is. If this is a more common scenario we<br>
&gt;     could also add an @WidgetAttached annotation to get rid of the<br>
&gt;     AttachHandler boilerplate or implement the suggested @TemplateOverride.<br>
&gt;<br>
&gt;     Cheers,<br>
&gt;     Christian<br>
&gt;<br>
&gt;     On 2013-01-14, at 4:43 PM, &quot;Lincoln Baxter, III&quot;<br>
</div></div><div class="im">&gt;     &lt;<a href="mailto:lincolnbaxter@gmail.com">lincolnbaxter@gmail.com</a> &lt;mailto:<a href="mailto:lincolnbaxter@gmail.com">lincolnbaxter@gmail.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;&gt;     Rest of the Errai team, what do you think?<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     On Fri, Jan 11, 2013 at 2:08 PM, Eric Wittmann<br>
</div><div class="im">&gt;&gt;     &lt;<a href="mailto:eric.wittmann@redhat.com">eric.wittmann@redhat.com</a> &lt;mailto:<a href="mailto:eric.wittmann@redhat.com">eric.wittmann@redhat.com</a>&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;         I&#39;d be favor of some annotations to control this aspect of the<br>
&gt;&gt;         templates.  I agree that care is needed, though.  :)<br>
&gt;&gt;<br>
&gt;&gt;         Certainly an @TemplateOverride annotation per widget can make<br>
&gt;&gt;         sense. Perhaps the existing @Templated annotation can have an<br>
&gt;&gt;         additional attribute?<br>
&gt;&gt;<br>
&gt;&gt;         Simple set of global attributes that should be widget-favored:<br>
&gt;&gt;<br>
&gt;&gt;            @Templated(<br>
&gt;&gt;               value=&quot;artifacts.html#page&quot;,<br>
&gt;&gt;               attributeOverrides={&quot;href&quot;, &quot;id&quot;, &quot;src&quot;})<br>
&gt;&gt;<br>
&gt;&gt;         That will cause the href, id, and src attributes to be<br>
&gt;&gt;         widget-favored rather than template-favored.<br>
&gt;&gt;<br>
&gt;&gt;         Or a more advanced possibility:<br>
&gt;&gt;<br>
</div>&gt;&gt;         @Templated(value=&quot;artifacts.__html#page&quot;,<br>
<div class="im">&gt;&gt;         attributeOverrides={&quot;@href&quot;, &quot;button@id&quot;, &quot;.help-icon@src&quot;,<br>
&gt;&gt;         &quot;#breadcrumbs@class&quot;})<br>
&gt;&gt;<br>
&gt;&gt;         That will cause the following attributes to be widget-favored:<br>
&gt;&gt;           * All href attributes<br>
&gt;&gt;           * The id attribute on button elements<br>
&gt;&gt;           * The src attribute on any element with class=help-icon<br>
&gt;&gt;           * The class attribute on the element with id=breadcrumbs<br>
&gt;&gt;<br>
&gt;&gt;         Support could exist only for the spec:<br>
&gt;&gt;<br>
</div>&gt;&gt;         &lt;element&gt;[.#]&lt;classOrId&gt;@&lt;__attribute&gt;<br>
<div class="im">&gt;&gt;<br>
&gt;&gt;         -Eric<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;         On 01/11/2013 01:36 PM, Lincoln Baxter, III wrote:<br>
&gt;&gt;<br>
&gt;&gt;             Maybe we need an @TemplateOverride annotation to alter<br>
&gt;&gt;             this behavior?<br>
&gt;&gt;<br>
&gt;&gt;             It wouldn&#39;t be hard to do. Though... we may want the<br>
&gt;&gt;             ability to do more<br>
&gt;&gt;             global overrides as well... for instance, maybe you want<br>
&gt;&gt;             all href<br>
&gt;&gt;             attributes to default to the widget value instead.<br>
&gt;&gt;<br>
&gt;&gt;             Getting the experience of this right might be tricky.<br>
&gt;&gt;<br>
&gt;&gt;             Thoughts?<br>
&gt;&gt;<br>
&gt;&gt;             ---<br>
&gt;&gt;             Lincoln Baxter&#39;s Droid<br>
</div>&gt;&gt;             <a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a> &lt;<a href="http://ocpsoft.org/" target="_blank">http://ocpsoft.org/</a>&gt;<br>
<div class="im">&gt;&gt;             &quot;Keep it Simple&quot;<br>
&gt;&gt;<br>
&gt;&gt;             On Jan 11, 2013 1:14 PM, &quot;Eric Wittmann&quot;<br>
&gt;&gt;             &lt;<a href="mailto:eric.wittmann@redhat.com">eric.wittmann@redhat.com</a> &lt;mailto:<a href="mailto:eric.wittmann@redhat.com">eric.wittmann@redhat.com</a>&gt;<br>
</div>&gt;&gt;             &lt;mailto:<a href="mailto:eric.wittmann@redhat.">eric.wittmann@redhat.</a>__com<br>
<div><div class="h5">&gt;&gt;             &lt;mailto:<a href="mailto:eric.wittmann@redhat.com">eric.wittmann@redhat.com</a>&gt;&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;                 No worries, Lincoln.  Good luck with the Forge stuff. :)<br>
&gt;&gt;<br>
&gt;&gt;                 As for the remaining attribute issue, I came up with<br>
&gt;&gt;             an acceptable<br>
&gt;&gt;                 workaround.  As I mentioned in the pull request, I<br>
&gt;&gt;             want the live<br>
&gt;&gt;                 preview/templates to be as functional as possible,<br>
&gt;&gt;             including the<br>
&gt;&gt;                 ability to navigate around the different pages<br>
&gt;&gt;             (statically when that<br>
&gt;&gt;                 makes sense - e.g. a primary nav bar).  So I want to<br>
&gt;&gt;             have &quot;href&quot;<br>
&gt;&gt;                 attributes that work in the templates.  At the same<br>
&gt;&gt;             time, I want the<br>
&gt;&gt;                 application to have the right value set on the href.<br>
&gt;&gt;<br>
&gt;&gt;                 Since the template code favors attributes in the<br>
&gt;&gt;             template (and I<br>
&gt;&gt;                 agree it almost always should!) I figured I had two<br>
&gt;&gt;             options.  Either<br>
&gt;&gt;                 modify the templating code to *sometimes* prefer<br>
&gt;&gt;             widget attributes<br>
&gt;&gt;                 over template attributes, or else find a way to remove<br>
&gt;&gt;             the href<br>
&gt;&gt;                 attributes from the template.<br>
&gt;&gt;<br>
&gt;&gt;                 I thought about a &quot;data-exclude-attributes&quot; attribute<br>
&gt;&gt;             in the<br>
&gt;&gt;                 template, but that didn&#39;t feel right.<br>
&gt;&gt;<br>
&gt;&gt;                 Instead, I simply removed all the hrefs from my<br>
&gt;&gt;             template and<br>
&gt;&gt;                 replaced them with a tiny bit of on-document-load<br>
&gt;&gt;             javascript that<br>
&gt;&gt;                 inserts them. This way, when the file is used as an<br>
&gt;&gt;             Errai template,<br>
&gt;&gt;                 there&#39;s no &#39;href&#39; attribute to get in the way.  At the<br>
&gt;&gt;             same time,<br>
&gt;&gt;                 when viewed directly in the browser, the templates<br>
&gt;&gt;             still appear to<br>
&gt;&gt;                 have valid hrefs (because they get added by my little<br>
&gt;&gt;             bit of JS code).<br>
&gt;&gt;<br>
&gt;&gt;                 Seems like a reasonable workaround, assuming there<br>
&gt;&gt;             aren&#39;t too many<br>
&gt;&gt;                 static links.  And I think in my applications there<br>
&gt;&gt;             won&#39;t be too many.<br>
&gt;&gt;<br>
&gt;&gt;                 -Eric<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;                 On 01/11/2013 12:22 PM, Lincoln Baxter wrote:<br>
&gt;&gt;<br>
&gt;&gt;                     Hey Eric,<br>
&gt;&gt;<br>
&gt;&gt;                     Thanks for getting in touch!<br>
&gt;&gt;<br>
&gt;&gt;                     I&#39;m sorry it took me so long to respond, I&#39;ve been<br>
&gt;&gt;             in fire<br>
&gt;&gt;                     fighting mode trying to get Forge ready for our<br>
&gt;&gt;             big team meeting.<br>
&gt;&gt;<br>
&gt;&gt;                     I&#39;ve also copied my preferred email address and<br>
&gt;&gt;             the errai-dev<br>
&gt;&gt;                     list, which are two places that will probably get<br>
&gt;&gt;             a faster<br>
&gt;&gt;                     response from me, since I don&#39;t always have access<br>
&gt;&gt;             to the VPN :)<br>
&gt;&gt;<br>
&gt;&gt;                     The issue has already been resolved, but I agree<br>
&gt;&gt;             with all of<br>
&gt;&gt;                     your changes. The attribute &quot;whacking&quot; can be<br>
&gt;&gt;             problematic if you<br>
&gt;&gt;                     actually want to go the &quot;other way.&quot;<br>
&gt;&gt;<br>
&gt;&gt;                     Sorry again for the late reply. Feel free to email<br>
&gt;&gt;             me personally<br>
&gt;&gt;                     (at home) and copy the dev list for best results :)<br>
&gt;&gt;<br>
&gt;&gt;                     Thanks!<br>
&gt;&gt;                     ~Lincoln<br>
&gt;&gt;<br>
&gt;&gt;                     ----- Original Message -----<br>
&gt;&gt;                     From: &quot;Eric Wittmann&quot; &lt;<a href="mailto:eric.wittmann@redhat.com">eric.wittmann@redhat.com</a><br>
&gt;&gt;             &lt;mailto:<a href="mailto:eric.wittmann@redhat.com">eric.wittmann@redhat.com</a>&gt;<br>
</div></div><div class="im">&gt;&gt;                     &lt;mailto:<a href="mailto:eric.wittmann@redhat.">eric.wittmann@redhat.</a>__com<br>
&gt;&gt;             &lt;mailto:<a href="mailto:eric.wittmann@redhat.com">eric.wittmann@redhat.com</a>&gt;&gt;&gt;<br>
&gt;&gt;                     To: &quot;Lincoln Baxter&quot; &lt;<a href="mailto:lbaxter@redhat.com">lbaxter@redhat.com</a><br>
&gt;&gt;             &lt;mailto:<a href="mailto:lbaxter@redhat.com">lbaxter@redhat.com</a>&gt;<br>
</div><div class="im">&gt;&gt;                     &lt;mailto:<a href="mailto:lbaxter@redhat.com">lbaxter@redhat.com</a><br>
&gt;&gt;             &lt;mailto:<a href="mailto:lbaxter@redhat.com">lbaxter@redhat.com</a>&gt;&gt;&gt;, <a href="mailto:jfuerth@redhat.com">jfuerth@redhat.com</a><br>
&gt;&gt;             &lt;mailto:<a href="mailto:jfuerth@redhat.com">jfuerth@redhat.com</a>&gt;<br>
</div>&gt;&gt;                     &lt;mailto:<a href="mailto:jfuerth@redhat.com">jfuerth@redhat.com</a><br>
<div class="im">&gt;&gt;             &lt;mailto:<a href="mailto:jfuerth@redhat.com">jfuerth@redhat.com</a>&gt;&gt;<br>
&gt;&gt;                     Sent: Wednesday, January 2, 2013 1:31:03 PM<br>
&gt;&gt;                     Subject: Errai navigation + templating discussion<br>
&gt;&gt;<br>
&gt;&gt;                     Hey Lincoln.  I&#39;m in the JBoss middleware group,<br>
&gt;&gt;             specifically<br>
&gt;&gt;                     working on<br>
&gt;&gt;                     the Overlord project.  One of my responsibilities<br>
&gt;&gt;             is producing a<br>
&gt;&gt;                     couple<br>
&gt;&gt;                     of UI applications.  To that end, I&#39;ve been<br>
&gt;&gt;             digging Errai and<br>
&gt;&gt;                     hope to<br>
&gt;&gt;                     contribute back based on my project needs.<br>
&gt;&gt;<br>
&gt;&gt;                     Ok, that&#39;s out of the way.  :)  I&#39;ve been<br>
&gt;&gt;             discussing a couple of<br>
&gt;&gt;                     Errai 3<br>
&gt;&gt;                     features with Jonathan (via github pull request<br>
&gt;&gt;             comments :)).<br>
&gt;&gt;                       One of<br>
&gt;&gt;                     these is a new injectable Transition widget in<br>
&gt;&gt;             errai-navigation.<br>
&gt;&gt;                       You<br>
&gt;&gt;                     can see the pull request here:<br>
&gt;&gt;<br>
</div>&gt;&gt;             <a href="https://github.com/errai/____errai/pull/27" target="_blank">https://github.com/errai/____errai/pull/27</a><br>
&gt;&gt;             &lt;<a href="https://github.com/errai/__errai/pull/27" target="_blank">https://github.com/errai/__errai/pull/27</a>&gt;<br>
<div class="im">&gt;&gt;<br>
&gt;&gt;                     &lt;<a href="https://github.com/errai/__errai/pull/27" target="_blank">https://github.com/errai/__errai/pull/27</a><br>
&gt;&gt;             &lt;<a href="https://github.com/errai/errai/pull/27" target="_blank">https://github.com/errai/errai/pull/27</a>&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;                     The goal was to really take out a lot of the<br>
&gt;&gt;             boilerplate for the<br>
&gt;&gt;                     simple<br>
&gt;&gt;                     case of static hyperlinks from one @Page to another.<br>
&gt;&gt;<br>
&gt;&gt;                     I think it works well except for one small issue<br>
&gt;&gt;             (documented in the<br>
&gt;&gt;                     &quot;What&#39;s Missing&quot; section of the pull request).<br>
&gt;&gt;<br>
&gt;&gt;                     Jonathan mentioned that you might have some<br>
&gt;&gt;             thoughts about the<br>
&gt;&gt;                     templating issue, as it relates to attribute priority.<br>
&gt;&gt;<br>
&gt;&gt;                     Any thoughts?  I&#39;d like the href to be preserved<br>
&gt;&gt;             in this case<br>
&gt;&gt;                     because I<br>
&gt;&gt;                     would like the template&#39;s href to point to some<br>
&gt;&gt;             local HTML file<br>
&gt;&gt;                     while<br>
&gt;&gt;                     the live application uses the proper history token<br>
&gt;&gt;             as the href.<br>
&gt;&gt;<br>
&gt;&gt;                     Thanks!<br>
&gt;&gt;<br>
&gt;&gt;                     -Eric<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     --<br>
&gt;&gt;     Lincoln Baxter, III<br>
</div>&gt;&gt;     <a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a> &lt;<a href="http://ocpsoft.org/" target="_blank">http://ocpsoft.org/</a>&gt;<br>
<div class="im">&gt;&gt;     &quot;Simpler is better.&quot;<br>
&gt;&gt;     _______________________________________________<br>
&gt;&gt;     errai-dev mailing list<br>
</div>&gt;&gt;     <a href="mailto:errai-dev@lists.jboss.org">errai-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:errai-dev@lists.jboss.org">errai-dev@lists.jboss.org</a>&gt;<br>
<div class="im">&gt;&gt;     <a href="https://lists.jboss.org/mailman/listinfo/errai-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/errai-dev</a><br>
&gt;<br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     errai-dev mailing list<br>
</div>&gt;     <a href="mailto:errai-dev@lists.jboss.org">errai-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:errai-dev@lists.jboss.org">errai-dev@lists.jboss.org</a>&gt;<br>
<div class="HOEnZb"><div class="h5">&gt;     <a href="https://lists.jboss.org/mailman/listinfo/errai-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/errai-dev</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Lincoln Baxter, III<br>
&gt; <a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
&gt; &quot;Simpler is better.&quot;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; errai-dev mailing list<br>
&gt; <a href="mailto:errai-dev@lists.jboss.org">errai-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/errai-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/errai-dev</a><br>
&gt;<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>
</div></div></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>