You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "dick.murray@unit4.com" <di...@unit4.com> on 2012/06/11 15:08:37 UTC

Struggling to get mixin to work.

Hi all. (Tapestry newbie).

I'm struggling to understand how to get a MixIn to be called.

I have the following template.

<html t:type="layout" title="Ordnance Survey"
  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<p>
	Data
  	<t:beandisplay object="this" include="postcode, georss"/>
 </p>
 
 <p>
 	Metadata
  	<t:beandisplay object="this" include="uri, tripleSize"/>
 </p>
 
 <p>
	<t:if test="getModel().getFound()">
		<p>
			<t:actionlink t:id="AsTriples" context="${getPostcode()}">As
Triples</t:actionlink>
		</p>
	</t:if>
</p>

<div id="map" style="width: 600px; height: 400px; border: 1px solid
black;"></div>
	
</html>

I have the following mixin os.js

var OS = Class.create();
OS.prototype = {
	var osMap;
	
        initialize: function(element) {
                Event.observe($(element), 'click',
this.doOS.bindAsEventListener());
        },
        
        doOS: function() {
			 osMap = new OpenSpace.Map('map');
			 osMap.setCenter(new OpenSpace.MapPoint(438760, 114760), 10);
			 var markers = new OpenLayers.Layer.Markers("Markers");
			 osMap.addLayer(markers);
			 var pos, marker;
			 pos = new OpenSpace.MapPoint(438760, 114760);
			 marker = new OpenLayers.Marker(pos);
			 markers.addMarker(marker);
        }
}

Where do I put the "call" to the os.js to populate the <div></div> please..?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Struggling-to-get-mixin-to-work-tp5713764.html
Sent from the Tapestry - User 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: Struggling to get mixin to work.

Posted by WINDEY Pieter AWL-IT <pi...@atos.net>.
You can find more info on how to create a mixin on http://jumpstart.doublenegative.com.au/jumpstart/ or http://tapestry.apache.org/component-mixins.html

But (unless I'm wrong) you always have to write a mixin-class, where you have to do some coding, import your .js file. And then add the mixin to a component via the mixins parameter of that component!



-----Original Message-----
From: dick.murray@unit4.com [mailto:dick.murray@unit4.com]
Sent: Monday 11 June 2012 15:09
To: users@tapestry.apache.org
Subject: Struggling to get mixin to work.

Hi all. (Tapestry newbie).

I'm struggling to understand how to get a MixIn to be called.

I have the following template.

<html t:type="layout" title="Ordnance Survey"
  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<p>
        Data
        <t:beandisplay object="this" include="postcode, georss"/>
 </p>

 <p>
        Metadata
        <t:beandisplay object="this" include="uri, tripleSize"/>
 </p>

 <p>
        <t:if test="getModel().getFound()">
                <p>
                        <t:actionlink t:id="AsTriples" context="${getPostcode()}">As
Triples</t:actionlink>
                </p>
        </t:if>
</p>

<div id="map" style="width: 600px; height: 400px; border: 1px solid
black;"></div>

</html>

I have the following mixin os.js

var OS = Class.create();
OS.prototype = {
        var osMap;

        initialize: function(element) {
                Event.observe($(element), 'click',
this.doOS.bindAsEventListener());
        },

        doOS: function() {
                         osMap = new OpenSpace.Map('map');
                         osMap.setCenter(new OpenSpace.MapPoint(438760, 114760), 10);
                         var markers = new OpenLayers.Layer.Markers("Markers");
                         osMap.addLayer(markers);
                         var pos, marker;
                         pos = new OpenSpace.MapPoint(438760, 114760);
                         marker = new OpenLayers.Marker(pos);
                         markers.addMarker(marker);
        }
}

Where do I put the "call" to the os.js to populate the <div></div> please..?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Struggling-to-get-mixin-to-work-tp5713764.html
Sent from the Tapestry - User 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




Atos Worldline SA/NV - Chaussee de Haecht 1442 Haachtsesteenweg
- 1130 Brussels - Belgium
RPM-RPR Bruxelles-Brussel - TVA-BTW BE 0418.547.872
Bankrekening-Compte Bancaire-Bank Account 310-0269424-44
BIC BBRUBEBB - IBAN BE55 3100 2694 2444

"The information contained in this e-mail and any attachment thereto is confidential and may contain information which is protected by intellectual property rights.
This information is intended for the exclusive use of the recipient(s) named above.
This e-mail does not constitute any binding relationship or offer toward any of the addressees.
If you are not one of the addressees , one of their employees or a proxy holder entitled to hand over this message to the addressee(s), any use of the information contained herein (e.g. reproduction, divulgation, communication or distribution,...) is prohibited.
If you have received this message in error, please notify the sender and destroy it immediately after.
The integrity and security of this message cannot be guaranteed and it may be subject to data corruption, interception and unauthorized amendment, for which we accept no liability."


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


Re: Struggling to get mixin to work.

Posted by Christian Riedel <cr...@googlemail.com>.
Hi,

you need to attach a mixin to the component that you'd like to manipulate. 
Read this: http://tapestry.apache.org/component-mixins.html

And have a look at other mixin implementations, like the Autocomplete-Mixin:

Autcomplete.java
https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/Autocomplete.java;h=737457986be53f86393b5f21e03b4b5dd8434420;hb=5.3

autocomplete.js
https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=blob;f=tapestry-core/src/main/resources/org/apache/tapestry5/corelib/mixins/autocomplete.js;h=ba8dd503a9bd90ba2e7e749802194fea20b94689;hb=5.3


Best,
Christian


Am 11.06.2012 um 15:08 schrieb dick.murray@unit4.com:

> Hi all. (Tapestry newbie).
> 
> I'm struggling to understand how to get a MixIn to be called.
> 
> I have the following template.
> 
> <html t:type="layout" title="Ordnance Survey"
>  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
> <p>
> 	Data
>  	<t:beandisplay object="this" include="postcode, georss"/>
> </p>
> 
> <p>
> 	Metadata
>  	<t:beandisplay object="this" include="uri, tripleSize"/>
> </p>
> 
> <p>
> 	<t:if test="getModel().getFound()">
> 		<p>
> 			<t:actionlink t:id="AsTriples" context="${getPostcode()}">As
> Triples</t:actionlink>
> 		</p>
> 	</t:if>
> </p>
> 
> <div id="map" style="width: 600px; height: 400px; border: 1px solid
> black;"></div>
> 	
> </html>
> 
> I have the following mixin os.js
> 
> var OS = Class.create();
> OS.prototype = {
> 	var osMap;
> 	
>        initialize: function(element) {
>                Event.observe($(element), 'click',
> this.doOS.bindAsEventListener());
>        },
> 
>        doOS: function() {
> 			 osMap = new OpenSpace.Map('map');
> 			 osMap.setCenter(new OpenSpace.MapPoint(438760, 114760), 10);
> 			 var markers = new OpenLayers.Layer.Markers("Markers");
> 			 osMap.addLayer(markers);
> 			 var pos, marker;
> 			 pos = new OpenSpace.MapPoint(438760, 114760);
> 			 marker = new OpenLayers.Marker(pos);
> 			 markers.addMarker(marker);
>        }
> }
> 
> Where do I put the "call" to the os.js to populate the <div></div> please..?
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Struggling-to-get-mixin-to-work-tp5713764.html
> Sent from the Tapestry - User 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
> 


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