Project

General

Profile

1
/*
2
Author:       Mike Adair mike.adairATccrs.nrcan.gc.ca
3
License:      LGPL as per: http://www.gnu.org/copyleft/lesser.html
4

    
5
$Id: OWSCatSearchForm.js 2076 2006-04-11 19:48:08Z madair $
6
*/
7

    
8
// Ensure this object's dependancies are loaded.
9
mapbuilder.loadScript(baseDir+"/widget/WidgetBaseXSL.js");
10

    
11
/**
12
 * Widget to display a form for input of parameters to generate a web service 
13
 * request.  This JS object handles the form submit via HTTP Get by appending 
14
 * a query string to the form's action URL.  The query string is created from
15
 * all input elements and their values.
16
 * The target model is then loaded from the URL created.
17
 * A stylehseet must be specified as a property in config for this widget.  
18
 * See widget/NtsForm.xsl for an example. 
19
 *
20
 * @constructor
21
 * @base WidgetBaseXSL
22
 * @param widgetNode This widget's object node from the configuration document.
23
 * @param model The model that this widget is a view of.
24
 */
25

    
26
function FormBase(widgetNode, model) {
27
  WidgetBaseXSL.apply(this, new Array(widgetNode, model));
28

    
29
  //get bbox inforamtion from a map model
30
  this.webServiceUrl = this.getProperty("mb:webServiceUrl");
31

    
32
  /**
33
   * Refreshes the form onblur handlers when this widget is painted.
34
   * @param objRef Pointer to this CurorTrack object.
35
   */
36
  this.postPaint = function(objRef) {
37
    var searchForm = document.getElementById(objRef.formName);
38
    searchForm.parentWidget = objRef;
39
    searchForm.onkeypress = objRef.handleKeyPress;
40
    searchForm.onsubmit = objRef.submitForm;
41
  }
42

    
43
  //set some properties for the form output
44
  this.formName = "WebServiceForm_" + mbIds.getId();
45
  this.stylesheet.setParameter("formName", this.formName);
46

    
47
  /**
48
   * handles keypress events to filter out everything except "enter".  
49
   * Pressing the "enter" key will trigger a form submit
50
   * @param event  the event object passed in for Mozilla; IE uses window.event
51
   */
52
  this.handleKeyPress = function(event) {
53
    var keycode;
54
    var target;
55
    if (event){
56
      //Mozilla
57
      keycode=event.which;
58
      target=event.currentTarget;
59
    }else{
60
      //IE
61
      keycode=window.event.keyCode;
62
      target=window.event.srcElement.form;
63
    }
64

    
65
    if (keycode == 13) {    //enter key
66
      return true;
67
    }
68
  }
69

    
70
  /**
71
   *
72
   * @param
73
   */
74
  this.setValue = function(xpath, value) {
75
    this.model.setXpathValue(this.model,xpath,value,false);
76
  }
77
}
(38-38/145)