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