Rendering descendant of PRCase

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Rendering descendant of PRCase

Dennis Schetinin

Is there any "correct'" way to render classes inhereted from PRCase? Here are the details:

I want to represent an object, say Clinic with fullDescription, address, etc. attributes. Currently I do such things the way I saw in Pier-Blog. I.e. I overloaded Person>>viewComponentClass to return PersonView. And there I do something like:

renderContentOn: html
    super renderContentOn: html.
    self renderFullDescriptionOn: html.
    self renderAddressOn: html.
    self renderDoctorsOn: html

It works ofcourse, but I feel there should be another way to explain Pier (or Magritte?) how to render Clinics as far as I described them.

And another part is about doctors. They are instances of Doctor which is surely inhereted from PRCase and properly described. I want to give a list of doctors in context of the clinic. Items of the list should represent some short form of doctors, I mean show some of Doctor's attributes. And when one of the doctors is selected I want all the information to be presented.

Now I do it just the same way:
  -  #renderDoctorsOn: outputs short information about each of them in context of the clinic
  -  full Doctors information is rendered by DoctorView component.

The question is just the same: I feel there must be another way to do it using metainformation I give about Doctors (and Clinics). Is there a "canonized" one?

And one more thing: I saw people mentioned "Tutorial" but I don't know where to get it. Perhaps it's where all answers are already given? :)

--
Dennis Schetinin


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering descendant of PRCase

Lukas Renggli
On Fri, Feb 13, 2009 at 4:52 PM, Dennis Schetinin <[hidden email]> wrote:

>
> Is there any "correct'" way to render classes inhereted from PRCase? Here
> are the details:
>
> I want to represent an object, say Clinic with fullDescription, address,
> etc. attributes. Currently I do such things the way I saw in Pier-Blog. I.e.
> I overloaded Person>>viewComponentClass to return PersonView. And there I do
> something like:
>
> renderContentOn: html
>     super renderContentOn: html.
>     self renderFullDescriptionOn: html.
>     self renderAddressOn: html.
>     self renderDoctorsOn: html
>
> It works ofcourse, but I feel there should be another way to explain Pier
> (or Magritte?) how to render Clinics as far as I described them.

That's basically the right way.

In the custom render method you can use Magritte to generate a
read-only view of the fields, try something along:

html table: [
        aStructure description do: [ :each |
                (each isEditable and: [ each componentClass notNil ]) ifTrue: [
                        html tableRow: [
                                html tableHeading: each label.
                                html tableData: [
                                        (each componentClass memento: aStructure description: each)
                                                renderViewerOn: html ] ] ] ] ]

Unfortunately you have to add that yourself, because PRCase overrides
this default view of structures by just displaying the document.

> And one more thing: I saw people mentioned "Tutorial" but I don't know where
> to get it. Perhaps it's where all answers are already given? :)

See here <http://www.lukas-renggli.ch/smalltalk/magritte> and keep
asking questions.

Lukas

>
> --
> Dennis Schetinin
>
>
> _______________________________________________
> SmallWiki, Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>



--
Lukas Renggli
http://www.lukas-renggli.ch

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering descendant of PRCase

Dennis Schetinin

keep  asking questions.
 
Ok... :)

In the custom render method you can use Magritte to generate a
read-only view of the fields, try something along:

html table: [
       aStructure description do: [ :each |
               (each isEditable and: [ each componentClass notNil ]) ifTrue: [
                       html tableRow: [
                               html tableHeading: each label.
                               html tableData: [
                                       (each componentClass memento: aStructure description: each)
                                               renderViewerOn: html ] ] ] ] ]

This way it ignores pier syntax including all the 'special' symbols in text... I can't understand how to fix it?
 

--
Dennis Schetinin


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering descendant of PRCase

Dennis Schetinin
In the custom render method you can use Magritte to generate a
read-only view of the fields, try something along:

html table: [
       aStructure description do: [ :each |
               (each isEditable and: [ each componentClass notNil ]) ifTrue: [
                       html tableRow: [
                               html tableHeading: each label.
                               html tableData: [
                                       (each componentClass memento: aStructure description: each)
                                               renderViewerOn: html ] ] ] ] ]

This way it ignores pier syntax including all the 'special' symbols in text... I can't understand how to fix it?

I played a little bit more with Pier and understood this question was somewhat stupid...

My current idea is the following... For my site I have to do again and again the same thing: render all the 'details' of the current object and then render 'overview' of it's children. So, considering the 1-st part (details) I'd like to tag some fields as details of the object. So I implemented according methods (#isDetail, #isDetail:, #beDetail) in MADescription. Then I want create DetailedCase as a subclass of PRCase and override there #accept:

DetailedCase >> accept: aVisitor
  aVisitor visitDetailedCase: self

In PRViewRenderer >> visitDetailedCase: anObject I want to visit every property (is it correct term?) of anObject described as detail...
but I can't understand how i can do it... can I get a property of object by description (or vice versa)?

I expect to get all the details about anObject properly presented on the page this way. Am I right?


--
Dennis Schetinin


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering descendant of PRCase

Dennis Schetinin
:) Seems like I'm the one who likes to talk to himself...

In the custom render method you can use Magritte to generate a
read-only view of the fields, try something along:

html table: [
       aStructure description do: [ :each |
               (each isEditable and: [ each componentClass notNil ]) ifTrue: [
                       html tableRow: [
                               html tableHeading: each label.
                               html tableData: [
                                       (each componentClass memento: aStructure description: each)
                                               renderViewerOn: html ] ] ] ] ]

This way it ignores pier syntax including all the 'special' symbols in text... I can't understand how to fix it?

I played a little bit more with Pier and understood this question was somewhat stupid...

My current idea is the following... For my site I have to do again and again the same thing: render all the 'details' of the current object and then render 'overview' of it's children. So, considering the 1-st part (details) I'd like to tag some fields as details of the object. So I implemented according methods (#isDetail, #isDetail:, #beDetail) in MADescription. Then I want create DetailedCase as a subclass of PRCase and override there #accept:

DetailedCase >> accept: aVisitor
  aVisitor visitDetailedCase: self

In PRViewRenderer >> visitDetailedCase: anObject I want to visit every property (is it correct term?) of anObject described as detail...
but I can't understand how i can do it... can I get a property of object by description (or vice versa)?

I expect to get all the details about anObject properly presented on the page this way. Am I right?

I did:

PRViewRenderer >> visitDetailedCase: anObject
    self remember: anObject while: [ super visitDetailedCase: anObject ]

PRDeepRenderer >> visitDetailedCase: anObject
    anObject detailedDescription
        do: [:each | self
                visit: (each accessor read: anObject)]

PRVisitor >> visitDetailedCase: anObject
    self visitCase: anObject


It seems to work except the case when I tag MAStringDescription with #beDetail. In that case it tries to visit a String which is collection and so each of its characters should be visited but visiting is not implemented for most of objects including Chars... and I'm affraid the same error will be raised for some other types of description...

Hope to hear (or find by myself if only I'll have enough time) how to do it all the right way tomorrow... :)

--
Dennis Schetinin


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Rendering descendant of PRCase

Lukas Renggli
> It seems to work except the case when I tag MAStringDescription with
> #beDetail. In that case it tries to visit a String which is collection and
> so each of its characters should be visited but visiting is not implemented
> for most of objects including Chars... and I'm affraid the same error will
> be raised for some other types of description...

Sounds good so far, you just have to stop the visiting at some point.
In your example when you encounter the MAStringDescription you
probably just want to render the described string instead of
continuing visiting the string and its individual characters. Btw, you
can ask descriptions for a renderable string description like so:

     aDescription toString: value

So even if your value is not a string, all descriptions know how to
convert it to one.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki