[Seaside] Add button not showing it's page

Brian Brown rbb at techgame.net
Wed Jul 28 07:30:37 CEST 2004


On Tue, 2004-07-27 at 22:42, LK wrote:
> Sorry, I'm Larry Kelly. 
> 
> the addNewItem needs a #children method? What would go in it?  I'm 
> unclear what the #children method is for?  Sorry to be so dense.:)
> -Larry
> 

The #children method is a recent addition to Seaside; the renderer uses
it to determine what should be rendered. What goes in it are all the
components of a component (or subcomponents if you will).

For example, if you have a component ParentComponent that has two
instance variables; child1 and child2. For to make this really easy to
try, put an initialize method on ParentComponent:

initialize
	child1 := WACounter new.
        child2 := WACounter new.

Then in ParentComponent>>renderContentOn: 

renderContentOn: html
	html heading: 'Check out my children!' level: 3.
	html 
		render: child1;
		br;
		render child2.

In order for callbacks to work properly, in this case you would have a
#children like this:

children
	^ Array with: child1 with: child2



Please note that if you put sub components that have forms rendered from
the renderContent on of a component, they will show up fine even if not
being returned from #children. You just won't be able to actually submit
the forms without a traceback. :)

HTH,

Brian


> Julian Fitzell wrote:
> 
> > Hi s002,
> >
> > Say, do you have a name? :)
> >
> > So the problem below is that you are using a render method as your 
> > callback, which is not at all what you want to do.
> >
> > Every time a request comes in, the callbacks are executed and then the 
> > root component is obtained and asked to render itself to be displayed 
> > to the user.  Your callback needs to perform some action to cause the 
> > display state to change before the next render pass is executed.
> >
> > When you call #renderAddOn: in your callback, nothing changes that 
> > would cause PMLogsView to render itself any differently than the last 
> > time, which is why you see the same page drawn again.
> >
> > What you probably want to do here is have another component, say 
> > PMLogItemEditor, which you pass a new instance of PMLogItem into.  For 
> > example you could write an action method like:
> >
> > addNewItem
> >    |item|
> >    item := PMLogItem new.
> >    "store the item however you do that"
> >    self call: (self editorComponentFor: item)
> >
> > And then in your render method use:
> >
> > html anchorWithAction: [self addNewItem] text: 'Add'
> >
> > Obviously you'd have to implement a #children method as well as 
> > #editorComponentFor: to keep track of the editor component...
> >
> > Julian
> >
> > s002 wrote:
> >
> >> I have an object that shows a record from a GOODS database.  I 
> >> created a link to 'add' a new record.  When I click on the link, the 
> >> screen flashes and stays  at the recordlist page.  Can someone help me.
> >> PMLogsView>>renderContentOn: html
> >>     | |
> >>     html table: [
> >>         html tableRow: [html tableHeading: 'View all Log Entries'; 
> >> space; space; space.
> >>             html tableData: [html anchorWithAction: [self 
> >> renderAddOn: html] text: 'Add']]].
> >>     html attributeAt: 'cellspacing' put: 0; attributeAt: 
> >> 'cellpadding' put: 5; attributeAt: 'border' put: 2.
> >>     html table: [
> >>             allRecords do: [:i |
> >>                 html tableRow: [
> >>                     html tableData: [html anchorWithAction: [self 
> >> delete: i from: db] text: 'Del'].
> >>                     html tableData: i type.
> >>                     html tableData: i entryDate.
> >>                     html tableData: i startTime.
> >>                     html tableData: i entryText.
> >>                     html tableData: i endTime.
> >>             ].
> >>         ].
> >>         html tableRow: []
> >> ]
> >> ------
> >> and here is the
> >> PMLogsView>>renderAddOn: html
> >> " show add new log form"
> >>     aRecord := PMLogItem new.
> >>     aRecord initialize.
> >>     html form: [
> >>     html table: [
> >>         html tableRow: [html tableHeading: 'New Log Entry']].
> >>     html text: 'TEST NEW ENTRY PAGE'.
> >>     html text: aRecord entryDate.]
> >>     _______________________________________________
> >> Seaside mailing list
> >> Seaside at lists.squeakfoundation.org
> >> http://lists.squeakfoundation.org/listinfo/seaside
> >
> > _______________________________________________
> > Seaside mailing list
> > Seaside at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/listinfo/seaside
> >
> >
> 
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/listinfo/seaside



More information about the Seaside mailing list