w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Mono Gtk.Dialog returning object as response
Just store the object you want to return in your dialog object, and provide access to it using a property. Don't forget to check whether the user pressed the cancel button (if you have one), conveniently by examining the return value of Run(). For an example see the sample code for the stock FileChooserDialog in the official documentation.

Categories : C#

hql - returning single object instead of list?
No, it will still return a collection for you to iterate over - but you can use uniqueObject to get a single result instead. That will throw an exception if it turns out there's more than one result.

Categories : Java

Returning a list of indices where a certain object appears in a nested array
Nothing super-elegant comes to mind for me right now. This seems to work: def indices_of(board, letter) indices = [] board.each_with_index do |ar, i| ar.each_with_index do |s, j| indices.push([i, j]) if s == letter end end indices end boggle_board = [["P", "P", "X", "A"], ["V", "F", "S", "Z"], ["O", "P", "W", "N"], ["D", "H", "L", "E"]] indices_of(boggle_board, "P") # => [[0, 0], [0, 1], [2, 1]]

Categories : Ruby

SIGSEGV and mono crash issue while running .NET binary using mono
Try this: Disable increasing amounts of your own/application code until the error goes away. Then refine, with smaller steps, to see which part/line of your code is causing this. If in the end, there is absolutely no own/application code left, play with the configuration, version, compiler options, of the libraries you're using. Sorry I can't give you a detailed answer, but I HTH. Good luck!

Categories : C

Android Mono List view
This is your layout at the bottom, minus the XML header. To make it work, you have to modify your OnCreate method to load your listview this way.. since you have more items in your view than just the List for your activity. SetContentView (Resource.Layout.YourLayoutFileName); ourlist = FindViewById<ListView> (Android.Resource.Id.List); ourlist.Adapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, list); <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:minWidth="25px" android:minHeight="25px"> <Button android:id="@+id/yourbutton" android:layout_width="300dip" android:gravity="center" a

Categories : Android

InvalidOperationException : Operation is not valid due to the current state of the object with Mono.Cecil
It was because of the version of the DLL, which was not the latest. I do not get the specific exception any longer. However, I cannot seem to write a resource to a certain stream. I had to write to a temporary file, then read from that file and write into the target assembly. Does anyone have an example that works ?

Categories : Misc

Python - Chaining methods: returning `self` vs returning a new cloned object
Django does this so that the base query can be kept around and reused, without inheriting changes from a future "child" query, like your exclude() on your filter(). I'm guessing somebody tried storing queries for later, and realized that didn't work well without copying. I cloned the django repo and did a quick git log on django/db/models/query.py, searching for the phrase clone. The patch that introduces this change is here: https://github.com/django/django/commit/d4a3a4b

Categories : Python

Take parameter, determine if its an object or list<>; if list<> then loop and treat each item as object
You could do something like this: public static Dictionary<string, object> Pick(object obj, Array Picklist) { Dictionary<string, object> dic = new Dictionary<string, object> (); IEnumerable items = obj as IEnumerable ?? new[] { obj }; foreach(string key in Picklist) { foreach(object item in items) { dic.Add(key, item.GetType().GetProperty(key).GetValue(item, null)); } } return dic; } Note however, this will fail if you actually try to provide two or more items, since it will attempt to add the same key to the dictionary twice. It will also fail if you try to pass an object which doesn't have one of the specified properties. It's unclear exactly what you want this method to do in these cases, but this code s

Categories : C#

Knockout.js Dynamic HTML Binding returning [object Object]
Your optionText is indeed an Option object. Try: htmlContent += item.optionText.optionText; UPDATE: The real problem lies here: function PagesViewModel(pageNo, pageHeader, questions) { this.pageNumber = ko.observable(pageNo); this.pageHeaderText = ko.observable(pageHeader); this.questionItems = ko.observableArray($.map(questions, function (n) { return [new QuestionViewModel(n.questionType, n.questionNumber, n.questionText, n.pointsBudget, n.options)] })); } When you're creating your PagesViewModel, the questions parameter is already an array of QuestionViewModel objects, and by assigning this.questionItems with your custom function, you're re-creating the QuestionViewModel, passing it n.options that is already an array of Option objects thus re-wrapping it

Categories : Javascript

Iterating over list of list elements and returning error message if integer has certain value
Use the any() function with a generator expression testing each nested list: if any(bread[2] > 80 for bread in breadsticks): print("You have entered too many breadcrumbs") This will only test as many nested lists as needed to find any for which the test is True. Note that it is simpler to just loop directly over breadsticks in loops: for bread in breadsticks: print(bread[2])

Categories : Python

Function returning an object by value or nothing if object doesn't exists
You can use the "Option Pattern". The basic idea is: template <typename T> class Optional { private: bool valueIsPresent; T value; } Then, from the function you can return Optional<YourType>. Client code can then check if a value is effectively present before trying to access it and use it.

Categories : C++

jQuery UI autocomplete returning [object Object]
Keep the line $('.search_box').val(searchTerm); But change the previous line to var searchTerm = ui.item.label; That will do it. Look in the log of this fiddle: http://jsfiddle.net/Ntb7G/

Categories : Jquery

GetConnection object not returning connection object
According to The doc for WrapperDataSource it doesn't implement DataSource. If you want to get a connection change your code this way: import org.jboss.resource.adapter.jdbc.WrapperDataSource; ... WrapperDataSource ds=(WrapperDataSource)jndiCntx.lookup("java:/MySqlDS"); return ds.getConnection();

Categories : Java

Creating new object in python is not returning a new object
You have created x as a class variable rather than an instance variable. To associate the variable with a particular instance of a class, do something like this: class myObject(object): def __init__(self): # The "constructor" self.x = [] # Assign x to this particular instance of myObject >>> debug: [] >>> debug: [] For a little better explanation of what's going on, have a look at this little mockup that demonstrates the same thing, a little more explicitly (if also more verbosely). class A(object): class_var = [] # make a list attached to the A *class* def __init__(self): self.instance_var = [] # make a list attached to any *instance* of A print 'class var:', A.class_var # prints [] # print 'instance var:', A.instance_var # This would ra

Categories : Python

Python Object list keep changing when I change an other object list
Lose the class attributes. You are not using them anyway. In fact it's causing your bug because all the instances appear to share the same CHAN list class ircServer: def __init__(self, HOST, PORT): self.HOST = HOST self.PORT = PORT self.CHAN = [] def addChan(self, CHANEL): self.CHAN.append(CHANEL) Also consider reading PEP8 and following at least most of the guidelines there

Categories : Python

Session Variable List, when adding a new Object I get Object reference not set to an instance of an object
After Session["SessionStats"] = new UserSession(); you have added a new UserSession, whose Option property is null, to Session. Then, when you do ((UserSession)Session["SessionStats"]).Options.Add(RO); you are pulling out that very same object and accessing the Option property, which is null, hence the NullReferenceException. It looks like you are forgetting to assign something to the newly created UserOption's Option property. However, you don't seem to be using the Options you are instantiating in the foreach for anything...

Categories : Asp Net

c# List.Contain(List) not returning true for containing list
To compare the lists, use SequenceEqual (MSDN) In your case, you can combine it with Any: var containsListToFind = parentList.Any(x => x.SequenceEqual(listToFind)); Contains won't work because it uses the default .Equals method of the objects in the list. For List<T>, that is a reference comparison, not a value comparision. Since listToFind is a different object than the one in parentList, the references are different and Contains won't find anything.

Categories : List

Reading values into a List object - Object reference not set to an instance of an object
This change should solve the problem: MyVec::MyVec(void) { MyVector = gcnew List<double>(); } Class member MyVector is initailly null reference. You need to initialize it before using, and MyVec constructor is appropriate place to do it.

Categories : List

Why is Javascript returning [object Object]?
console.log will give you a debugging view of an object. alert will give you a string view of an object. Objects are converted to strings by calling .toString() on them. The default toString() function on a basic object will return "[Object object]"

Categories : Javascript

Returning a list to another list from a for-loop
I think you want to do something like this: >>> def list_of_list(): ... all_lists = [] ... for _ in range(3): ... all_lists.append([1, 2]) ... return all_lists ... >>> >>> list_of_list() [[1, 2], [1, 2], [1, 2]] I've just appended [1, 2] everytime for demonstration purpose. You can add any list there.

Categories : Python

casting list to list
You should be able to use the Cast() extension method in Linq Objects = HttpContext.Current.Items["Objects"].Cast<object>().ToList() http://msdn.microsoft.com/en-us/library/bb341406.aspx

Categories : C#

Search list of object based on another list of object c#
Well, you could just use: bool hasCode = arts.Any(a => a.BarCode.Intersect(eans).Any()); That's assuming that either you want to treat each Ean object individually, or you've actually overridden Equals and GetHashCode appropriately. It would be more efficient to create a set though: var set = new HashSet<Ean>(eans); bool hasCode = arts.Any(a => a.BarCode.Any(e => set.Contains(e))); As an alternative approach, you could flatten your list to basically be a sequence of barcodes: bool hasCode = arts.SelectMany(a => a.BarCode) .Intersect(eans) .Any(); That's actually probably the cleanest approach, as you don't care about which article has the matching barcode.

Categories : C#

What kind of List is List list = Database.getAllData();?
You don't have to know; that's the point. The interface is what matters to you, not the implementation. You can't know without looking at the source of that method. But even if you do, it's immaterial to your client. All you call are List methods.

Categories : Java

Returning object in Yii Component
Suppose you have this in your config file: ... 'components' => array( 'parameters' => array( 'class' => 'path.to.parameters.php', 'applications' => array( 'productName' => array( 'tableName' => 'settings', 'property' => 'param1' ), ) ), ), ... If you want to have Yii::app()->parameters->productName->tableName return the value "settings". Your application component would then have to override the __get magic method to check if $this->applications contains the "productName" key using isset() and return that key's value as an object instead of an array. The application component would look like this: <?php namespace Sakanade; class parameters extends CApplicationComponent { public $cacheAll = false; p

Categories : PHP

How is returning an object by reference possible?
It could be as simple as a cv::Mat having a shared pointer to a dynamically allocated block of memory. When you copy a Mat instance, you copy the shared pointer (incrementing the reference count), not the resource it points to.

Categories : C++

Why isn't this query returning an object?
There's probably an error in your SQL query and $result is false instead of the result object. I think it's probably because you're missing some spaces in the query. This line: $query = "select * from books where".$searchtype."like '%".$seachterm."%'"; should be something like: $query = "SELECT * FROM books WHERE '" .$searchtype. "' LIKE '%".$seachterm."%'"; It would help if we knew the values of: $_POST['searchtype']; $_POST['searchterm'];

Categories : PHP

Returning A> from builder
Is ParameterDefinition a generic class? In other words, is it defined as public class ParameterDefinition<T> or something other than public class ParameterDefintion If so, then you can return a ParameterDefintion<List<String>>, but if not, you need to decide on what value to place within the <T> area. By the way, adding final to a static method has no effect, and is redundant. I'd remove it. After ParameterDefinition takes a Generics parameter, you can write public static final <X> ParameterDefinition<X> build(Class<X> clazz, String name) { ... return ...; } And you don't even need the cast you had at (ParameterDefinition) ParameterDefinition.build( List.class, "names" );

Categories : Java

Correctly returning object through Many to Many relationship
try this: class ArticleUserOwnership (models.Model): article = models.ManyToManyField(Article) user = models.ManyToManyField(User) def __unicode__(self): return self.article OR def __unicode__(self): return self.article.question

Categories : Django

Object.hashCode() returning duplicate
It may happen. You may get same hashcode for two different objects: As per Object.hashCode() documentation: It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables. what can be done to avoid it?  Here are few best practices suggested in other SO questions: Hashcode implementation best practice1 Hashcode implementation best practice2 Still, these are best practices only, not guaranteed to avoid same hashcode. In your case I think you simply shouldn't depend on hashcode.

Categories : Java

Returning "undefined" field in object
Since I still can't comment I'll post as an answer. My guess here is that javascript has never been clear about the "passing as value/reference" issue. var entry contains all the values from your JSON and are copied as reference to your "note" object, but since it's on a limited scope, these references cease to exist. Just for testing, try copying some of the values directly from the response variable.

Categories : PHP

Public_Activity returning an object instead of result
Have you tried this to see if it works: Activity.order("created_at desc") I am just wondering if you have namespacing setup correctly. I am not familiar with the way you are trying to namespace. Maybe give this a try: Module PublicActivity class Activity end end or class PublicActivity::Activity < ActiveRecord::Base (or whatever class you want) end

Categories : Ruby On Rails

Keeps returning [object HTMLSpanElement]? (Javascript)
Try something like this: function prompta1() { var a1 = prompt("Unesi broj", ""); var spana1 = document.getElementById("spana1"); spana1.innerHTML = a1; } function prompta2() { var a2 = prompt("Unesi broj", ""); var spana2 = document.getElementById("spana2"); spana2.innerHTML = a2; } function functiona7() { var spana1 = document.getElementById("spana1").innerHTML; var spana2 = document.getElementById("spana2").innerHTML; var spana7 = document.getElementById("spana7"); if (!(spana1 && spana2 && spana7)) return; var a7 = spana1 + spana2; spana7.innerHTML = a7; } Fiddle In your current example the values for spana1/2 are not pulling from the DOM, so first they need to be populated using getElementById, after that a simple c

Categories : Javascript

PowerShell Select-Object returning more than specified?
That should work, but it sounds like for some reason the assignment of the results of Get-VM to $obj is happening before anything gets piped to select. Try Get-VM | select VMName, State by itself at the prompt, and if you get the expected results, try this: $obj = (Get-VM | select VMName, State); $obj To get just the State property, you can do this: (Get-VM).State

Categories : Powershell

unwanted returning empty object
Update based on further clarifications from comments below $(document).ready(function () { /***The objects that I am creating with arrays***/ var columnOne = { '$100':'On the world political map, where were some of the major states and empires located about 1500 A.D. (C.E.)?', '$200':'What were the artistic, literary, and intellectual ideas of the Renaissance?', '$300':'Where were the five world religions located around 1500 A.D. (C.E.)?', '$400':'What were the regional trading patterns about 1500 A.D. (C.E.)?', '$500':'Why were the regional trading patterns important?' }; var columnTwo = { '$100':'A', '$200':'B', '$300':'C', '$400':'D', '$500':'E' }; var columnThree = { '

Categories : Jquery

Returning an object based on type
You may try using Dictionary, e.g. Dictionary<String, BaseEntry> types = new Dictionary<String, BaseEntry>() { {"BaseBall", new BaseBallService()}, {"BasketBall", new BasketBallService()}, ... } ... var value = types["BaseBall"].GetId(2);

Categories : C#

View Not Returning HttpResponse Object
I think you should tweak something like this: if request.method == 'POST': for user in myUsers: if user in request.POST: request.session['myUser'] = request.POST['myUser'] request.POST is dictionary-like object, and your myUsers is a list. I dont think you can do myUser in request.POST directly in python. Its my 2 cent.

Categories : Python

Is returning a dereferenced iterator the same as an object?
The problem is that you are trying to take the address of a temporary. (p_graph->getVertex(vert2)); The expression (p_graph->getVertex(vert2)) returns a temporary and the life time of such temporary is until ; is reached. The scenario is more like - Vertex *v2 = & Vertex(); You have an option of const qualifying the v2 which extends life time of such temporary. Try - const Vertex* v2 = &(p_graph->getVertex(vert2));

Categories : C++

Returning object-parameter in Web-Flow
i think the problem is here: value="requestParameters.address.street" requestParameters can only contain Strings and you expect an object of the type Address Simply pass your street like this ...&name=foo&street=bar... in your url and receive it as requestParameters.street

Categories : Java

Returning an object from a form using MVVM
Something like this: interface IPresentationService { bool ShowInDialog(ViewModel viewModel); } class CarViewModel : ViewModel {} class MainViewModel : ViewModel { [Import] private IPresentationService presentationService; private void AddNewCar() { var car = new CarViewModel(); if (presentationService.ShowInDialog(car)) { Cars.Add(car); } } public MainViewModel() { Cars = new ObservableCollection<CarViewModel>(); AddNewCarCommand = new RelayCommand(AddNewCar); } public ObservableCollection<CarViewModel> Cars { get; private set; } public ICommand AddNewCarCommand { get; private set; } } Where IPresentationService is a service, which is intended to create and show a pop

Categories : C#

find_by_* method is not returning the object
First off, unless this is a simple exercise in Rails authentication, you should use Devise or AuthLogic at this stage. Second, are you sure that params[:email] contains the email you are looking for? From your params, it looks to me like you want to use params[:session][:email]. Third, you should move this down into the model. For example: class SecurityUser < ActiveRecord::Base def self.authenticate(params) user = where(email: params[:email]).first (user && user.password == params[:password]) ? user : false end end And in the controller: @user = SecurityUser.authenticate params[:session] session[:user_id] = user.id if @user Note above that the password is not hashed - you should not save a plain text password - but that's not what this is about. Also note t

Categories : Ruby On Rails



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