dev@woodstock.java.net

Re: autoValidate problem.

From: AntonioV <antonio_at_antonioshome.net>
Date: Thu, 1 Nov 2007 15:22:13 -0700 (PDT)

Hi Dan,

Thanks for the clarifications.

I was wondering if we could use the "dojo.addOnLoad" function to add
subscriptions to topics. I assume we can't, and that we should add
subscriptions in functions invoked after document initialization (i.e. in
the "init()" method you describe).

Am I right regarding this?

If I'm right then I'd like to have a "dojo.addOnLoad2" function, to add
functions invoked from the "onLoad=setTimeout..."

That function would allow us to place topic-subscription functions wherever
we want (in small files containing facelets' ui:compositions of woodstock
components), uncoupling the main page (with the head and body and "onLoad"
and "init()") from the subscription scripts (included in each one of the
other files).

It's somewhat difficult to me to explain the whole details here, I'll try to
blog about it, or something, once we have a solution.

Thanks for the help,
Antonio



Dan Labrecque wrote:
>
> AntonioV wrote:
>> Hi Dan,
>>
>> Thanks for your reply. This is very informative (and should be in the TLD
>> Docs, I assume).
>>
>
> The event topics and how to use them are documented in the TLD. Using
> the window.onLoad event has been added to the release notes.
>
>> This new approach makes it more difficult for us to reuse components
>> (facelets ui:compositions) in our pages, because our components
>> (compositions) do not contain "webuijsf:head" elements.
>>
>> I was thinking that we could publish an event on the "init()" method, and
>> subsbscribe to that same event on each of our compositions, decoupling
>> the
>> compositions from the webuijsf:head/init() method.
>>
>
> Technically, script can appear anywhere in the page. Therefore, you
> don't have to define your function in the head, if that's a problem? The
> important thing is that you don't invoke your function until all the
> elements in the page are available. Regardless of where your script is
> defined, you can still use the window.onLoad event to initialize this
> functionality.
>
> Dan
>> We'll experiment with that and will post here the results.
>>
>> Thanks,
>> Antonio
>>
>>
>>
>> Dan Labrecque wrote:
>>
>>> AntonioV wrote:
>>>
>>>> Hi Dmitry,
>>>>
>>>> Thanks for your reply.
>>>>
>>>> I've tried out with the topic name you've suggested without success.
>>>>
>>>> What I've done is to add an event handler in the "onBlur" attribute,
>>>> and
>>>> that seems to be working correctly.
>>>>
>>>> Thanks again,
>>>> Antonio
>>>>
>>>> P.S.: The topic names in the TLD docs for build #14 are not updated to
>>>> dojo
>>>> 0.9, I think (shall I file an issue for that?)
>>>>
>>>>
>>> FYI, I checked the textField TLD below (build #14) and the event topics
>>> are correct.
>>>
>>> http://webdev2.sun.com/woodstock-tlddocs
>>>
>>> Note that in order to subscribe to a topic, you must now use:
>>>
>>> <webuijsf:head>
>>> <webuijsf:script>
>>> var processEvents = {
>>> update: function(props) {
>>> // Do something...
>>> }
>>> }
>>> function init() {
>>> // Subscribe to event.
>>>
>>> dojo.subscribe(webui.suntheme.widget.textField.event.<eventname>.endTopic,
>>> processEvents, "update");
>>> }
>>> </webuijsf:script>
>>> </webuijsf:head>
>>> <webuijsf:body onLoad="setTimeout('init();', 0)">
>>> ...
>>> |
>>> |Not only did Dojo's function signature change for Dojo .9, but you must
>>> subscribe after the widget has been created. In the example above, I'm
>>> using the window.onLoad event to subscribe. You may not need the
>>> timeout, but it ensure all HTML elements, widgets, etc. have been
>>> created.
>>>
>>> Dan
>>>
>>>
>>>> Dmitry Kushner wrote:
>>>>
>>>>
>>>>> Antonio
>>>>>
>>>>> Sorry - the event names have been changed with the migration to dojo
>>>>> 0.9.
>>>>> The following, for example is set of events our ajax implementation
>>>>> subscribed to ( you can find this in
>>>>> javascript.../widget/jsfx/textField.js)
>>>>> ( @THEME@ gets translated to theme, so it becomes
>>>>> webui.suntheme.widget.textField.event.validation.beginTopic)
>>>>>
>>>>> dojo.subscribe(webui._at_THEME@.widget.textField.event.refresh.beginTopic,
>>>>> webui._at_THEME@.widget.jsfx.common, "processRefreshEvent");
>>>>> dojo.subscribe(webui._at_THEME@.widget.textField.event.state.beginTopic,
>>>>> webui._at_THEME@.widget.jsfx.common, "processStateEvent");
>>>>> dojo.subscribe(webui._at_THEME@.widget.textField.event.submit.beginTopic,
>>>>> webui._at_THEME@.widget.jsfx.common, "processSubmitEvent");
>>>>> dojo.subscribe(webui._at_THEME@.widget.textField.event.validation.beginTopic,
>>>>> webui._at_THEME@.widget.jsfx.textField, "processValidationEvent");
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_woodstock.dev.java.net
>>>>> For additional commands, e-mail: dev-help_at_woodstock.dev.java.net
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
>

-- 
View this message in context: http://www.nabble.com/autoValidate-problem.-tf4692440.html#a13538621
Sent from the Project Woodstock - Dev mailing list archive at Nabble.com.