JSUrlModel

From GeoMedia Smart Client
Jump to: navigation, search
GMSC 2013/2014 Javascript API Overview Form Events Types Utility Functions client-side Validation Conditions Interaction with SmartClient Cookbook Cheatsheet
Utility Functions Request and URL Handling Localisation Dialogs & Notification Workflow Utility Functions


IG.url(url)

returns an IG.url class instance. GMSC 2013


Paramters

{String} url A string containing the Asp .Net Action to which the request is sent.


Examples

Basic IG.Url Object

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Save');
 
	myUrl.toString();
	//returns "{HOSTADDRESS}/Form/Save"

Methods

urlParams(params [, options])


includes parameters to url. If the parameter key already exists the parameter value will be overwritten. GMSC 2013


Parameters

{Object} params An object with key/value pairs to include to url Structure: {[ {String} urlParameterKey: {String} urlParameterValue ]}

{Object} options An object with attributes

Structure:

ignoreFalsyValues: {Boolean} (default: false)
If falsy values (null, NaN, undefined) should be rejected.

omitKeys: {Boolean} (default: false)
Omit the given keys during serialisation


Examples

Basic including of additional url parameters

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Save');
 
	myUrl.urlParams({ "foo" : "bar" });
 
	myUrl.toString();
	//returns "{HOSTADDRESS}/Form/Save?foo=bar"


Overwrite existing url parameters

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Save');
	//Including url parameters
	myUrl.urlParams({ "foo" : "bar", "oof" : "rab" });
	myUrl.toString();
	//returns "{HOSTADDRESS}/Form/Save?foo=bar&oof=rab"
 
	//Overwrite parameter
	myUrl.urlParams({ "oof" : "newRab" });
 
	myUrl.toString();
	//returns "{HOSTADDRESS}/Form/Save?foo=bar&oof=newRab"


postParams(params [, options])


includes parameters to http body. If the parameter key already exists the parameter value will be overwritten. GMSC 2013


Parameters

{Object} params An object with key/value pairs to include to http post. Structure: {[ {String} urlParameterKey: {String} urlParameterValue ]}

{Object} options An object with attributes

Structure:

ignoreFalsyValues: {Boolean} (default: false)
If falsy values (null, NaN, undefined) should be rejected.

omitKeys: {Boolean} (default: false)
Omit the given keys during serialisation


Examples

Basic including of additional post parameters

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Save');
 
	myUrl.postParams({ "foo" : "bar" });


Overwrite existing post parameters

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Save');
	//Including url parameters
	myUrl.postParams({ "foo" : "bar", "oof" : "rab" });
 
	//Overwrite post parameter
	myUrl.postParams({ "oof" : "newRab" });


hasUrlParam(param)


validates if parameter is already existing in url. Returns true if given parameter key is already existing in url. GMSC 2013


Returns

{Boolean} result of the validation.


Parameters

{String} param The parametery key as string.


Examples

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Save');
	myUrl.urlParams({ "foo" : "bar" });
 
	myUrl.hasUrlParam("foo");
	//returns true
 
	myUrl.hasUrlParam("oof");
	//returns false


hasPostParam(param)


validates if parameter is already existing in http post body. Returns true if given parameter key is already existing in http post body.GMSC 2013


Returns

{Boolean} result of the validation.


Parameters

{String} param The parametery key as string.


Examples

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Save');
	myUrl.postParams({ "foo" : "bar" });
 
	myUrl.hasPostParam("foo");
	//returns true
 
	myUrl.hasPostParam("oof");
	//returns false


removeUrlParams(paramArr)


removes given url parameters. GMSC 2013


Parameters

{Array} paramArr An array of parameterkeys as strings.


Examples

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Save');
	myUrl.urlParams({ "foo" : "bar", "oof" : "bar" });
	myUrl.toString();
	//returns "{HOSTADDRESS}/Form/Save?foo=bar&oof=rab"
 
	//remove url parameter
	myUrl.removeUrlParams(["oof"]);
 
	myUrl.toString();
	//returns "{HOSTADDRESS}/Form/Save?foo=bar"


removePostParams(paramArr)


removes given post parameters. GMSC 2013


Parameters

{Array} paramArr An array of parameterkeys as strings.


Examples

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Save');
	myUrl.postParams({ "foo" : "bar", "oof" : "bar" });
 
	//remove post parameter
	myUrl.removeUrlParams(["oof"]);


redirectTo()


redirects to defined location. GMSC 2013


Examples

	//Create an IG.Url Object with simple Controller/Action url
	var myUrl = IG.url('Form/Index');
	myUrl.urlParams({ "nodeid": "1"});
 
	//change current location
	myUrl.redirectTo();