You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by =?...@tiger.tigra.hu, _S=E1ndor=22?= <ty...@tigra.hu> on 2004/03/23 11:19:33 UTC

Subclassing Body

Greetings!

Question:
Can you tell me how to create my own Body component?
Recently I have
	public abstract class MyBody extends Body
and I include some extra methods in it.
The testpage refers it as
	<component id="budi" type="my:MyBody"/>

Unfortunately this way it is not recognized as body component. The class 
of body is still org.apache.tapestry.html.Body$Enhance_51.
I think the problem is that it should register itself somehow....

And if someone interested in...
Problem rooted from:
I would like to make some simple event handling in my pages in jScript. 
While the page is rendered, components that want to listen to events, 
register a jScript function with an event name. At the end a function 
generated in the page that resolves the event. The eventsources call this 
resolver function with the event name and the corresponding object in the 
page.
Example:
<script>
...
	function fireEvent( event, source ) {
		if ( event == "COUNTER_CHANGED" ) {
			recalculate( source );
			copy( source );
		}
		...
	}

	function recalculate( source ) {
		...
		sum += source.value;
		...
	}

	function copy( source ) {
		other.value = source.value;
	}
...
</script>

I believe this kind of scripting is best placed in Body component, as body 
handles scripts and anyting in the body can define listener. So MyBody 
have addListener function that collects listeners and after rendering its 
body it can use addBodyScript to render the event resolver function.

Thanks for all comments!

-- 
Irlanda, Sándor

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