[OpenLayers-Users] wfs-t insert alphanumeric values

Fabio D'Ovidio fabiodovidio at gmail.com
Mon Jun 30 11:43:44 EDT 2008


Thanks it works !!

Andreas Hocevar ha scritto:
> Hi Fabio,
>
> On Mon, Jun 30, 2008 at 4:41 PM, Fabio D'Ovidio <fabiodovidio at gmail.com> wrote:
>   
>> Hi!
>> After drwing my feature trought openlayers and wfs-t protocol in
>> Geoserver, I'd like to update alphanumeric fileds of that feature
>> reading some variables in query string.
>>     
>
> Wouldn't it save you a roundtrip if you set the attribute values right
> after drawing the feature, before posting it to the server? All you
> have to do is give your feature the according attributes, e.g.:
>
> features.attributes = {
>     "importo": "my query_string variable value",
>     "nome": "my query_string variable value"
> }
>
>   
>> // Javascript function
>>  function getQueryVariable(variable) {
>>        var query = window.location.search.substring(1);
>>        var vars = query.split("&");
>>         for (var i=0;i<vars.length;i++) {
>>         var pair = vars[i].split("=");
>>         if (pair[0] == variable) {
>>         return pair[1];
>>     }
>>   }
>>  alert('Query Variable ' + variable + ' not found');
>>   }
>>     
>
> This is much simpler with OpenLayers.Util.getParameters:
>
> If the query string of your url looks like
> ?importo=1&nome=my query string nome
>
> you can simply say
>
> feature.attributes = OpenLayers.Util.getParameters();
>
>   
>> // wfs-t update request: "importo" and "nome" will be my query_string
>> variables....
>>
>> <wfs:Transaction service="WFS" version="1.0.0"
>>  xmlns:topp="http://www.openplans.org/topp"
>>  xmlns:ogc="http://www.opengis.net/ogc"
>>  xmlns:wfs="http://www.opengis.net/wfs">
>>  <wfs:Update typeName="topp:poligono">
>>    <wfs:Property>
>>      <wfs:Name>nome</wfs:Name>
>>      <wfs:Value>"my query_string variable value"</wfs:Value>
>>
>>    </wfs:Property>
>>    <wfs:Property>
>>      <wfs:Name>importo</wfs:Name>
>>      <wfs:Value>"my query_string variable value"</wfs:Value>
>>
>>    </wfs:Property>
>>    <ogc:Filter>
>>      <ogc:FeatureId fid="poligono.1"/>
>>    </ogc:Filter>
>>  </wfs:Update>
>> </wfs:Transaction>
>>
>> How can I do it?
>>     
>
> No need to code it like that. It's very simple, assuming you have your
> wfs layer set up like in
> http://www.openlayers.org/dev/examples/wfst.html:
>
> feature.state = OpenLayers.State.UPDATE;
> wfs.commit();
>
> Regards,
> Andreas.
>
>   

-- 
Ing. Fabio D'Ovidio

INOVA Open Solutions s.r.l.
Web : http://www.inovaos.it
Tel.: 081 197 57 600
mail: fabiodovidio at gmail.com




More information about the Users mailing list