parent-child

How to pass messages from a child user-control to the parent

This is a Windows Forms / .Net C# question. I have a borderless windows whose transparency key and background color make it completely transparent. Inside the window are a couple of user controls. I want to be able to move the window. I know how to do this on the parent window, but my problem is that the child controls are the only t...

Ruby on Rails: Creating child objects

I'm sure this is a very simple question, but I'm just a newbie so... I have a model, Game, which has_many :piles. Pile, in turn, has_many :cards. I'm able to populate the Piles and Cards at creation of the Game, so my code at present looks something like: class Game < ActiveRecord::Base has_many :piles def after_create 1.upto(...

Ruby-on-Rails: Validating uniqueness (or number of) child objects

I have a model, Game, which has_many :piles. In fact, I know that each Game has exactly 4 piles, each of which has a different (at the scope of the Game) contents. My web-form for creating a Game allows the user to pick the four contents (as c_type_#). I'm therefore able to populate the Piles at creation of the Game. However, I can't fig...

JPA parent child delete problem

I have two entities: @Entity public class Game implements Serializable{ @ManyToOne @JoinColumn(name = "target_id") protected GameObject target; } @Entity public class GameObject implements Serializable { @OneToMany(mappedBy = "target", cascade = CascadeType.ALL) protected Collection<Game> games = new HashSet<Game>(); } In one t...

SQL Server: How to select second-highest parentid?

I have a SQL Server database with these pages: +------------+--------------+-------------------------------+ | pageid | parentid | title | +------------+--------------+-------------------------------+ | 1 | null | Home | +------------+--------------+----------...

Ruby on Rails: multiple acts_as_list directives for the same parent-child pair

I am developing a card game server, for a game where each player has a deck and a discard pile. To reflect the fact that a given card could be located in a player's deck or their discard pile, I have my Player model set up as follows: class Player < ActiveRecord::Base belongs_to :game has_many :deck_cards, :class_name => "Card", ...

Creating a set number of child objects from a parent's form

Thanks to http://stackoverflow.com/questions/2020673 and "Agile Web Dev", I know how to have multiple models in a form using fields_for. But I'm tearing my hair out over this one. Suppose I have a model Person. Person has a name attribute, and has_many :foos. The Foo model, in turn, has a colour attribute. Furthermore, I know that each...

Called child´s constant not available in static funcion in parent

I have a static function in a class that needs to be called from several child classes. I need a constant from the calling child class to be available in that function. To have these constants available in other places, the child classes have a function that returns the value of that constant (php 5.2.9). However, when in the parent cla...

c# parent-child property protection

Hello, Here are two classes with a parent/child relation (taken from Unity3D) public class GameObject { ... public T AddComponent<T>() where T : Component; ... } public class Component { ... public GameObject gameObject { get; } ... } Since only the getter is public, how do they acheive to set the value of ...

Calling method from child class

Hello, In Silverlight / C#, I have class Main, which creates an instance of Child, Child _child = new Child(...) Now, in Child class I need to call a method from Main class. What should be the best way to do this ? Events? ...

Targeting the parent div with jQuery

So, here's my situation. I have a wordpress site, and each entry has a link within the post div. <div class="post" id="post-133"> <h2><a href="post-link" rel="bookmark" title="Link to Post">Post</a></h2> <div class="post-date"> <span class="date">Tuesday, Jan. 26, 2010</span><span class="right read"><a href="#" class="noprint show_s...

.NET / SQLite. Inserting parent/child record; how do I get the foreign key?

I use VS 2008 (C#) and SQLite via ADO.NET 2.0 Provider (SourceForce project). The database used by application contains an "employees" (parent) and "employmentHistory" (children) datatables. "eploymentHistory" datatables is supposed to contain all the working contracts for any given employee from day 1 (e.g. a promotion will generate a ...

C# Winforms Parent Child Instances

In my application... to navigate between winforms what i do is that i make an object of the form that needs to be shown and i use Register reg = new Register() reg.show(); this thing has two problems if i do it with a button, more than one instance of same form could be opened. if i close through which the instance was created, th...

Android ListView - Making the parent expand to show all children when addingListViews within ListViews

Basically, I have a custom ListView in which each item looks like: <LinearLayout> <Table> <Row> <TextView/> <Button /> </Row> </Table> <ListView /> </LinearLayout> The ListView in each item is GONE by default and is set to VISIBLE when the button is clicked. Everything seems to work fine with the exception that when the ListView is...

How can I create a parent/child relationship with the same object with AutoPersistenceModel

I have the following class in my project public class ProductCategory { public virtual Guid Id { get; set; } public virtual string UrlSlug { get; set; } public virtual string Title { get; set; } public virtual bool IsActive { get; set; } public virtual IList<Product> Products { get; set; } public virtual ProductCategory Par...

Need beginner's explanation for the difference between using a parent-entity relationship versus ReferenceProperty

In regards to this statement in Google's app-engine doc: "Only use entity groups when they are needed for transactions. For other relationships between entities, use ReferenceProperty properties and Key values, which can be used in queries." can someone give an example of a query of say getting all the players that are member of the sa...

Accessing parentViewController's variables

I want to allow a pushed to set parentViewController's instance variables. For instance, VC1 (the parent) has a bunch of textfields and what not which are filled from VC2 (the child). VC2 is pushed onto the stack by VC1. I've tried doing like parentViewController.myString = "foo"; however since parentViewController is a UIViewController,...

How do I override the automapping for a composite Id, one to many relationship with fluent nhibernate?

I'm polling mulitple systems (domains) for security info so I'm dealing domainUsers and their roles. I've got my entities setup as show below, but I'm having trouble setting up the domainUser.HasMany relationship in the AutoMapper override. You'll notice that I don't have domainUser.DomainUserId and role.RoleId which make this much m...

Access a variable in a child flash file through a parent flash file using javascript

I have the need to change a variable in a child flash file. The setup is a parent flash file has called a child flash, and placed it in movieclip. I can send a variable using Javascript to the parent flash file, but not directly to the child flash file. Is there a way that I can access the child flash file directly with javascript? O...

Problems updating/inserting with Linq-to-SQL + child relationships

Hi, I'm learning LINQ, and am having trouble with inserting and updating in one go. I have a StatusReport table (School, Customer, Time), where School is the primary key, and a Service table (School, ServiceName, State, and Version), where School is a foreign key, and School + ServiceName is the primary key. Here's my update code: pub...