Re: [pidget-devel] new bindings
Brought to you by:
lkehresman
From: David W. <dj...@ne...> - 2003-10-19 17:19:59
|
Luke Ehresman wrote: >On Sat, Oct 18, 2003 at 09:51:55PM -0400, David Whittington wrote: > > >>Indeed. We need to be able to retrieve information from widgets after a >>... [snip] ... >>assigned to the widget. What do people think? Is it a worthy idea? >> >> > >I think that's a good idea for assigning names to widgets, but I'm a bit >skeptical about what happens after post. As far as setting names, it >could be another parameter of the constructor, and at render-time, the >names could get concatinated together with parent names. Example: > > $fnEditbox = new pEditbox($form, "FirstName"); > $lnEditbox = new pEditbox($form, "LastName"); > >That all works fine, I think. But after the form has been posted, how >do we retrieve the values from $_POST? They could do it manually, but >that is less than ideal. I would really like to have an object >interface that gets loaded on form post which contains some easy way to >get the data. Preferrably without having to know the names of the >widgets themselves. > >What I'm thinking is something like this: At the top of a page that has >some values in the $_POST variable, an object heierarchy will be created >of pData objects. The pData object would have methods like: > GetData(); > GetType(); > GetName(); > GetChildren(); >This way, to use your example of the contact manager, To fetch >information after a post with two contact widgets on the same page, they >would receive a pData widget heierarchy that would look like this: > > pData[page] > | > +-- pData[contact1] > | | > | +-- pData[firstname] > | +-- pData[lastname] > | +-- pData[phone] > | > +-- pData[contact2] > | > +-- pData[firstname] > +-- pData[lastname] > +-- pData[phone] > >Would something like that work? >Luke > > Oops! I left part out. That's what I get for writing an email while playing Nethack. I was figuring each widget would have static members for retrieving it's date. For example you could do something like this: $contact1Name = pContactWidget::getContactName("widgetName"); $contact1Address = pContactWidget::getContactAddress("widgetName"); $contact1Phone = pContactWidget::getContactName("widgetName"); Or, on second thought maybe we would do something like this: $contact1Name = pContactWidget::getRequestValue("widgetName", "Name"); $contact1Address = pContactWidget::getRequestValue("widgetName", "Address"); $contact1Phone = pContactWidget::getRequestValue("widgetName", "Phone"); That way we would have only one function to deal with. I see two advantages to doing it this way. First, it will avoid a lot of overhead. A large form could instantiate a lot of objects if we require that an object is instanciated for each form value. Also, this will give widgets more control over how the data is presented to the client application. If a person wants to write a contact widget that spits out contact object in addition to or instead of regular string values they can do so. Any thoughts? -- David "Spartacus" Whittington |