I've got an "admin" sort of component for a set of code I'm working on,
and I was wondering if I have the "admin" component initially put up a list of anchors/links with callbacks to specific functionality (e.g. add organization, edit organization, etc), is there a way to allow the anchor's callbacks to temporarily bring up a new view (that has its own forms, etc) if you will -- similar to using the #call setup, but without using a new object that has it's own #renderContentOn: method defined? If I go that route (which seems reasonable, but tedious), I'll have separate components for each function I'm looking to do (one for "add organization", one for "edit organization", etc).. Ideally in my case, each of these functions (e.g. add organization) will have its own form and relevant processing, etc.. I'm guessing the proper way to do this is to use the #call/#answer setup, but thought I'd check to see if there's a way to do it without creating all of the extra components. Thanks! -- Rick _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
You could also have your components rendering slightly different for users
with varying privileges, ... self user isAdmin ifTrue: [html input value: username; callback: [:v | username := v]] ifFalse: [html text: username]. ... But I'd say different views often warrant components of their own. Depending on your composition, you could also insert admin-type child component into your standard views. ... self user isAdmin ifTrue: [html render: adminpanel] ... Hope this helps, -Boris -- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5 [hidden email] CONFIDENTIALITY NOTICE This email is intended only for the persons named in the message header. Unless otherwise indicated, it contains information that is private and confidential. If you have received it in error, please notify the sender and delete the entire message including any attachments. Thank you. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Rick Flower Sent: Thursday, August 10, 2006 2:37 PM To: Seaside Mailing List Subject: [Seaside] Using one component to render multiple views? I've got an "admin" sort of component for a set of code I'm working on, and I was wondering if I have the "admin" component initially put up a list of anchors/links with callbacks to specific functionality (e.g. add organization, edit organization, etc), is there a way to allow the anchor's callbacks to temporarily bring up a new view (that has its own forms, etc) if you will -- similar to using the #call setup, but without using a new object that has it's own #renderContentOn: method defined? If I go that route (which seems reasonable, but tedious), I'll have separate components for each function I'm looking to do (one for "add organization", one for "edit organization", etc).. Ideally in my case, each of these functions (e.g. add organization) will have its own form and relevant processing, etc.. I'm guessing the proper way to do this is to use the #call/#answer setup, but thought I'd check to see if there's a way to do it without creating all of the extra components. Thanks! -- Rick _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside smime.p7s (4K) Download Attachment |
Boris Popov wrote:
> You could also have your components rendering slightly different for users > with varying privileges, > > ... > self user isAdmin > ifTrue: [html input value: username; callback: [:v | username := v]] > ifFalse: [html text: username]. Yup.. I've got logic in for that sort of thing now -- which works rather well -- currently I use it mostly for which hyperlinks to display in the top link-bar -- admin users get a different set than average-joe users do. > But I'd say different views often warrant components of their own. Depending > on your composition, you could also insert admin-type child component into > your standard views. I think in my case, many of my views (for lack of a better term) are not going to be very complex and will consist mostly of forms+validation and writing to my Glorp tables. I was just trying to reduce the amount of classes I've got if there wasn't a need to split out functionality. Thanks! _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Rick Flower
Dear Rick,
It may not be necessary to have lots of different components, if you have ever looked at SUnit, there is one class, but each time you instanciate an instance you indicate which test case you want that instance to run. The test case is run according to its selector. This piece of smalltalk trickery is handled by Object>>#perform: aSelector I tried the attached code, in which callbacks are able to switch the viewSelector and it seemed to work quite well. Keith ---- 'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 11 August 2006 at 1:53:51 am'! WAFrameComponent subclass: #WAMultipleViewComponent instanceVariableNames: 'viewSelector' classVariableNames: '' poolDictionaries: '' category: 'Magma seaside'! !WAMultipleViewComponent methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:26'! renderContentOn: html ^self perform: self viewSelector with: html! ! !WAMultipleViewComponent methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:30'! rendererClass ^ WARenderCanvas! ! !WAMultipleViewComponent methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:28'! setView: viewName ^ viewSelector := ('render' , viewName capitalized , 'On:' ) asSymbol ! ! !WAMultipleViewComponent methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:25'! viewSelector ^ viewSelector ifNil: [ #renderViewOn: ]! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! WAMultipleViewComponent class instanceVariableNames: ''! !WAMultipleViewComponent class methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:27'! view: viewName ^ self new setView: viewName; yourself! ! 'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 11 August 2006 at 1:53:57 am'! WAMultipleViewComponent subclass: #WAMultipleViewTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Magma seaside'! !WAMultipleViewTest methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:47'! renderAddOrganisationOn: html html heading: 'Add Organisation'. html anchor callback: [ self setView: 'View' ]; text: '(done)'.! ! !WAMultipleViewTest methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:36'! renderConfigOn: html self renderViewOn: html. html horizontalRule. html break; text: 'configuration options: '. html anchor callback: [ self setView: 'EditOrganisation' ]; text: '(edit organisations)'. html anchor callback: [ self setView: 'AddOrganisation' ]; text: '(add organisation)'.! ! !WAMultipleViewTest methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:47'! renderEditOrganisationOn: html html heading: 'Edit Organisation'. html anchor callback: [ self setView: 'View' ]; text: '(done)'.! ! !WAMultipleViewTest methodsFor: 'as yet unclassified' stamp: 'kph 8/11/2006 01:41'! renderViewOn: html html heading: 'Default View'. html break; text: 'nothing doing'. ! ! _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Keith Hodges wrote:
> Dear Rick, > > It may not be necessary to have lots of different components, if you > have ever looked at SUnit, there is one class, but each time you > instanciate an instance you indicate which test case you want that > instance to run. The test case is run according to its selector. > > This piece of smalltalk trickery is handled by Object>>#perform: aSelector > > I tried the attached code, in which callbacks are able to switch the > viewSelector and it seemed to work quite well. Thanks Keith! I'll check that out when I get home, but it looks like what I was looking for.. That should keep me from having a bunch of needless components lying around.. I'm constantly amazed at the interesting things that Smalltalk can easily do, but which other languages either are incapable of doing or not without some really ugly hacks.. Thanks again! -- Rick _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
You can use the multiview component from a link... like so
html anchor callback: [ self call: (WAMultipleViewTest view: 'config') ] text: '(configuration demo)'. This will render the multiple view component as a page showing the 'Config View'. The rendering of this view includes link/buttons that can change the view. html anchor callback: [ self setView: 'EditOrganisation' ] text: '(edit)'. this will re-render the page but with an alternative view. ===== You can also use the multiview component embedded in any other component using #render: MyComponent>>renderContentOn: html some html gen here html render: configTestComponent some more html gen here. ======== To do this the component needs to be registered as one of the children of the containing component. i.e. MyComponent>>initialize super initialize configTestComponent := WAMulipleViewTest view: 'config'. MyComponent>>children ^ Array with: configTestComponent. ========== hope this helps Keith Rick Flower wrote: > Keith Hodges wrote: >> Dear Rick, >> >> It may not be necessary to have lots of different components, if you >> have ever looked at SUnit, there is one class, but each time you >> instanciate an instance you indicate which test case you want that >> instance to run. The test case is run according to its selector. >> >> This piece of smalltalk trickery is handled by Object>>#perform: >> aSelector >> >> I tried the attached code, in which callbacks are able to switch the >> viewSelector and it seemed to work quite well. > > Thanks Keith! I'll check that out when I get home, but it looks like > what I was looking for.. That should keep me from having a bunch of > needless components lying around.. I'm constantly amazed at the > interesting things that Smalltalk can easily do, but which other > languages either are incapable of doing or not without some really > ugly hacks.. Thanks again! > > -- Rick > _______________________________________________ > Seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > ___________________________________________________________ All New Yahoo! Mail Tired of Vi@gr@! come-ons? Let our SpamGuard protect you. http://uk.docs.yahoo.com/nowyoucan.html _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Rick Flower
Hi
I'm not sure but maybe you could use magritte for that... If you have descriptions on your model's classes, you can automaticly build components that will be rendered by seaside with the command: aModel asComponent For instance you can have a seaside interface with validanting form with the command: result := self call: (aModel asComponent addValidatedForm; yourself). see the slides from Lukas here: http://www.lukas-renggli.ch/smalltalk/magritte/tutorial.pdf http://www.lukas-renggli.ch/smalltalk/magritte Cédrick _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Cédrick Béler wrote:
> Hi > > I'm not sure but maybe you could use magritte for that... > If you have descriptions on your model's classes, you can automaticly > build components that will be rendered by seaside with the command: Thanks Cedrick.. I might do that if I decide to use Magritte in the future. For now, I was able to get Keiths suggestion going and it works great. In my case, I've got a unique base class that all of my components inherit from (my base consequently inherits from WAComponent if I recall).. Anyway, for these multi-view components, all I had to do was to remove my standard #renderContentOn: method and swap out who the parent class was and a few other odds-n-ends and all worked pretty well. All I really need to do is to fill in the meat of the forms et-al and I'm good to go! Thanks! _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |