You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Lentz <pa...@gmail.com> on 2009/02/13 12:32:32 UTC

T4.1.6 - UpdateComponents doesn't rebuild body element

Hello there,
I'm making a migration from 4.0.2 to 4.1.6. Everything works great except
rendering one of my components by updateComponent function. This component
is an extended version of contrib:Table. It additionally consist of 3
IScript components. For a first time a page is rendered except that
component (and nothing is there, just empty area, and this is ok, this was
planned). Then, after submitting, during refreshing this area my component
should appear. I'm trying to render it this way:
cycle.getResponseBuilder().updateComponent("dynamicArea");

..the component was rendered, but the scripts weren't. There are 3 actions
added to my component:

onfocus=function1();
onblur=function2();
onclick=function3();
..and when I try to fire them, an error appears:
no function1 found , no function2 found, etc…
..but if I refresh the page with F5 (normal response, not ajax), everything
is ok (the javascript functions are rendered in body element). Does anyone
know how to resolve this problem?
Thanks in advance
Patryk ‘Lentz’ Ziemnicki

-- 
View this message in context: http://n2.nabble.com/T4.1.6---UpdateComponents-doesn%27t-rebuild-body-element-tp2320775p2320775.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

Re: T4.1.6 - UpdateComponents doesn't rebuild body element

Posted by Andreas Andreou <an...@di.uoa.gr>.
If you do inject the script, then just
getScript().execute(this, cycle, cycle.getResponseBuilder(), params);

Otherwise, if you use the Script component, you can surround it with an @If
and control when it's rendered

On Tue, Feb 17, 2009 at 6:48 PM, Lentz <pa...@gmail.com> wrote:
>
> Hello again,
>
> the scripts are not included in the ajax response,
>
> I wrote a component to show the problem in the simpliest form:
>
> ComponentWithIScript.html
>
> <html>
> <body jwcid="$content$">
>
>        Component with IScript
>
>
> </body>
> </html>
>
> ComponentWithIScript.jwc
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE component-specification PUBLIC
>  "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
>  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
>
> <component-specification allow-body="no" allow-informal-parameters="no">
>
>        <component id="onFocusScript" type="Script">
>                <binding name="script" value="literal:OnFocusScript.script"/>
>        </component>
>
> </component-specification>
>
> OnFocusScript.script
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE script PUBLIC
> "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
> "http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd">
>
> <script>
>        <body>
>                <unique>
>                        <![CDATA[
>                                function onFocusShowMessage() {
>                                        alert('hello');
>                                }
>                        ]]>
>                </unique>
>        </body>
> </script>
>
> I tried to find some examples how (or rather in what cases) to use such
> things like:
> cycle.getResponseBuilder().addBodyScript(script); ... etc...but haven't
> found anything interresting..
> or maybe should I include script other way, like <inject property="script"
> type="script" object="OnFocusScript.script"/> and then render it in
> renderComponent method? but my component is more like composite component,
> that consist of standard / my components (each of it has its own
> updateComponent method) I'm not sure if I can add
> MyCompositeComponent.updateComponent extra method..
>
> any ideas how to include he scripts to ajax response?
>
>
> Andreas Andreou-2 wrote:
>>
>> First see if the scripts are included in the ajax response
>> using something like Firebug... they should be
>>
>> Then you just need to see how you define the functions
>> function1, function2, function3
>>
>> There are a few normal ways such as
>> 1) function function1() {...}
>> 2) function1=function() {...)
>> but the scripts (that include those definitions) are not
>> evaluated in the normal window/document scope when in ajax.
>>
>> Anyway, just use
>> window.function1=function() {...)
>>
>>
>> On Fri, Feb 13, 2009 at 1:32 PM, Lentz <pa...@gmail.com> wrote:
>>>
>>> Hello there,
>>> I'm making a migration from 4.0.2 to 4.1.6. Everything works great except
>>> rendering one of my components by updateComponent function. This
>>> component
>>> is an extended version of contrib:Table. It additionally consist of 3
>>> IScript components. For a first time a page is rendered except that
>>> component (and nothing is there, just empty area, and this is ok, this
>>> was
>>> planned). Then, after submitting, during refreshing this area my
>>> component
>>> should appear. I'm trying to render it this way:
>>> cycle.getResponseBuilder().updateComponent("dynamicArea");
>>>
>>> ..the component was rendered, but the scripts weren't. There are 3
>>> actions
>>> added to my component:
>>>
>>> onfocus=function1();
>>> onblur=function2();
>>> onclick=function3();
>>> ..and when I try to fire them, an error appears:
>>> no function1 found , no function2 found, etc…
>>> ..but if I refresh the page with F5 (normal response, not ajax),
>>> everything
>>> is ok (the javascript functions are rendered in body element). Does
>>> anyone
>>> know how to resolve this problem?
>>> Thanks in advance
>>> Patryk 'Lentz' Ziemnicki
>>>
>>> --
>>> View this message in context:
>>> http://n2.nabble.com/T4.1.6---UpdateComponents-doesn%27t-rebuild-body-element-tp2320775p2320775.html
>>> Sent from the Tapestry Users mailing list archive at Nabble.com.
>>>
>>
>>
>>
>> --
>> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
>> Tapestry / Tacos developer
>> Open Source / JEE Consulting
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
> --
> View this message in context: http://n2.nabble.com/T4.1.6---UpdateComponents-doesn%27t-rebuild-body-element-tp2320775p2341882.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4.1.6 - UpdateComponents doesn't rebuild body element

Posted by Lentz <pa...@gmail.com>.
Hello again,

the scripts are not included in the ajax response,

I wrote a component to show the problem in the simpliest form:

ComponentWithIScript.html

<html>
<body jwcid="$content$">

	Component with IScript
	

</body>
</html>

ComponentWithIScript.jwc

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification PUBLIC 
  "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">

<component-specification allow-body="no" allow-informal-parameters="no">

	<component id="onFocusScript" type="Script">
		<binding name="script" value="literal:OnFocusScript.script"/>
	</component>
	
</component-specification>

OnFocusScript.script

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script PUBLIC
"-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd">

<script>
	<body>
		<unique>
			<![CDATA[
				function onFocusShowMessage() {
					alert('hello');
				}
			]]>
		</unique>
	</body>
</script>

I tried to find some examples how (or rather in what cases) to use such
things like:
cycle.getResponseBuilder().addBodyScript(script); ... etc...but haven't
found anything interresting..
or maybe should I include script other way, like <inject property="script"
type="script" object="OnFocusScript.script"/> and then render it in
renderComponent method? but my component is more like composite component,
that consist of standard / my components (each of it has its own
updateComponent method) I'm not sure if I can add
MyCompositeComponent.updateComponent extra method..

any ideas how to include he scripts to ajax response?


Andreas Andreou-2 wrote:
> 
> First see if the scripts are included in the ajax response
> using something like Firebug... they should be
> 
> Then you just need to see how you define the functions
> function1, function2, function3
> 
> There are a few normal ways such as
> 1) function function1() {...}
> 2) function1=function() {...)
> but the scripts (that include those definitions) are not
> evaluated in the normal window/document scope when in ajax.
> 
> Anyway, just use
> window.function1=function() {...)
> 
> 
> On Fri, Feb 13, 2009 at 1:32 PM, Lentz <pa...@gmail.com> wrote:
>>
>> Hello there,
>> I'm making a migration from 4.0.2 to 4.1.6. Everything works great except
>> rendering one of my components by updateComponent function. This
>> component
>> is an extended version of contrib:Table. It additionally consist of 3
>> IScript components. For a first time a page is rendered except that
>> component (and nothing is there, just empty area, and this is ok, this
>> was
>> planned). Then, after submitting, during refreshing this area my
>> component
>> should appear. I'm trying to render it this way:
>> cycle.getResponseBuilder().updateComponent("dynamicArea");
>>
>> ..the component was rendered, but the scripts weren't. There are 3
>> actions
>> added to my component:
>>
>> onfocus=function1();
>> onblur=function2();
>> onclick=function3();
>> ..and when I try to fire them, an error appears:
>> no function1 found , no function2 found, etc…
>> ..but if I refresh the page with F5 (normal response, not ajax),
>> everything
>> is ok (the javascript functions are rendered in body element). Does
>> anyone
>> know how to resolve this problem?
>> Thanks in advance
>> Patryk 'Lentz' Ziemnicki
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/T4.1.6---UpdateComponents-doesn%27t-rebuild-body-element-tp2320775p2320775.html
>> Sent from the Tapestry Users mailing list archive at Nabble.com.
>>
> 
> 
> 
> -- 
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/T4.1.6---UpdateComponents-doesn%27t-rebuild-body-element-tp2320775p2341882.html
Sent from the Tapestry Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4.1.6 - UpdateComponents doesn't rebuild body element

Posted by Andreas Andreou <an...@di.uoa.gr>.
First see if the scripts are included in the ajax response
using something like Firebug... they should be

Then you just need to see how you define the functions
function1, function2, function3

There are a few normal ways such as
1) function function1() {...}
2) function1=function() {...)
but the scripts (that include those definitions) are not
evaluated in the normal window/document scope when in ajax.

Anyway, just use
window.function1=function() {...)


On Fri, Feb 13, 2009 at 1:32 PM, Lentz <pa...@gmail.com> wrote:
>
> Hello there,
> I'm making a migration from 4.0.2 to 4.1.6. Everything works great except
> rendering one of my components by updateComponent function. This component
> is an extended version of contrib:Table. It additionally consist of 3
> IScript components. For a first time a page is rendered except that
> component (and nothing is there, just empty area, and this is ok, this was
> planned). Then, after submitting, during refreshing this area my component
> should appear. I'm trying to render it this way:
> cycle.getResponseBuilder().updateComponent("dynamicArea");
>
> ..the component was rendered, but the scripts weren't. There are 3 actions
> added to my component:
>
> onfocus=function1();
> onblur=function2();
> onclick=function3();
> ..and when I try to fire them, an error appears:
> no function1 found , no function2 found, etc…
> ..but if I refresh the page with F5 (normal response, not ajax), everything
> is ok (the javascript functions are rendered in body element). Does anyone
> know how to resolve this problem?
> Thanks in advance
> Patryk 'Lentz' Ziemnicki
>
> --
> View this message in context: http://n2.nabble.com/T4.1.6---UpdateComponents-doesn%27t-rebuild-body-element-tp2320775p2320775.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org