[OpenLayers-Users] Can't update a feature for which there is no
FID (WFS-T)
Eric Lemoine
eric.lemoine at camptocamp.com
Wed Feb 10 12:15:28 EST 2010
On Wednesday, February 10, 2010, paweluz <paweluz at o2.pl> wrote:
>
> Hi!
>
> I have problem with WFS-T ADD state. I my application the user is able to
> add, update and delete a feature from map. The problem appears if:
> 1. User draw new geometry on map, fill out the attributes of new object and
> click SAVE to database.
> 2. Then user click on the new object on map. The attributes of the object
> appear.
> 3. User is trying to modify or delete the object... Then I got an alert
> Can't update a feature for which there is no FID
> I check it in firebug, and the FID is null. Why is that... The real funny
> think is that when I change the zoom of the map, or click F5, or in layer
> switch a uncheck and check my wfs_layer, the FID of my new object is changed
> to correct!! Now the user is able to remove or change the geometry (object)
> on map. Did anyone have this problem?
> Here is code for adding new object into the database
>
> feature.layer.eraseFeatures([feature]);
> feature.geometry = new OpenLayers.Geometry.MultiLineString(
> feature.geometry
> );
> selectedfeature=feature;
> feature.state = OpenLayers.State.INSERT;
> feature.layer.drawFeature(feature);
> my_wfslayer.commit();
>
>
> If I add the line my_wfslayer.refresh(); at the end I got response
> (SUCCEED), my layer is refreshed but I can't see my new object (new geometry
> does not appear on map). I have to click F5 or zomm in/out or make change in
> layer switch(off/on)... What is wrong?
Are you using Layer.WFS or Layer.Vector? Using the latter is
recommended. In your case you'd use it with a Strategy.Save and a
Protocol.WFS configured into it. The Strategy.Save should take care of
updating the features' fid once the create operation is complete.
Check out the WFS examples for more practical information.
Cheers,
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
More information about the Users
mailing list