w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to do arithmetic in Spring properties, with values from a properties file?
If you're using Spring 3.0 or later, you can use the property inside the SpEL expression like this: <property name="validationQueryTimeout" value="#{${jdbc.timeout}/1000}" />

Categories : Java

Selecting nested navigation properties will generate the same SQL statement when selecting separate navigation properties
In a nutshell yes, it has to otherwise there is no way for you to traverse to that navigation property EG, the only way to access AccountDefinition.SDOrganization.AaaPostalAddresses is if SDOrganization is not null. Having said that my personal preference is to make this intermediate inclusion explicit by listing it anyway. While this has no functional benefit its a reminder that this property will also be returned

Categories : Asp Net Mvc

MSBuild: how to use the nested properties like in Ant
Here are some of the "tricks". Save the below xml into a file called "MSBuild_Conditionals.xml" <?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapper"> <!-- --> <PropertyGroup> <MyFavoriteFoodComplement Condition="'$(FavoriteFood)'=='PeanutButter'">Jelly</MyFavoriteFoodComplement> <MyFavoriteFoodComplement Condition="'$(FavoriteFood)'=='Steak'">Potatoes</MyFavoriteFoodComplement> <!-- Check to see if a match was given (by seeing if the variable value is an empty string), if no match (aka, an empty string), do a default --> <MyFavoriteFoodComplement Condition="'$(MyFavoriteFoodComplement)'==''">Cookie

Categories : Ant

How to build nested properties from key strings
Try the following: function objectBuild(object, keys, value) { for (var i = 0; i < keys.length-1; i++) { if (!object.hasOwnProperty(keys[i])) object[keys[i]] = {}; object = object[keys[i]]; } object[keys[keys.length-1]] = value; } Example usage (see it in action): var object = {}; objectBuild(object, ["foo", "moreFoo"], "bar"); objectBuild(object, ["foo", "ultraFoo"], "bigBar"); // object --> {foo: {moreFoo: "bar", ultraFoo: "bigBar}}

Categories : Javascript

Can python objects have nested properties?
The traceback is because your property doesn't have a return statement, hence it returns NoneType, which obviously can't have attributes of its own. Your property would probably need to return an instance of a different class, that has its own prop attribute. Something like this: class a(): def __init__(self): self.b = b() @property def prop(self): print("hello from object.prop") return self.b class b(): @property def prop(self): print("Hello from object.prop.prop") x = a() print x.prop.prop >> hello from object.prop >> Hello from object.prop.prop >> None

Categories : Python

Initializing nested object properties
Without requiring changes to your Employee class, you could use object initializers: var myEmployee = new Employee { Name = "Jhon", Insurance = new Insurance { PolicyId = 123, PolicyName = "Life Time" } }; Alternatively, and maybe preferably, you can have the Employee class create a new instance of Insurance either in its constructor (as in the other answers), or one other option would be to do it in the Insurance property getter itself, so it's instantiated only if you use it. Here's an example of the latter: class Employee { private Insurance insurance; public Insurance Insurance { get { if (insurance == null) { insurance = new Insurance(); } return insurance

Categories : C#

calculate closed sets of keys and values in two dictionaries
It sounds like you want to find closed sets c in C st for each n in c, every p in PhoneDupes[n] and every co in CompanyDupes[n] is also in c. As a first pass, let's build some sets of number we know are associated: PhoneDupes = {8715: [7125], 8710: [7125, 18684], 8719: [7067, 7101, 7125, 7342, 8068]} CompanyDupes = {8068: [8719], 7342: [8719], 7125: [8719, 8715, 8710], 7067: [8719], 18684: [8710], 7101: [8719]} [set([n]+PhoneDupes.get(n, [])+CompanyDupes.get(n, [])) for n in PhoneDupes] What should we do with these? Probably the exact same thing: import itertools def closure(inset, acc = set()): new = set(itertools.chain.from_iterable(itertools.chain(PhoneDupes.get(n, []),CompanyDupes.get(n, [])) for n in inset)) really_new = (new - inset) - acc if not really_new: return

Categories : Python

How do I delete field values of a table once window is closed?
The best way to do this is to use cron. Code the php script that will do the clean up and set up cron to run it every x minutes, hours to run it for you. http://net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2/ Another option could be using ignore_user_abort() depending on how exactly you want to remove the data from the offender table http://php.net/manual/en/function.ignore-user-abort.php

Categories : PHP

AngularJS binding to nested model properties
I'm not quite sure if your trying to get a list property from the model or if you're trying to create a Dynamic Set Model? As for the list property that isn't very difficult just append an array to the model or even append some object with a list property. Multiple Models Or are you looking to use multiple 'models'? function MyCtrl($scope, $filter) { $scope.Model = { SubModel : { // Submodel stuff }, FooModel : { // Submodel stuff } } } EDIT: I completely missed the point of the question my first try. The question really wanted to render different content based on a property's type (if that's not what you wanted I apologize) Plunker Example HTML <div ng-app ng-controller="MyCtrl"> <div ng-i

Categories : Javascript

ModelMetadata.FromStringExpression doesn't work on nested properties
You have to create a new custom HtmlHelper class that uses a new Model or new ViewData, so : public static class CustomHtmlHelperExtensions { public static HtmlHelper CustomHtmlHelper(this HtmlHelper helper, Object model) { ViewDataDictionary customViewData = new ViewDataDictionary(helper.ViewData) { Model = model }; ViewDataContainer customViewDataContainer = new ViewDataContainer(customViewData); ViewContext customViewContext = new ViewContext(helper.ViewContext.Controller.ControllerContext, helper.ViewContext.View, customViewData, helper.ViewContext.TempData, helper.ViewContext.Writer); return new HtmlHelper(customViewContext, customViewDataContainer, helper.RouteCollection); } private class ViewDataContainer : IViewDataCo

Categories : Asp Net Mvc

How to optimize a SQL query showing 2 adjacent rows with closed in values timestamps?
may be you can simply your query by using subquery select b1.create_stamp as st1, b2.create_stamp as st2, b1.request_id as b1_id, b2.request_id as b2_id, msi1, msi2, (msi1 - msi2) as diff from ( select * , Cast(date_part('milliseconds', create_stamp) as Integer) as msi1 from request ) b1 , ( select * , Cast(date_part('milliseconds', create_stamp) as Integer) as msi2 from request ) b2 where (b1.request_id - b2.request_id) = 1 and (msi1 - msi2) < 100 and (msi1 - msi2) > 0 order by b1.request_id;

Categories : SQL

Dynamic linq order by on nested property with null properties
static void Main(string[] args) { var data = new List<MyType>() { new MyType() { SomeProperty = new Inner() { NestedProperty = "2" }}, new MyType() { SomeProperty = new Inner() { NestedProperty = "1" }}, new MyType() { SomeProperty = new Inner() { NestedProperty = "3" }}, new MyType(), }.AsQueryable(); var sorted = data.OrderBy(x => GetPropertyValue(x, "SomeProperty.NestedProperty")); foreach (var myType in sorted) { try { Console.WriteLine(myType.SomeProperty.NestedProperty); } catch (Exception e) { Console.WriteLine("Null"); } } } public static object GetPropertyValue(object obj, string propertyName) { try { foreach (var prop in propertyName.Spl

Categories : C#

Finalizing a Cursor that has not been deactivated or closed or database not closed error
When you are done with the cursor, you need to call Cursor.close(). Leaving it not closed leads to memory leaks. E.g.: Cursor cursor = null; try { cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null); if (cursor != null && cursor.moveToFirst()) { // moar code } } finally { if (cursor != null) { cursor.close(); } }

Categories : Android

PHP: Pull values foreach() nested array, run function, return a 2nd level nested array
foreach ($array as $key => $value){ $array[$key]['restaurants'] = work($value['id'],$value['name']); } function work($id,$name){ $results = array(); ///process data return $results; }

Categories : PHP

Application gets closed when terminal is closed, how to stop this?
Use nohup to prevent child processes from being killed when the terminal closes. spawn nohup /usr/bin/firefox https://www.google.com/ I assume there's more to the script, since there's no need to use Expect just to start firefox.

Categories : Python

Using CSS properties as input values
Remove the quotes around $(.preview).css("background") and also you need quotes around .preview inside the jquery selector: $('.preview').css("background") $('#custom-prev').attr('value', $('.preview').css("background"));

Categories : Javascript

How to draw closed spline 3D (closed curve 3d) through unordered list of points3D. How to arrange points3D?
It sounds like you're looking for the Concave Hull of the data set. Unfortunately, I don't know of any pre-canned algorithms, but the link references a paper that another developer was starting from, as well as some sample code, so maybe that'll help you in the right direction.

Categories : C#

Reading values from properties file
Here's how you access the properties: GetConfigProperties.ExtractUrlData(); This calls the static method ExtractUrlData() (which should be called extractUrlData() to conform to Java naming conventions). Nowhere do you call the GetConfigProperties() method of GetConfigProperties, which is where the Properties object is populated. You should choose: either the Properties is static, and it should be populated when the class is loaded, by a static method, or a static block: private static Properties props = createAndPopulateProperties(); or it should be an instance field, that can be populated by the class constructor or one of its instance methods that would initialize the object. Another problem is that there is a very low chance that the user running your app has the file in exactly

Categories : Java

applying !important to all properties' values once
No, but there is a better way. Make the selector more specific than the selector that you want to override. You can for example specify the element name in the selector to make it more specific: div.someclass { color: #f00; background-color: #ff0; margin: 0; padding: 0; width: 100%; display: block; } Not only is it simpler, it's also possible to further override this with an even more specific selector. Adding !important only works in one level. The specificity of a selector is basically calculated by the number of identifiers, the number of class names and the number of element names that it contains, in that order. For example a selector like div.item .cost with two class names and one element name is more specific than a selector like div span.count with one class name

Categories : HTML

How can I store a list of properties (not their values)?
Store the names of the properties instead and use setattr: obj = MyClass() prop_list = [ "prop1", "prop2", "prop3", "prop1", "prop3" ] setattr(obj, prop_list[0], something) If you really need the item assignment syntax, this is also possible with a custom class: class CustomPropertyList(object): def __init__(self, obj, names): self.obj = obj self.property_names = list(names) def __getitem__(self, item): return getattr(self.obj, self.property_names[item]) def __setitem__(self, item, value): setattr(self.obj, self.property_names[item], value) prop_list = CustomPropertyList(obj, ["prop1", "prop2", "prop3", "prop1", "prop3"]) prop_list[0] = something

Categories : Python

How to set and get values in Detail Properties of file? c#
Try below link this will help you to solve your problem:- http://www.codeproject.com/Articles/7987/Retrieve-detailed-information-of-a-File http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/bb887b05-2018-4978-b115-c8c98e3542ce

Categories : C#

Replace values in file with object properties
I do not completely understand, however it looks like those files are just legitimate XML files, therefore you can create your own XML crawler to do that. If that's not what you are looking for please elaborate the question. Here is some info: http://msdn.microsoft.com/en-us/library/cc189056(v=vs.95).aspx

Categories : C#

C# properties and how to access their values from another function/class?
In addition to the comments about setting up your class correctly. So you really want to do this or something like it: Client cli = new Client(); Employee emp = new Employee(); Patient pat = new Patient(); public bool eligibleAppointment() { cli.Client = "something"; emp.Employee = "something"; pat.Patient = "something"; DateTime DOB = pat.DOB; DateTime appt = cli.AppointmentDate; } Hops this get you going in the right direction.

Categories : C#

PropertyPlaceholderConfigurer to look for DB values and use properties file as fallback
PropertyPlaceholderConfigurer has a "properties" property that can point to an object that retrieves the database values. See an example here: http://pure-essence.net/2011/02/10/spring-loading-properties-from-database-with-a-twist/ Also, you'll want to set "ignoreUnresolvablePlaceholders" to true on the bean that config that loads the properties from the database. That way you can add another PropertyPlaceholderConfigurer as a fallback to provide properties that are not found in the database.

Categories : Java

Preferred way to set default values of nullable properties?
You can only ensure that null is never returned when you use the property: class Stuff { private String _SomeInfo; public String SomeInfo { get { return _SomeInfo ?? String.Empty; } set { _SomeInfo = value; } } } The same approach is used by text-controls(e.g. in ASP.NET) where the Text property never returns null but String.Empty. For example(ILSpy): // System.Web.UI.WebControls.TextBox public virtual string Text { get { string text = (string)this.ViewState["Text"]; if (text != null) { return text; } return string.Empty; } set { this.ViewState["Text"] = value; } }

Categories : C#

Outlook VBA-- Some MailItem Properties return values, others do not
Multiple Item Types First, there is no guarantee that all items in the Inbox.Items collection are of type MailItem. Inboxes also contain AppointmentItem, MeetingItem, and other *Item type objects. Not all of these item types have the same properties populated. To ensure you do not get a type mismatch error, declare your iterator variable as a generic Object and only assign it to a strongly-typed MailItem variable if it is of the correct type: Dim oInbox As Outlook.Folder Dim oItem As Object Dim oMailItem As MailItem Set oInbox = ActiveExplorer.Session.DefaultStore.GetRootFolder().Folders("Inbox") For Each oItem In oInbox.Items If TypeOf oItem Is MailItem Then Set oMailItem = oItem ' Do stuff Else Debug.Print "Skipping " & TypeName(oItem) En

Categories : Vba

Bltoolkit: How to cache values of instance properties
Heh, now that sounds like a joke :) Decided to look on the Russian-language forum where BLtoolkit originally appeared and found MY OWN 5 years old topic about the same problem: http://www.rsdn.ru/forum/prj.rfd/2966573.flat#2966573 Since that time solution was already implemented, that is another attribute: InstanceCacheAttribute :) Good luck! :)

Categories : C#

How should i create datacontract for a List of class which contain nested list of classes as properties
What you have in your example is fine and will automatically serialize correctly. I recommend attributing your classes with [DataContract] and your properties with [DataMember] for explicitness.

Categories : Wcf

Will calling a nested Navigation Property retrieve all the parent navigation properties?
You can see what query is executed in the SQL Server Profiler (if using SQL Server), or you can have a look at some Entity Framework Tracing Provider. http://code.msdn.microsoft.com/EFProviderWrappers-c0b88f32 This will give you lots of information and understanding...

Categories : Entity Framework

How to modify JNDI Custom Resources Properties Values on the fly
According to my understanding, the mailProperties resource is injected after the EJB is instantiated by the container which only occurs one time in the lifecycle of bean. Therefore, futures properties changes are not available to him. An alternative could be to try to lookup the mailProperties inside @Timeout method.

Categories : Java

How can I get index-parameter values from indexed properties via reflection?
No, there's no way of doing this - because it doesn't make sense to do so. Like properties, indexers are just methods with some extra metadata. So this: public int this[int x, int y] { get { return x * y; } } Is just like this: public int ComputeValue(int x, int y) { return x * y; } If the indexer has a setter, that's just another method with an extra parameter as the value being set. Look at the indexer above - what would you say the "indexed property values" are? It can work with any int values. That's certainly not a typical indexer, but it's entirely valid from a language perspective. If you're writing an indexer which only accepts some inputs, you can choose to expose that (just as Dictionary<,> exposes a Keys property) but it's up to you to do so.

Categories : C#

Parse into Properties with default values using Commons Digester
Well I figured out this can be done using the FactoryCreateRule class PropertiesFactory extends AbstractObjectCreationFactory<Properties> { Properties defaultProperties; public PropertiesFactory(Properties defaultProperties) { super(); this.defaultProperties = defaultProperties; } @Override public Properties createObject(Attributes attributes) throws Exception { return new Properties(defaultProperties); } } ... ... forPattern("properties").factoryCreate() .usingFactory(new PropertiesFactory(defaultProperties)); forPattern("properties/property") .callMethod("put").withParamCount(2) .withParamTypes(Object.class, Object.class).then() .callParam().fromAttribute("name").ofIndex(0).then() .callPa

Categories : Java

Setting property values based on other properties of same object
Cache the variable var $nav = $('#top_nav .nav'); Then you can use it multiple times in your code var $nav = $('#top_nav .nav'), $childrenLi = $nav.children('li'); var myApp = { nav : $nav , primary_navs : $childrenLi , secondary_navs : $childrenLi.find('.secondary > li') } You can also use children to get the immediate children. $('#top_nav .nav').find('> li') same as $('#top_nav .nav').children('li')

Categories : Javascript

Adding values from a dictionary to the object's properties when serializing to JSON
You need to create a converter for DTO class, not for its Items property, because you are modifying representation of the whole object. class DtoConverter : JsonConverter { public override void WriteJson (JsonWriter writer, object value, JsonSerializer serializer) { var dto = (Dto)value; var jobj = JObject.FromObject(dto); foreach (var item in dto.Items) jobj[item.Key] = item.Value; jobj.WriteTo(writer); } public override object ReadJson (JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { throw new NotImplementedException(); } public override bool CanConvert (Type objectType) { return typeof(Dto).IsAssignableFrom(objectType); } } Usage (note JsonIgnoreAtt

Categories : Asp Net Mvc

Cargo unable to set the system properties values during bean injection
I realized the fault. I was not using @Inject in my TokenUtils constructor. The following change fixed it @Inject public TokenUtils(@Nonnull @Configuration(BB_AUTH_PRIVATE_KEY) final String serverPrivateKey, @Configuration(BB_AUTH_VALIDITY) final long validity) { this.serverPrivateKey = serverPrivateKey; this.validity = validity; LOGGER.info("serverPrivateKey:" + serverPrivateKey); LOGGER.info("validity:" + validity); } With that I could see values in logs as following [INFO] [talledLocalContainer] 06:39:30,042 INFO [com.org.proj.commons.cdi.config.ConfigurationProvider] (http--0.0.0.0-9090-1) getProperty(auth.key) is secure [INFO] [talledLocalContainer] 06:39:30,043 INFO [com.org.proj.commons.cdi.config.ConfigurationProvider

Categories : Java

How do dependency/attached properties work internally and where are values stored?
The property system in WPF is pretty complex. MSDN really has a lot of information, but it is often hard to find. While there are many ways a DependencyProperty can be set, I'm not sure that you need to care where the values are stored. For local values, you can assume that it is stored on the DependencyObject (again you shouldn't care where it is stored), with the caveat that they are not stored based on strings. It truly is associated with an instance of DependencyProperty. This is why you would want to add an owner to the property. If somebody sets TextElement.FontSize on your control, it is just like setting your local FontSize property. As far as inheriting values for a property from a parent, this only happens with attached properties. From the MSDN entry for FrameworkPropertyMeta

Categories : Wpf

Setting default values for inherited properties on a custom control in WPF
Please take a look at the Control Authoring Overview page on MSDN for a complete answer to your question. However, in short, for a CustomControl, you should create a folder in your application root directory named Themes. You should add a XAML file named Generic.xaml into this folder and you should put a ControlTemplate for your CustomControl in there. For a UserControl, you can just add your Styles into the UserControl.Resources section of the page.

Categories : Wpf

Access to nested map's values
You have lost type information. You could actually do what you want, but it's not typesafe. m.get(2).flatMap{ case m2: Map[Int, _] => m2.get(3) } Since you have lost type information you have to cast explicitly, so if you want to get list's element you should do something like this: m.get(2).flatMap{ case m2: Map[Int, _] => m2.get(4) }.map{ case l: List[_] => l(1) } You should try to save type information. At least you could use Either.

Categories : Scala

The underlying connection was closed: The connection was closed unexpectedly wcf service
The first thing i will do is, instead of returning the full list of candidates i will return an empty list. If that works fine, then it is very clear that the size of the data is a problem. To modify the size play with your binding parameters.

Categories : Wcf

setting values of nested objects
If my understanding is correct that you need an object as a property of another object, use Ember.Object.create() for your subObject to create an instance. Now you can go out with your way as TopObject.create({subOject: {prop: 'value'}}); Here is a Little fiddling on your objects

Categories : Ember Js



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