In order to get WFS Delete to work I changed OpenLayers/Format/WFS.js.
For some reasen in the remove section other properties are used as with Update and Insert:
feature.attribures.fid <-> feature.fid
this.featureNS <-> this.wfsns
I changed these things and after that a feature was really deleted from the database!
Probably the same result is achieved if you set these properties in your own script, but for me the test was whether it could work and than what would happen.
Actually I was looking for a way to delete only the geometry or empty the geometry but can't get that to work yet, because in my situation other attributes than geometry have to be kept in the database.

Below the original line after // and below that my correction in OpenLayers/Format/WFS.js:
    remove: function(feature) {
        //if (!feature.attributes.fid) {
        if (!feature.fid) {
            alert("Can't update a feature for which there is no FID.");
            return false;
        }
        //var deleteNode = document.createElementNS(this.featureNS, 'wfs:Delete');
        var deleteNode = document.createElementNS(this.wfsns, 'wfs:Delete');
        deleteNode.setAttribute("typeName", this.layerName);

        var filterNode = document.createElementNS('http://www.opengis.net/ogc', 'ogc:Filter');
        var filterIdNode = document.createElementNS('http://www.opengis.net/ogc', 'ogc:FeatureId');
        //filterIdNode.setAttribute("fid", feature.attributes.fid);
        filterIdNode.setAttribute("fid", feature.fid);
        filterNode.appendChild(filterIdNode);
        deleteNode.appendChild(filterNode);

        return deleteNode;
    },

Rinke Heida

Arnaud Cogoluegnes wrote:
I finally found a hack (well, I think it is) by reading the
OpenLayers.Format.WFS.js code. Seems the typeName attribute of the update
request is mapped with the OpenLayers.Format.WFS layerName property.

The WFS layer writer (a OpenLayers.Format.WFS object) is created on demand
when the commit method is called:

/* from OpenLayers.Layer.WFS */
if (!this.writer) {
  this.writer = new OpenLayers.Format.WFS({},this);
}

The option table is empty, so the layerName property is not initialized. So
after the WFS layer creation, I added:

if (!water.writer) {
  water.writer = new
OpenLayers.Format.WFS({layerName:'G4WD:tasmania_water'},water);
}

I don’t know if it's the correct way, but it worked (I would be happy to
know the correct way if it exists :-)  )

If I find anything about the DELETE request (the FID was missing), I'll let
you know

Cheers

Arnaud

-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] De
la part de Pierre GIRAUD
Envoyé : mercredi 16 janvier 2008 11:49
À : Yingqi
Cc : [email protected]
Objet : Re: [OpenLayers-Users] WFS-T delete/update

Hi Arnaud,

I didn't use the WFS-T functionnalities for a long time now. I hope I
can throw an eye on it, but I don't think I will have time soon.
However, don't hesitate to send snippets of code so that I can
reproduce your test case.

Regards,
Pierre

On Jan 16, 2008 9:06 AM, Yingqi <[EMAIL PROTECTED]> wrote:
  
I think you should probably dig into OpenLayers\Format\GML.js to see if
    
fid
  
is correctly retrieved when GML response from Geoserver was parsed when
    
you
  
turned the layer. I guess fid attribute in your features are empty.



Arno wrote:
    
Hi all,

I've been trying the WFS-T support for inserting polygons and it works
greats (polygons added in the PostGIS database, using GeoServer 1.6). I
tried also modifying features with the ModifyFeature Controls (based on
the
online example). Using the modifyOptions, I changed the state of the
feature:

feature.state = OpenLayers.State.UPDATE;

and then tried to commit the WFS layer. But I received an error from the
GeoServer (log traces something like "features is not available") and
      
the
  
transaction failed. Before asking something on the GeoServer list, is
there
anything I missed when trying to modify the feature with OpenLayers?

For deleting, I used the SelectFeature control, overrode the onSelect
method
to mark the feature as deleted:

feature.state = OpenLayers.State.DELETE;

and when committing the WFS layer, OpenLayers displayed a message saying
that the fid was missing. Same as the update question, is there anything
      
I
  
missed when trying to mark the feature?

Thanks!

Arnaud

_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users


      
--
View this message in context:
    
http://www.nabble.com/WFS-T-delete-update-tp14843989p14873181.html
  
Sent from the OpenLayers Users mailing list archive at Nabble.com.


_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

    
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users



_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users


  
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to