konto usunięte
Temat: Formularz ExtJs (kilka pól), problem z WFS
Witam,zbudowałem wyszukiwarkę atrybutów (formularz), który wysyła zapytania do serwera WFS.
Gdy jest tylko jedno pole, to formularz wysyła poprawnie zapytanie o dany atrybut lub gdy dodam kolejne pole i wypełnię obydwa to serwer WFS zwraca poprawnie wyniki.
Problem pojawia się w momencie gdy stworzę formularz, który ma 11 pól tekstowych. Gdy wypełnię wszystkie pola, serwer również zwraca wyniki zapytania. Natomiast gdy wypełnię tylko kilka pól, a resztę pozostawię pustą to po naciśnięciu przycisku wyszukaj, wysyłane są również te puste pola:
Poniżej jest fragment zapytania WFS i widać, że puste pola są wysyłane jako puste wartości do serwera WFS.
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:Query typeName="feature:transakcje_punkty" srsName="EPSG:900913" xmlns:feature="http://geoserver.org/transakcje">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:And>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>trans_id</ogc:PropertyName>
<ogc:Literal>22</ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>dokument</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>data_transakcji</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>typ_nier</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>cena_tran</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>cena_1m2_dlk</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>pow_m2</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>sprzedawca</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>nabywca</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>wspx</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo matchCase="true">
<ogc:PropertyName>wspy</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:And>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
Serwer zwraca odpowiedź:
<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/ows http://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows">
<ows:Exception exceptionCode="NoApplicableCode">
<ows:ExceptionText>java.lang.RuntimeException: java.io.IOException
java.io.IOException
null
BŁĄD: nieprawidłowa składnia wejścia dla typu numerycznego: ""
Pozycja: 161</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>
Chciałbym, żeby użytkownik mógł wpisać te atrybuty do wyszukiwania które go interesują. Natomiast gdy nie uzupełni on żadnego pola to, żeby pojawiała się informacja w stylu "Proszę uzupełnić co najmniej jedno pole"
Poniżej zamieszczam kod ExtJS formularza:
formPanel = new GeoExt.form.FormPanel({
ref: "formPanel",
title:"Wyszukiwarka",
collapsible: true,
width: 150,
region: "west",
protocol: protocol,
buttons:[
{text: 'Czyść',
width: 60,
handler: function(){
formPanel.getForm().reset();
}},
{
text: "Szukaj",
width: 70,
handler: function() {
formPanel.getForm().search();
},
//scope: formPanel
}],
items: [{
xtype: "textfield",
name: "trans_id__eq",
cls : 'myCls',
emptyText:"ID Transakcji",
value: "",
//fieldLabel: "ID",
//disabled: true,
},
{
xtype: "textfield",
name: "dokument__eq",
// emptyText:"Dokument",
cls : 'myCls',
value: "",
//disabled: true,
// fieldLabel: "nabywca",
//allowBlank: false
},
{
xtype: "textfield",
name: "data_transakcji__eq",
cls : 'myCls',
//emptyText:"Data Transakcji",
value: "",
//fieldLabel: "ID",
//disabled: true,
},
{
xtype: "textfield",
name: "typ_nier__eq",
cls : 'myCls',
// emptyText:"Typ nieruchomości",
value: "",
//fieldLabel: "ID",
//disabled: true,
},
{
xtype: "textfield",
name: "cena_tran__eq",
cls : 'myCls',
// emptyText:"Cena transakcji",
value: "",
//fieldLabel: "ID",
//disabled: true,
},
{
xtype: "textfield",
name: "cena_1m2_dlk__eq",
cls : 'myCls',
//emptyText:"Cena 1m2",
value: "",
//fieldLabel: "ID",
//disabled: true,
},
{
xtype: "textfield",
name: "pow_m2__eq",
cls : 'myCls',
//emptyText:"Powierzchnia",
value: "",
//fieldLabel: "ID",
//disabled: true,
},
{
xtype: "textfield",
name: "sprzedawca__eq",
cls : 'myCls',
// emptyText:"Sprzedawca",
value: "",
//fieldLabel: "ID",
//disabled: true,
},
{
xtype: "textfield",
name: "nabywca__eq",
cls : 'myCls',
// emptyText:"Nabywca",
value: "",
//fieldLabel: "ID",
//disabled: true,
},
{
xtype: "textfield",
name: "wspx__eq",
cls : 'myCls',
// emptyText:"WspX",
value: "",
//fieldLabel: "ID",
//disabled: true,
},
{
xtype: "textfield",
name: "wspy__eq",
cls : 'myCls',
// emptyText:"WspY",
value: "",
//fieldLabel: "ID",
//disabled: true,
}
],
listeners: {
actioncomplete: function(form, action) {
// this listener triggers when the search request
// is complete, the OpenLayers.Protocol.Response
// resulting from the request is available
// through "action.response"
features = action.response.features;
app.featureGrid.store.loadData(features); //załadowanie zwróconego wyniku wyszukiwania do "app.featureGrid.store"
vm=app.mapPanel.map.getLayersByName("Wynik wyszukiwania");
if(vm.length==0){
vecLayer = new OpenLayers.Layer.Vector("Wynik wyszukiwania");
app.mapPanel.map.addLayer(vecLayer);
app.featureGrid.store.bind(vecLayer);
app.featureGrid.getSelectionModel().bind(vecLayer);
//app.featureGrid.getSelectionModel().bind(vectorLayer);
}
}
}
})
Prosiłbym o informację w jaki sposób zrobić, żeby puste pola nie były wysyłane do serwera WFS oraz o podpowiedź jak zrobić ostrzeżenie, w momencie gdy nie zostanie wypełnione co najmniej jedno pole w formularzu.
Z góry dziękuję