Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
linenumberstrue
...
	<client:initial id="default" minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>

	<client:full id="default" minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>

	<client:limit id="default" minx="320000" miny="5810000" maxx="360000" maxy="5840000"/>

	<client:extents id="defaults">
		<initial ref="default"/>
		<full ref="default"/>
		<limit ref="default"/>
	</client:extents>
...

And if we wanted to we could create a separate snippet for a "custom" extent

Code Block
xml
xml
linenumberstrue
...
	<client:initial id="custom" minx="328000" miny="5811000" maxx="331000" maxy="5817000"/>
...

Then in our "custom" client configuration we could use the following to accomplish the same as we did previously

Code Block
xml
xml
linenumberstrue
...
	<client:config id="custom">
		<view id="com.cohga.html.client.map.mapView">
			<extents ref="defaults">
				<initial ref="custom"/>
			</extents>
		</view>
	</client:config>
...

Replacing content with an id attributes

...

Code Block
xml
xml
titleExample with two client configurations
linenumberstrue

<?xml version="1.0" encoding="UTF-8"?>

<config xmlns="urn:com.cohga.server.config#1.0" xmlns:client="urn:com.cohga.html.client#1.0">

	<client:config id="test1">
		<view id="com.cohga.html.client.map.mapView">
			<extents>
				<initial minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
				<full minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
			</extents>
		</view>
	</client:config>

	<client:config id="test2">
		<view id="com.cohga.html.client.map.mapView">
			<extents>
				<initial minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
				<full minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
			</extents>
		</view>
	</client:config>

</config>

we might come up with the following, which would not work.

Code Block
xml
xml
titleExtracting map view into a snippet the wrong way
linenumberstrue

<?xml version="1.0" encoding="UTF-8"?>

<config xmlns="urn:com.cohga.server.config#1.0" xmlns:client="urn:com.cohga.html.client#1.0">

	<client:view id="com.cohga.html.client.map.mapView">
		<extents>
			<initial minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
			<full minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
		</extents>
	</client:view>

	<client:config id="test1">
		<view ref="com.cohga.html.client.map.mapView"/>
	</client:config>

	<client:config id="test2">
		<view ref="com.cohga.html.client.map.mapView"/>
	</client:config>

</config>


Info

The reason the above code does not work is that the code that processes the snippets does not know that the id for the view tag is important, and just treats it an an identifier used to provide the link between the snippet and the reference to include it.
But as part of the including process it's the content of the snippet, which does not include the id, that replaces the reference, thereby loosing the id as part of the include process.

...

Code Block
xml
xml
titleExample with two client configurations
linenumberstrue

<?xml version="1.0" encoding="UTF-8"?>

<config xmlns="urn:com.cohga.server.config#1.0" xmlns:client="urn:com.cohga.html.client#1.0">

	<client:config id="test1">
		<view>
			<extents>
				<initial minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
				<full minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
			</extents>
		</view>
	</client:config>

	<client:config id="test2">
		<view>
			<extents>
				<initial minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
				<full minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
			</extents>
		</view>
	</client:config>

</config>

The way to fix this problem is to include the id in the reference, as follows:

Code Block
xml
xml
titleExample with two client configurations
linenumberstrue

<?xml version="1.0" encoding="UTF-8"?>

<config xmlns="urn:com.cohga.server.config#1.0" xmlns:client="urn:com.cohga.html.client#1.0">

	<client:view id="map">
		<extents>
			<initial minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
			<full minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
		</extents>
	</client:view>

	<client:config id="test1">
		<view ref="map" id="com.cohga.html.client.map.mapView"/>
	</client:config>

	<client:config id="test2">
		<view ref="map" id="com.cohga.html.client.map.mapView"/>
	</client:config>

</config>

Possible alternative format

...

Code Block
xml
xml
titlePossible future syntax for snippets
linenumberstrue

<?xml version="1.0" encoding="UTF-8"?>

<config xmlns="urn:com.cohga.server.config#1.0" xmlns:client="urn:com.cohga.html.client#1.0">

	<client:snippet id="map">
		<view id="com.cohga.html.client.map.mapView">
			<extents>
				<initial minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
				<full minx="327098" miny="5811358" maxx="351971" maxy="5827675"/>
			</extents>
		</view>
	</client:snippet>

	<client:config id="test1">
		<view ref="map"/>
	</client:config>

	<client:config id="test2">
		<view ref="map"/>
	</client:config>

</config>

This has the added bonus that the snippet can contain more than one item, although if that's actually useful is as yet unclear.