[Nitro] Nitro/OG examples that show recommended ......

Walter Walter at mwsewall.com
Fri Sep 2 09:29:15 EDT 2005

See inline comments:

> > 1.) Passing data to/from controller variables/form fields.
> > I am assuming there are predefined "controls" that can take 
> the form data and validate it against certain constraints, 
> automatically convert the data to the desired format, and if 
> there is an error automatically populate the appropriate 
> error list tha
> t can be used to send the page back to the same page with 
> error messages. (similar to what Rails does with validation 
> errors for an AR object).
> yeap, this works almost exactly like AR validation. Have a look at 
> lib/glue/valdation.rb
> > Ideally this would also work with non OG managed classes as well????
> Yeap, unlike AR this works on non managed classes. 

OK.....I did look at that and will experiment with that, but are there "controls" already defined to work with them.  i.e Are there text fields that will automatically pull from the defined variable and to prefill the field, and then when posting automatically validates and set the data to the correct field.  If there are errors how does it display them? On the same page or is this configurable???

Is there a basic architecture document that might allow me to wrap my head around the theories of Nitro.

> > 2.) Is there a recommended directory layout for 
> views/controllers.  If I have 3 controllers and they all have 
> an index.xhtml page, is there a recommend place to put these 
> different files.
> Nitro, unlike Rails does not force a directory structure. But If you
> like it, you can use the structure of Flare.

Fair enough.

> > 3.) An example of OG using compound primary keys, 
> especially with belongs_to, or other relations, especially 
> when dealing with a legacy database via an ODBC driver.
> have a look at:
> test/og/tc_reverse.rb

I did look at this and dug deeper into the OG source code.  And while it does look like it can handle a legacy schema fairly well,
I don't believe it currently works with compound primary keys.  Everywhere in the source it refers to a pk field, it does not seem to allow for an array of these.  Or have I just totally misunderstood something fundamental.

> > 4.) An example of OG using sub-objects i.e. Person is an OG 
> managed class and it has an Address(line1, line2, city, st, 
> zip).  So you could have 
> Person.find_something[0].address.city.  Is this even possible with OG
> of course, it works just how you describe this :)

Cool....I guess the only part I am missing is how to describe this?  And are there requirements that they be set in the constructor or can they be set after object creation vie assessor fields.

I have a table like
Create table Customer(name varchar, seq_no int, other_fields varchar, addr1 char(30), addr2 char(30), city char(15), st char(2), zip char(10), more_fields varchar)

And Ruby classes ...

class Address
    attr_accessor :line1, :line2, :city, :state, :zip
    def to_s

Class Customer
  property :name, String
  property :seq_no, Integer
  property :other_fields, String
  property :address, Address #how do a assign the fields in the table to the address object 
  property :more_fields, String

I am missing how I tell OG to map the fields to the sub-object Address contianed by Customer.

My problem is that many times I am looking at things one way when they are really meant to be looked at another way.  If I can get my head in the correct context, I can manage just fine, but sometimes starting out I have a totally wrong approach.  I am trying to align my thinking with the inteded design/usage patterns for Nitro/OG.



No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.17/85 - Release Date: 8/30/2005

More information about the Nitro-general mailing list