code: private JsHandlerRegistration addFeatureSelectionHandler2(final FeatureSelectedHandler selectedHandler,
  			final FeatureDeselectedHandler deselectedHandler) {
  
  		final List<VectorLayer> layers = ((MapImpl) map).getMapWidget().getMapModel().getVectorLayers();
  		final HandlerRegistration[] registrations = new HandlerRegistration[layers.size()];
  
  		for (int i = 0; i < layers.size(); i++) {
  			final FeaturesSupported fs = (FeaturesSupported) map.getLayersModel().getLayer(layers.get(i).getId());
  
  			registrations[i] = layers.get(i).addFeatureSelectionHandler(new FeatureSelectionHandler() {
  
  				public void onFeatureSelected(FeatureSelectedEvent event) {
  					Feature feature = new FeatureImpl(event.getFeature().toDto(), fs);
  					selectedHandler.onFeatureSelected(new org.geomajas.plugin.jsapi.client.event.FeatureSelectedEvent(
  							feature));
  				}
  
  				public void onFeatureDeselected(FeatureDeselectedEvent event) {
  					Feature feature = new FeatureImpl(event.getFeature().toDto(), fs);
  					deselectedHandler
  							.onFeatureDeselected(new org.geomajas.plugin.jsapi.client.event.FeatureDeselectedEvent(
  									feature));
  				}
  			});
  		}
  
  		return new JsHandlerRegistration(registrations);
  	}
docs: ------------------------------------------------------------------------