Embedding view

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

Embedding view

Dennis Schetinin
I did ask this question before, but still don't know how to solve the problem.

So, I have Questionnaire (subclass of PRCase) and it's view QuestionnaireView (PRDefaultView). The latter should render children Polls of Questionnaire using vote command. I need to embed a Questionnaire into another page.

I tried to do it implementing #visitQuestionnaire: in  #PREmbeddedRender

visitQuestionnaire: aStructure
    (aStructure viewComponentClass on: self context) structure: aStructure;
         renderContentOn: html

As far as QuestionnaireView renders polls as components, selecting an option in one of the Polls (posting the form) gives a "WAComponentsNotFoundError" exception (because #children method of QuestionnaireView is not invoked at all).

What is the correct way to implement what I want?

--
Dennis Schetinin

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

Re: Embedding view

Lukas Renggli
> I did ask this question before, but still don't know how to solve the
> problem.

Sorry, must have missed this one.

> So, I have Questionnaire (subclass of PRCase) and it's view
> QuestionnaireView (PRDefaultView). The latter should render children Polls
> of Questionnaire using vote command. I need to embed a Questionnaire into
> another page.

In the current design of Pier there can only be one context active at
a time. And the context consists either of a command or a single view
on the current structure.

> I tried to do it implementing #visitQuestionnaire: in  #PREmbeddedRender
>
> visitQuestionnaire: aStructure
>     (aStructure viewComponentClass on: self context) structure: aStructure;
>          renderContentOn: html

What the view itself does is up to you, however (as basic rule with
Seaside) you should never instantiate components as a side-effect and
you should never call #renderContentOn: manually.

> What is the correct way to implement what I want?

What are you trying to do?

Lukas

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

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

Re: Embedding view

Dennis Schetinin

What are you trying to do?

I want to ask users of my site several questions (using Polls). This Questionnaire form (consisting of Poll's forms and two buttons like "Ok" and "Cancel"... or just "Ok" maybe...) should be at the main page of the site.

Those who already answered questions should see results instead of the form. But I hope I can do this feature myself (or will ask for help later, if you don't mind:). The main problem so far is embedding. Or whatever I should use instead of it...

--
Dennis Schetinin

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

Re: Embedding view

John McKeon


On Mon, Jul 13, 2009 at 7:30 AM, Dennis Schetinin <[hidden email]> wrote:

What are you trying to do?

I want to ask users of my site several questions (using Polls). This Questionnaire form (consisting of Poll's forms and two buttons like "Ok" and "Cancel"... or just "Ok" maybe...) should be at the main page of the site.

Those who already answered questions should see results instead of the form. But I hope I can do this feature myself (or will ask for help later, if you don't mind:). The main problem so far is embedding. Or whatever I should use instead of it...

It sounds like you want functionality like that of the postticker  wrt a blog.

When i wrote a PRCase subclass, I referred extensively to the PBBlog and its associated classes for direction.

John



--
Dennis Schetinin

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



--
http://jmck.seasidehosting.st

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

Re: Embedding view

Dennis Schetinin

I want to ask users of my site several questions (using Polls). This Questionnaire form (consisting of Poll's forms and two buttons like "Ok" and "Cancel"... or just "Ok" maybe...) should be at the main page of the site.

Those who already answered questions should see results instead of the form. But I hope I can do this feature myself (or will ask for help later, if you don't mind:). The main problem so far is embedding. Or whatever I should use instead of it...

It sounds like you want functionality like that of the postticker  wrt a blog.

When i wrote a PRCase subclass, I referred extensively to the PBBlog and its associated classes for direction.

So, (Pier-)widget implementation is the correct way?

--
Dennis Schetinin

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

Re: Embedding view

Lukas Renggli
>> When i wrote a PRCase subclass, I referred extensively to the PBBlog and
>> its associated classes for direction.
>
> So, (Pier-)widget implementation is the correct way?

There are different possibilities, but using a widget is probably the
most strait forward. Have a look at the Blog plugin, it makes use of
various views and widgets. Also the Citezen plugin uses the same
approach: <http://scg.unibe.ch/wiki/howtos/howToLinkToScgBib>.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Embedding view

Dennis Schetinin
>> When i wrote a PRCase subclass, I referred extensively to the PBBlog and
>> its associated classes for direction.
>
> So, (Pier-)widget implementation is the correct way?

There are different possibilities, but using a widget is probably the
most strait forward. Have a look at the Blog plugin, it makes use of
various views and widgets. Also the Citezen plugin uses the same
approach: <http://scg.unibe.ch/wiki/howtos/howToLinkToScgBib>.

Thank you, John and Lukas

--
Dennis Schetinin

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

Re: Embedding view

Dennis Schetinin
I found I was wrong with my plans. So I need more help, if you still don't mind. So, what I want. I want to join several Polls (from the respective package) in a Questionnaire. User should see several polls with options, select one answer in each of them, and submit his votes with one click on 'submit' button.

I don't know how to implement it with the current design of Polls. I neither know how to use several Vote commands in one form nor see any other ways to do what I want (not reimplementing this in whole). What is (Pier+Magritte-)correct way to do that?

--
Dennis Schetinin

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

Re: Embedding view

John McKeon
Hi David,
We here at the Pier-Magritte mailing list are always eager to help out =)
You have an interesting plug-in in the works, so that makes it worth it too,

On Wed, Jul 15, 2009 at 12:18 AM, Dennis Schetinin <[hidden email]> wrote:
I found I was wrong with my plans. So I need more help, if you still don't mind. So, what I want. I want to join several Polls (from the respective package) in a Questionnaire.

This is what I had in mind when i suggested the postticker type of arrangement.

I will lay out the steps for how I see the design. I have no idea how much you have accomplished, how astute you are with regards to Pier design. I am certainly no expert but have a good grasp of it, so I am giving the soup to nuts version and then hopefully it will help otheres as well. Maybe it will be good enough (and correct enough!) to be included in a tutorial somewhere. Keep in mind that you want to start as simple as possible. The Blog is a good example but appears daunting because it has some very complex view requirements. Most PRCases probably dont need that much in the way of view rendering.
And for editing of the Pier structures, Pier does most of it automatically.

My design would use a PollManager (PRCase) to manage the "package" of available Poll questions (akin to the blog as a manager of posts). You definitely want to look at its Model class for guidance. That is what I am referring to as i write this :)

There really is not much more to PBBlog than:

1) It descends from PRCase
2) It implements a few choice methods:
   a) On the class side #canBeParentOf: aClass is implemented to tell Pier what the Add command can add to it (what will show up in the drop down box when the Add command is invoked)
   b) isAbstract is implemented to return false.
   c) On the instance side, #viewComponentClass
   d) As a general usage pattern, #allXxxxIn: aContext will enumerate all the children (Polls)
   e) #isValidView: aComponentClass in: aContext might be needed  (though I have gotten away without this one...)
3) It implements Magritte descriptions of the various instance variables. Any setting or items that can be edited at runtime send #beSetting or #beEditable to the description (This is what makes these fields show up when you click Edit Settings or Edit respectively).

I really do not see many settings for this piece of the design except maybe how many questions to feed to connected Questionnaire widgets, max life for a Poll question to be considered for the widget feed etc. You decide. Then give them setting descriptions.
The view component will me minimal. This is what is used to render the manager when we click on a link to it, of which the only one should be in the Commands section when we the admin, log in to add a Poll or two or change a settting. This view is not for general consumption. So all it renders is itself and the Poll questions.

Polls would also be a subclass of PRCase and do most of what PollManager does except it will also implement #canBeChildOf: aClass to return true only if aClass = PollManager. Again all of the settings and calculated fields get Magritte descriptions so they show up in the automatically generated editor. Some of these settings will be the fields on which our widget will filter which Polls it displays.
The view component will render the question in some form, maybe just the question text and the total vote statistics. Also a link to itself for easy navigation (instead of making us go down into the Commands section and trying to find it in the tree of structures) . Again the main thing here is that it is just rendering for our view only. The widget will be the public renderer of the Poll.

(If we would be happy with the one structure being the renderer of our poll, ie making our poll manager viewable by the public but only show some selection of questions we COULD buiild that functionality into the PollManager's view component class and be done with it. All that logic would be designed into the rendering code. But that would make it less flexible.)


We want the more flexible Questionnaire widget set up. My design is going to be alot like the PBPostticker widget so lets take a closer look at what that does.  Notice that almost all of its mehtods involve rendering as it is a Seaside component. It has a blog method that get the blog for which it 'ticks' via a description. It gets the posts that it will display from the blog. Out widget will do the same thing, It will have a description for the PollManager and a way to get all the Polls it will display. Again, any Magritte described fields will be editable by the site admin. #descriptionBlog is very instructive. It tells us how to describe the PollManager (we should implement a #isPollManager method to return true so our description can return the poll manager(s) available to be chosen as the Poll source. If we want to filter polls on some field of the polls then we need a description for that. It might be complex since we want a dynamic selection of what those field values are. This logic is up to you. The rest is the rendering code that displays the Poll question to whomever wanders into our site, the choices of answers and what happens when the user clicks one and when they click the submit button. This component definitely requires the most work.

I hope you fiind this instructive. If anyone finds any glaring errors please feel free to correct me.
John
 
User should see several polls with options, select one answer in each of them, and submit his votes with one click on 'submit' button.

I don't know how to implement it with the current design of Polls. I neither know how to use several Vote commands in one form nor see any other ways to do what I want (not reimplementing this in whole). What is (Pier+Magritte-)correct way to do that?

--
Dennis Schetinin

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



--
http://jmck.seasidehosting.st

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

Re: Embedding view

Dennis Schetinin
I hope you fiind this instructive. If anyone finds any glaring errors please feel free to correct me.

It's  a nice manual. But unfortunately I didn't find solutions for the problems I met. Perhaps it's because I didn't explain what I want correctly. Let me try again...

I would like to use existing Poll package, recently updated by Lukas to work properly in current versions of Pier.

There's POPoll class containing options (as instances of POPollOptions and described by MAToManyRelationDescription) along with other attributes (like deadline, uuid --- unique ID used to identify already voted users, --- etc.). POPolls were supposed to be rendered with special kinds of PRViewComponents using charts but it's a bit off-topic right now.

Voting itself is supported by POVoteCommand class, which is rendered as a form described by MASingleOptionDescription with POPollOptons as options. (I don't fully understand how it works but it obviously does:) By the way, despite unvoted POPoll has POVoteCommand as default, it is still rendered as with View (it's a question for Lukas, maybe?).

So, the question (still) is: how to join several POPolls in one form providing choices several choices (of different polls) being posted back to server by click on one button. I'm not so good in web programming so I'm not sure if it is possible at all (should those be nested forms or what?).

--
Dennis Schetinin

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

Re: Embedding view

John McKeon


On Wed, Jul 15, 2009 at 2:37 PM, Dennis Schetinin <[hidden email]> wrote:
I hope you fiind this instructive. If anyone finds any glaring errors please feel free to correct me.

It's  a nice manual. But unfortunately I didn't find solutions for the problems I met. Perhaps it's because I didn't explain what I want correctly. Let me try again...

I would like to use existing Poll package, recently updated by Lukas to work properly in current versions of Pier.

Eep! I hadn't seen those 8) heheh ahem  That you were using an existing package was a bit of info missing from your original post.....


There's POPoll class containing options (as instances of POPollOptions and described by MAToManyRelationDescription) along with other attributes (like deadline, uuid --- unique ID used to identify already voted users, --- etc.). POPolls were supposed to be rendered with special kinds of PRViewComponents using charts but it's a bit off-topic right now.

Voting itself is supported by POVoteCommand class, which is rendered as a form described by MASingleOptionDescription with POPollOptons as options. (I don't fully understand how it works but it obviously does:) By the way, despite unvoted POPoll has POVoteCommand as default, it is still rendered as with View (it's a question for Lukas, maybe?).

So, the question (still) is: how to join several POPolls in one form providing choices several choices (of different polls) being posted back to server by click on one button. I'm not so good in web programming so I'm not sure if it is possible at all (should those be nested forms or what?).

This is all Lukas and Phillipe's fault so I must defer to them :)

I also notice that I cannot make the Vote command visible to non-logged in users by using the ChangeOther command. Can someone shed some light on that?
 


--
Dennis Schetinin

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



--
http://jmck.seasidehosting.st

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