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.]
On Jul 26, 2004, at 9:34 AM, 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: [] ]
You don't want two methods on the same class here, you want two different classes. So your #renderAddOn: method should be the #renderContentOn: of a PMLogsAddItem component. And then your 'Add' link should be this:
html anchorWithAction: [self call: PMLogsAddItem new] text: 'Add'.
Does that make sense?
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@lists.squeakfoundation.org http://lists.squeakfoundation.org/listinfo/seaside
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@lists.squeakfoundation.org http://lists.squeakfoundation.org/listinfo/seaside
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
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@lists.squeakfoundation.org http://lists.squeakfoundation.org/listinfo/seaside
Seaside mailing list Seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/listinfo/seaside
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@lists.squeakfoundation.org http://lists.squeakfoundation.org/listinfo/seaside
Seaside mailing list Seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/listinfo/seaside
Seaside mailing list Seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/listinfo/seaside
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
Hi Larry, not a problem.
So a component's #children method is supposed to return an array of all the subcomponents it is currently displaying within itself.
Unfortunately it was me who was being dense for even mentioning it in this context: you don't need to implement a #children method when you call another component. I think I must have confused myself between what you had been trying to do and the solution I was suggesting for you.
You could probably ignore all the #editorComponentFor: stuff I was talking about as well as #children for now and just implement addItem more like:
addItem self call: (PMLogItemEditor new item: PMLogItem new)
(noting again that you need to do something with the new item to store it somewhere presumably).
To explain #children a little more, since I brought it up, let's look at WAMultiCounter as an example that needs to implement #children. It's render method looks like:
renderContentOn: html counters do: [:ea | html render: ea] separatedBy: [html horizontalRule]
and it implements #children as follows:
children ^ counters
Seaside uses #children when handling callbacks, decorations, etc. to make sure each of the embedded components has its chance to do processing. You can see some weird behaviour if you don't have #children properly defined in those cases.
Cheers,
Julian
seaside@lists.squeakfoundation.org