w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Web Service (web method) String return type
Basically when your list is serialized it will be converted to XML although the format would be like: <Value>EmployeeId, EmployeeName</Value> The tags are not actually unneccessary and in fact they are helpful as they preserve the data and it's conctrete data type. I am not fan of returning an XML string as it is prone to error and you may always need to update the value of the string. What I suggest is to return an object containing your result set and an error description property. public class ReturnObject { public List<Employee> list {get; set;} public String ErrorDescription {get; set;} } public class Employee { public int EmployeeID {get; set;} public string EmployeeName {get; set;} } In here your web service will return a concrete type with addi

Categories : Java

Using ng-options within a directive and getting options data from injected service
In my opinion, you have several options (as pointed out in the comments): 1. create controller for the directive In you directive's template, use a controller, i.e. <div ng-controller="SelectController"> <!-- your select with the ngOptions --> </div> and create the SelectController as a regular controller: var app = angular.module("app.controllers", []) app.controller("SelectController", ['$scope', 'myDataService', function(scope, service) { scope.options = service.whatEverYourServiceDoesToProvideThis() }]); You can also give your directive a controller, which works just the same: recManagerApp.directive(myDirective, function () { return { restrict: 'E', templateUrl: '/templates/directives/mydirective.html', scope: { m

Categories : Angularjs

Allowed Options in NSJSONSerialization class method dataWithJSONObject:options:error
NSJSONWritingPrettyPrinted is the only option supported at this time. You can provide 0, of course, if you don't want pretty printing. You can find a discussion of it at the bottom of this page. kNilOptions equates to 0, but it's included as part of the Carbon APIs, not Cocoa.

Categories : Objective C

My .NET web service method needs to return a JSON result to the calling client (an iOS device), but is returning a bunch of 's
You should use the overload of ToString() that takes the formatting parameter: return val.ToString(Formatting.None, yourJsonFormatters);

Categories : C#

WCF Service Slow - Options?
Enable tracing with switch value All. It should reveal something helpful. <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="All" > <listeners> <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:UserTraces.svclog" /> </listeners> </source> </sources> <trace autoflush="true" /> </system.diagnostics>

Categories : Json

What guarantees does the service control manager (SCM) make about the method calls on the service?
Michael Taylor provided a good answer to this question on the MSDN forums referencing the Win32 API which documents what the SCM will do in response to invalid control codes (reject them in various ways). State change methods are called only when the SCM believes the service is in the appropriate state and assuming that the service says it can handle the state (pause/continue). OnStart will be called if the service is stopped. OnPause is called if the service is running. OnContinue if the service is paused. A paused service can only be resumed or stopped. A running service can only be paused or stopped. SCM serializes commands to a service so only a single command will be running at a time. Refer to the Win32 documentation on how services work fo

Categories : C#

What are some options for java messaging from service layer to front end
One beautiful thing about Spring MVC is the Exception handling. Since the DispatcherServlet has a try-catch(Exception) wrapping the handler method (ie. your controller method), it can catch all exceptions thrown and handle them with @ExceptionHandler methods or some other construct (there are alternatives). What I've started doing is making my Service methods only throw RuntimeException instances (works well with @Transactional) and define all my @ExceptionHandler methods in a @ControllerAdvice annotated class. Something like: @ControllerAdvice public class ControllerHandler { private static final Logger logger = LoggerFactory.getLogger(ControllerHandler.class); @ExceptionHandler(value = AuthenticationException.class) public String handleAuthenticationException(Authenticati

Categories : Java

Options for transferring data between MySQL and SQLite via a web service
The XML/JSON route is by far the simplest while providing sufficient flexibility to handle updates to the database schema/older versions of the app accessing your web service. In terms of the second option you mention, there are two approaches - either use an SQL statement dump, or a CSV dump. However: The "default" (i.e.: mysqldump generated) backup files won't import into SQLite without substantial massaging. Using a CSV extract/import will mean you have considerably less flexibility in terms of schema changes, etc. so it's probably not a sensible approach if the data format is ever likely to change. As such, I'd recommend sticking with the tried and tested XML/JSON approach. In terms of the amount of data transmitted, JSON may be smaller than the equivalent XML, but it really depe

Categories : Mysql

Is it possible to return the index of an array with ng-options
I've almost done what you need, but still one problem: JS: var demo = angular.module("demo", []); demo.controller("DemoController", ['$scope', function($scope){ $scope.obj = { "value": 2, "values": [ "value 1", "value 2", "value 3", "value 4" ] }; }]); HTML: <body data-ng-app="demo"> <div data-ng-controller="DemoController"> <select data-ng-model="obj.value"> <option data-ng-repeat="i in obj.values" value="{{$index}}" data-ng-selected="$index == obj.value"> {{i}} </option> </select> {{obj}} </div> </body> But obj.value becomes string afte

Categories : Angularjs

How do I tell my service (all calls REST/JSON) to handle OPTIONS requests?
You may have to enable it in IIS as well: http://encosia.com/using-cors-to-access-asp-net-services-across-domains/

Categories : Asp Net

Can't solve enum related display options in booking service
This is a question where we cant help without knowing your complete model. There is little detail. May be you want something like this: string[] strSeatInfoStrings = new string[count]; int counter = 0; for (int i = 0; i < totalNumberOfSeats; i++) { var seatInfo = GetSeatInfoAt(i); if (seatInfo == "reserved") //some kind of checking { strSeatInfoStrings[counter] = seatInfo; counter++; //run another counter } } return strSeatInfoStrings; You can avoid all the hassle of array and counter and just use a List<T>.. var strSeatInfoStrings = new List<string>(); for (int i = 0; i < totalNumberOfSeats; i++) { var seatInfo = GetSeatInfoAt(i); if (seatInfo == "reserved") //some kind of checking strSeatInfoStrings.Add(seatInfo)

Categories : C#

Call Method In Windows Service from WCF Service (Self Hosted)
If the window service is to host WCF service, that is all what it should do (SRP). However, WCF can interact with another Project (say Business service that Process your business rules). So what I am saying is Windows service only host wcf, wcf service delegates the request to the Business service for processing

Categories : C#

jquery plugin: how to return default value when some options are not set?
I use this codes to define defaults and options and it works: var defaults = { speed : 150 , check_effect: "fade" , uncheck_effect: "fade" , }; var options = $.extend({}, defaults, options); And I dont use function on defining defaults like what you have!

Categories : Jquery

Along with my hosted Windows service's installer, is it possible to set the recovery options when errors occur?
You can set recovery options using sc.exe from the command line. This answer has a good example of how to do this using C#: Install Windows Service with Recovery action to Restart

Categories : C#

Do we have any options to collect storage service operation logs in Azure using Rest API
Thanks for sharing the steps. Yes, you could programmatically get this information. To do so, you would need to make use of Windows Azure Service Management API especially List Subscription Operations. Portal actually makes use of the same operation.

Categories : Java

Calling WCF Service Contract/Method without Service Name in the url
refer to Creating WCF service without .svc file and link mentioned in one of the comments - http://blogs.msdn.com/b/rampo/archive/2009/10/27/activation-without-svc-files-config-based-activation-cba.aspx

Categories : Wcf

Manually applying OData query options using Breeze and still return InlineCount
I eventually stumbled upon the solution to this problem. The following post is what lead me to the proper solution to take care of the problem I described above. Breeze WebAPI: How to combine QueryResult with ODataQueryOptions to return inlineCount

Categories : C#

Call ASP.net web service method inside succeeded callback function of another method in javascript
You have writen the second function inside the first function. Correct it as below. <script type='text/javascript' language='javascript'> myNameSpace.myClass.myMethod1(succeededCallBack1); function succeededCallBack1(strResponse1) { //some operation with strResponse myNameSpace.myClass.myMethod2(s, p, x, y, succeededCallBack2); } function succeededCallBack2(strResponse2) { alert(strResponse2); } </script>

Categories : Javascript

Configuring Spring MVC to map GET requests to one method in a controller and OPTIONS requests to another method
With the SimpleUrlHandlerMapping it is not possible specify the http method. Probably you have to use other mapping like the MethodUrlHandlerMapping in the Spring MVC REST project (http://spring-mvc-rest.sourceforge.net/). The way to declare the mappings using the MethodUrlHandlerMapping should be something like this: <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="GET /hitmycontroller">MyController</prop> <prop key="OPTIONS /hitmycontroller">MyController</prop> </props> </property> </bean> You can see the example in their page: http://spring-mvc-rest.sourceforge.net/introduction.html Look at the par

Categories : Java

"Method must have a return type" and "return must not be followed by an object expression"
You would need to change the declaration to return an Exception: public static Exception LogMessage(Exception ex) { Trace.WriteLine(ex.ToString()); return ex; } Note that, depending on usage, it might make sense to allow this to be a generic method: public static T LogMessage<T>(T ex) where T : Exception { Trace.WriteLine(ex.ToString()); return ex; } This would allow you to use the resulting exception in a strongly typed manner. Alternatively, you could just not return the exception, since Logging shouldn't need to return an exception in any case: public static void LogMessage(Exception ex) { Trace.WriteLine(ex.ToString()); }

Categories : C#

Call an action method in mvc controller from a WCF service method
You have to think of them as separate websites, the wcf service wouldn't just instantiate a controller and run it, more it would create a webrequest and do either a get or post to it. You can leverage the System.Net.WebClient class to do that. All you need to do is decide if you want to post or get some data from the mvc site, and then use one of the methods on the webclient class to accomplish it. http://msdn.microsoft.com/en-us/library/system.net.webclient(v=vs.100).aspx That will detail the webclient class and how to use it. You will probably need an appsetting entry on the wcf service to point to the mvc site that you want to call, shouldn't be complicated at all

Categories : Asp Net

Use other service from a service method in AngularJs
The $scope service is unique to Controllers (and directives, but in directives it isn't being injected). Try another service name which you defined in another factory or just any other angular service like $http and it will work...

Categories : Javascript

Angularjs - $resource causing a 404 - method: OPTIONS
The answer here is that your browser is running into a cross domain issue See http://metajack.im/2010/01/19/crossdomain-ajax-for-xmpp-http-binding-made-easy/ for an explanation and Jquery: Why am I getting an OPTIONS request insted of a GET request? for a question basically the same as yours.

Categories : Angularjs

Loading has_many options hash via a method
has_many is just a class method so this: has_many :related_things, get_association_hash(arg1) is just a method call like any other and the receiver in that context is your ExampleClass. That means that get_association_hash needs to be a class method. You'll also have to define it before your has_many calls or you won't be able to call it where you want to: class ExampleClass < ActiveRecord::Base def self.get_association_hash(arg) { :class_name => 'SomeClass', :conditions => ['table.column = ?', arg] } end has_many :related_things, get_association_hash(arg1) has_many :other_things, get_association_hash(arg2) end That might be a bit ugly and make a mess of the usual definition order. If that's the case, then you can push your get_association_hash method into a modu

Categories : Ruby On Rails

jQuery options for method stop working
The problem is here: alert('We are currently ' + say + '!'); // -------------------------^ You want alert('We are currently ' + options.say + '!'); The first one is looking for a variable called say. The second is looking for the property say on your options object. You also have a } where you mean to have a ): var options = $.extend({say:'open'}, options}; // -----------------------------------------^ should be var options = $.extend({say:'open'}, options); With those two fixes, it runs fine (source).

Categories : Javascript

Using python's mock patch.object to change the return value of a method called within another method
It can be done with something like this: #foo.py class Foo: def method_1(): results = uses_some_other_method() #testing.py form mock import patch @patch('Foo.uses_some_other_method'): def test_some_other_method(mock_some_other_method): mock_some_other_method.return_value = "specific_value" foo = Foo() the_value = foo.method_1() assert name == "specific_value" Here's a source that you can read: Patching in the wrong place

Categories : Python

How to mock the return of a public method called in a private method inSpring
If you are trying to test Service, then you have to mock oracleDao as well and make its getSubjectOracle() method return the String you want. I'm assuming you aren't testing getSubject() but a method that calls getSubject().

Categories : Java

Javascript Method Chaining: Correct method chain toFixed() and parseFloat() to return a number, not a string?
toFixed is a method of Number and returns a string. window.parseFloat is a global function and not a method of String, but if you really must, then you can make it a String method, otherwise just use it as a function. You can even use the unary plus operator in this case. (There is a great deal of discussion about augmenting native objects that I am not going to go into, you can do some research and make up your own mind.) Javascript if (!String.prototype.parseFloat) { String.prototype.parseFloat = function () { return parseFloat(this); } } var lat = 123.456789; console.log(parseFloat(lat.toFixed(2))); console.log(lat.toFixed(2).parseFloat()); console.log(+lat.toFixed(2)); Output 123.46 123.46 123.46 On jsfiddle

Categories : Javascript

Understanding [options] argument in Backbone.sync method
The meaning of that line is to ensure that the options hash is a hash object and not null. More generally, this is one way in JavaScript to give a parameter a default value.

Categories : Javascript

What is the difference between done and complete options in the jquery animate method
done() is global across the entire of jQuery and fires based on all events within the promise being completed, regardless of if they are queued or async. Check promises out on jquery's website: jQuery Promise Example from documentation: var effect = function() { return $("div").fadeIn(800).delay(1200).fadeOut(); }; $("button").on("click", function() { $("p").append(" Started... "); $.when(effect()).done(function() { $("p").append(" Finished! "); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button>Go</button> <p>Ready...</p> <div></div> <div></div> <div></div> <div></div>

Categories : Jquery

What is the current method of implementing an options menu in an application?
It really depends on the particular app, existing UX, branding and a ton of other design considerations. In general, starting from scratch, a good starting point (though not universally!) would be the action bar. It gives the user access to ways of manipulating the data on screen, as well as a way of consistently presenting secondary functionality (the overflow menu). Design docs, implementation docs. I would heartily recommend going through the Patterns section of the design documentation, as it explains the rationale behind many of the core design decisions. P.S. The reason I'm eager to underline that it's not universal is apps with established UX and user expectations. Examples include Facebook, Path, Google Maps. They all have their reasons for not sticking strictly to the action ba

Categories : Android

Calling a float return from method 1 in another method Objective-C
call like this, - (IBAction)txtChangeEinde:(id)sender { NSLog(@"totaal: %.2f",[self berekenTotaal:totaal]); OR NSLog(@"totaal: %.2f",[self berekenTotaal:someFloatValue]); }

Categories : Objective C

Can a method that supposed to return value be used like method that returns nothing (void)?
You don't have to use the value returned by registerListener(). Consider this code: void performOperation() { doSomething(); } doSomething does something and returns true if the operation was successfully done, false otherwise. performOperation doesn't return a thing, it simply performs the operation. Another example: public boolean delete(): Returns: true if and only if the file or directory is successfully deleted; false otherwise You don't have to use the value returned by delete method (but it's highly recommended to). Clarification: You're probably confused with method signature in this situation. Methods are declared like: modifier return-type name(parameters ..) When your method declared to return something, it must return something! But if you us

Categories : Java

return method response after it executes to the parent method
Your controller method is expecting to output the result as an echo statement, which goes to the browser, rather than to return it in a variable. This means your server function is having to try to capture the output of that controller method. That setup is much more awkward and prone to error. Unless you also need to access your update_p method directly from a browser you should change your Controller to simply return the output which really means this controller is more of a library and should probably go in the libraries folder. You will need to change your controller code a bit so that instead of grabbing the parameters from $_GET you are getting them as arguments, which in CodeIgniter is what you should be doing anyway. So from the end of update_p just do this instead of your echo:

Categories : PHP

Ambiguous Method Names: Same method name and parameters different return value
No, different return type does not constitute an overload. You're better off renaming the methods with a convention that includes the return type name. Another approach is to use generics to make the typing flexible. More info here http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx

Categories : C#

Kendo UI Grid request method is OPTIONS even if I intend to POST
If you are accessing http://127.255.0.1:8081/api/meeting/postmeeting from http://localhost:30320, it is a cross-origin request. By default, browsers prevent access to a resource which is in a different origin. Check this out. Cross-Origin Resource Sharing (CORS) is one way to get around this limitation. Since you do a POST, the browser makes a pre-flighted CORS request, which is basically an OPTIONS request. If this OPTIONS request results in a response with necessary CORS headers, the browser will make the POST request subsequently. You can implement an action method to handle OPTIONS but it is very easy to enable CORS in Web API now. Check this link.

Categories : Ajax

this.options is not defined inside public method Jquery Widget
You need to use $el.find(this.options.optionsGroup + " .option").on('click', $.proxy(this.bindOption, this)); Since bindOption is added as a callback to an event, this inside bindOption does not point to the widget, it refers the dom element which triggered the event. You can fix it by passing a custom execution context to the callback handler using $.proxy()

Categories : Jquery

Most efficient method to store MYSQL options and values in database
I'd store all the values serialized (e.g. JSON or XML or YAML) into a blob, and then define inverted index tables for attributes I want to be searchable. I describe this technique and alternatives in my presentation Extensible Data Modeling with MySQL. Also see http://bret.appspot.com/entry/how-friendfeed-uses-mysql

Categories : PHP

Method must have a return type on an InitializeComponent() method
The problem is that your GenerateReport method doesn't declare a return type. If it doesn't return anything the return type should be declared as void. public void GenerateReport(MainWindow mainWindow) { InitializeComponent(); }

Categories : C#

Why does he method imagecreatefromjpeg($src) return false in my method?
Are you sure that the image is a valid jpeg image? You check the type of the image by extension. You can check get the extension in a much simpler way. You should also check if the file exists: function makeThumb( $src, $thumbWidth, $imageName ) { if(!file_exists($src)) throw new Exception('The file '.$src.' does not exist.'); $ext = pathinfo($src, PATHINFO_EXTENSION); But checking the type of an image using extension is not reliable. There is another way to check that using the getimagesize function: function makeThumb( $src, $thumbWidth, $imageName ) { if(!file_exists($src)) throw new Exception('The file '.$src.' does not exist.'); $info = getimagesize($src); if($info === false) throw new Exception('This file is not a valid image');

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.