Thanks for all the support. You guys are the greatest! I now have an app that will add and delete records from a GOODS database. My problem now is they added records are not showing in the PMLogsView when I refresh my browser. The user must close and re-open the browser to see the changes. Is there a way to fix this?
-Larry
Relevent code is below:
PMLogsTask>>renderContentOn: html
|db | html cssId: 'banner'. html table: [ html tableRowWith: [ html divNamed: 'title' with: self title. html divNamed: 'subtitle' with: self subtitle. ] ]. html render: pmLogsView. html text: 'testing'.
----- PMLogsView>>renderContentOn: html | | html table: [ html tableRow: [html tableHeading: 'View all Log Entries'; space; space; space.]]. html anchorWithAction: [self call: PMLogAddItem new] 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: [] ] ----------- PMLogAddItem>>renderContentOn: html " show add new log form" item := PMLogItem new. item initialize. html form: [ html table: [ html tableRow: [html tableHeading: 'New Log Entry']. html tableRow: [html tableData: 'Date'. html tableData: item entryDate]. html tableRow: [html tableData: 'Time'. html tableData: item startTime]. html tableRow: [html tableData: 'Type'. html tableData: [html selectFromList: #('DRE' 'SA' 'DBA' 'TEST') selected: (item type) callback: [:i | item type: i]]]. html tableRow: [html tableData: 'Entry Text'. html tableData: [ html textAreaWithValue: 'log entry' callback: [:i| item entryText: i]]]. ]. html submitButtonWithAction: [self add: item] text: 'Save'. ]
--------- PMLogAddItem>>add: aRecord db _ PMDatabase new connect. self table: (db root at: 'logs'). table add: aRecord. db commit. db flush. db logout. self answer. -----
I suspect that the problem is the "allRecords" instance variable in PMLogsView. Where does that get filled in? You will have to refresh it each time you render the component. An alternative is to have your database connection stored in your Seaside session. Then you only have to worry about flushing that view periodically so you see other session's changes to the database. The tutorial Avi mentioned shows you how to do this.
David
LK wrote:
Thanks for all the support. You guys are the greatest! I now have an app that will add and delete records from a GOODS database. My problem now is they added records are not showing in the PMLogsView when I refresh my browser. The user must close and re-open the browser to see the changes. Is there a way to fix this?
-Larry
Relevent code is below:
PMLogsTask>>renderContentOn: html
|db | html cssId: 'banner'. html table: [ html tableRowWith: [ html divNamed: 'title' with: self title. html divNamed: 'subtitle' with: self subtitle. ] ]. html render: pmLogsView. html text: 'testing'.
PMLogsView>>renderContentOn: html | | html table: [ html tableRow: [html tableHeading: 'View all Log Entries'; space; space; space.]]. html anchorWithAction: [self call: PMLogAddItem new] 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: [] ]
PMLogAddItem>>renderContentOn: html " show add new log form" item := PMLogItem new. item initialize. html form: [ html table: [ html tableRow: [html tableHeading: 'New Log Entry']. html tableRow: [html tableData: 'Date'. html tableData: item entryDate]. html tableRow: [html tableData: 'Time'. html tableData: item startTime]. html tableRow: [html tableData: 'Type'. html tableData: [html selectFromList: #('DRE' 'SA' 'DBA' 'TEST') selected: (item type) callback: [:i | item type: i]]]. html tableRow: [html tableData: 'Entry Text'. html tableData: [ html textAreaWithValue: 'log entry' callback: [:i| item entryText: i]]]. ]. html submitButtonWithAction: [self add: item] text: 'Save'. ] --------- PMLogAddItem>>add: aRecord db _ PMDatabase new connect. self table: (db root at: 'logs'). table add: aRecord. db commit. db flush. db logout. self answer.
Seaside mailing list Seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/listinfo/seaside
C. David Shaffer wrote:
I suspect that the problem is the "allRecords" instance variable in PMLogsView. Where does that get filled in? You will have to refresh it each time you render the component. An alternative is to have your database connection stored in your Seaside session. Then you only have to worry about flushing that view periodically so you see other session's changes to the database. The tutorial Avi mentioned shows you how to do this.
David
allRecords get filled in: PMLogsView>>initialize db _ self connect. allRecords _ db root at: 'logs'.
I added 'db refresh' to the top of PMLogsView>>renderContentOn: ... It seems to do the trick. But, I was wondering if there was a better way. -Larry
LK wrote:
Thanks for all the support. You guys are the greatest! I now have an app that will add and delete records from a GOODS database. My problem now is they added records are not showing in the PMLogsView when I refresh my browser. The user must close and re-open the browser to see the changes. Is there a way to fix this?
-Larry
Relevent code is below:
PMLogsTask>>renderContentOn: html
|db | html cssId: 'banner'. html table: [ html tableRowWith: [ html divNamed: 'title' with: self title. html divNamed: 'subtitle' with: self subtitle. ] ]. html render: pmLogsView. html text: 'testing'.
PMLogsView>>renderContentOn: html | | html table: [ html tableRow: [html tableHeading: 'View all Log Entries'; space; space; space.]]. html anchorWithAction: [self call: PMLogAddItem new] 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: [] ]
PMLogAddItem>>renderContentOn: html " show add new log form" item := PMLogItem new. item initialize. html form: [ html table: [ html tableRow: [html tableHeading: 'New Log Entry']. html tableRow: [html tableData: 'Date'. html tableData: item entryDate]. html tableRow: [html tableData: 'Time'. html tableData: item startTime]. html tableRow: [html tableData: 'Type'. html tableData: [html selectFromList: #('DRE' 'SA' 'DBA' 'TEST') selected: (item type) callback: [:i | item type: i]]]. html tableRow: [html tableData: 'Entry Text'. html tableData: [ html textAreaWithValue: 'log entry' callback: [:i| item entryText: i]]]. ]. html submitButtonWithAction: [self add: item] text: 'Save'. ] --------- PMLogAddItem>>add: aRecord db _ PMDatabase new connect. self table: (db root at: 'logs'). table add: aRecord. db commit. db flush. db logout. self answer.
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:
allRecords get filled in: PMLogsView>>initialize db _ self connect. allRecords _ db root at: 'logs'.
I added 'db refresh' to the top of PMLogsView>>renderContentOn: ... It seems to do the trick. But, I was wondering if there was a better way. -Larry
Again, I'd put the database in the session then your entire session would see the same view of the database. See Brian Brown's tutorial at http://www.techgame.net/projects/Seaside/wiki/UsingGOODS.
David
On Aug 3, 2004, at 7:54 AM, C. David Shaffer wrote:
LK wrote:
allRecords get filled in: PMLogsView>>initialize db _ self connect. allRecords _ db root at: 'logs'.
I added 'db refresh' to the top of PMLogsView>>renderContentOn: ... It seems to do the trick. But, I was wondering if there was a better way. -Larry
Again, I'd put the database in the session then your entire session would see the same view of the database. See Brian Brown's tutorial at http://www.techgame.net/projects/Seaside/wiki/UsingGOODS.
Yeah, let me second that. There's no reason to open a brand new database connection each time you create a component (well, maybe not *no* reason, I can see it if you're playing complicated transactional games), and it's just going to complicate things. Either pass the db instance from component to component, or store it somewhere like the session where they can all get at it.
Avi
C. David Shaffer wrote:
LK wrote:
allRecords get filled in: PMLogsView>>initialize db _ self connect. allRecords _ db root at: 'logs'.
I added 'db refresh' to the top of PMLogsView>>renderContentOn: ... It seems to do the trick. But, I was wondering if there was a better way. -Larry
Again, I'd put the database in the session then your entire session would see the same view of the database. See Brian Brown's tutorial at http://www.techgame.net/projects/Seaside/wiki/UsingGOODS.
David
Thanks to both you and Avi. I'll work through the tutorial. -Larry
Seaside mailing list Seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/listinfo/seaside
seaside@lists.squeakfoundation.org