trouble rendering widgets

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

trouble rendering widgets

Tudor Girba-2
Hi,

I have a bit of trouble rendering a widget that aims to embed some other structures.

Here is the current code:

renderContentOn: html
        html div
                id: #cycler;
                script: ((html jQuery: #cycler) cycle fx: 'fade'; timeout: self timeout; delay: self delay; speed: self speed; pager: '#cyclerNav') greaseString;
                with: [
                        self sourceChildren do: [:each |
                                html div class: 'cyclerItem'; with: [html rendererInstance visit: each document] ] ].

It seems to work fine when sourceChildren contains only PRPages, but when there is a PRFile inside, it goes strange. For example, if I have three PRFiles in the collection, the rendering looks like:

<div id="cycler">
        <div class="cyclerItem"></div>
        <div class="cyclerItem"><img alt="One" src="/pier?_s=Zp6phh68i9hRHhnB"></div>
        <div class="cyclerItem"><img alt="Two" src="/pier?_s=z2r2BcgQuxMPw_cc"></div>
</div>
<img alt="Three" src="/pier?_s=LFE6L8UkDNIyzAdN"></div>


What am I doing wrong?

Cheers,
Doru

--
www.tudorgirba.com

"Some battles are better lost than fought."




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

Re: trouble rendering widgets

Lukas Renggli
Are you correctly implementing #children?

Also you make sure to use #continue:in:on: instead of #visit: (that's
why you get the messed up HTML, your code writes to the wrong
renderer).

Have a look at PRDocument widget to see an example of how to render
other structures within your widgets.

Lukas

On 19 August 2011 00:49, Tudor Girba <[hidden email]> wrote:

> Hi,
>
> I have a bit of trouble rendering a widget that aims to embed some other structures.
>
> Here is the current code:
>
> renderContentOn: html
>        html div
>                id: #cycler;
>                script: ((html jQuery: #cycler) cycle fx: 'fade'; timeout: self timeout; delay: self delay; speed: self speed; pager: '#cyclerNav') greaseString;
>                with: [
>                        self sourceChildren do: [:each |
>                                html div class: 'cyclerItem'; with: [html rendererInstance visit: each document] ] ].
>
> It seems to work fine when sourceChildren contains only PRPages, but when there is a PRFile inside, it goes strange. For example, if I have three PRFiles in the collection, the rendering looks like:
>
> <div id="cycler">
>        <div class="cyclerItem"></div>
>        <div class="cyclerItem"><img alt="One" src="/pier?_s=Zp6phh68i9hRHhnB"></div>
>        <div class="cyclerItem"><img alt="Two" src="/pier?_s=z2r2BcgQuxMPw_cc"></div>
> </div>
> <img alt="Three" src="/pier?_s=LFE6L8UkDNIyzAdN"></div>
>
>
> What am I doing wrong?
>
> Cheers,
> Doru
>
> --
> www.tudorgirba.com
>
> "Some battles are better lost than fought."
>
>
>
>
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>



--
Lukas Renggli
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: trouble rendering widgets

Nick
>
> renderContentOn: html
>        html div
>                id: #cycler;
>                script: ((html jQuery: #cycler) cycle fx: 'fade'; timeout: self timeout; delay: self delay; speed: self speed; pager: '#cyclerNav') greaseString;
>                with: [
>                        self sourceChildren do: [:each |
>                                html div class: 'cyclerItem'; with: [html rendererInstance visit: each document] ] ].
>

Unrelated to your problem, but I don't think you need the call to #greaseString at the end of your script: line.

Nick

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

Re: trouble rendering widgets

Tudor Girba-2
In reply to this post by Lukas Renggli
Hi,

On 19 Aug 2011, at 07:23, Lukas Renggli wrote:

> Are you correctly implementing #children?

Yes. But, in this case, there are no children.

> Also you make sure to use #continue:in:on: instead of #visit: (that's
> why you get the messed up HTML, your code writes to the wrong
> renderer).

Thanks. That seems to solve the problem. I am using:
html rendererInstance withinContentDo: [ html rendererInstance continue: each document in: self on: html ]

Cheers,
Doru

> Have a look at PRDocument widget to see an example of how to render
> other structures within your widgets.
>
> Lukas
>
> On 19 August 2011 00:49, Tudor Girba <[hidden email]> wrote:
>> Hi,
>>
>> I have a bit of trouble rendering a widget that aims to embed some other structures.
>>
>> Here is the current code:
>>
>> renderContentOn: html
>>        html div
>>                id: #cycler;
>>                script: ((html jQuery: #cycler) cycle fx: 'fade'; timeout: self timeout; delay: self delay; speed: self speed; pager: '#cyclerNav') greaseString;
>>                with: [
>>                        self sourceChildren do: [:each |
>>                                html div class: 'cyclerItem'; with: [html rendererInstance visit: each document] ] ].
>>
>> It seems to work fine when sourceChildren contains only PRPages, but when there is a PRFile inside, it goes strange. For example, if I have three PRFiles in the collection, the rendering looks like:
>>
>> <div id="cycler">
>>        <div class="cyclerItem"></div>
>>        <div class="cyclerItem"><img alt="One" src="/pier?_s=Zp6phh68i9hRHhnB"></div>
>>        <div class="cyclerItem"><img alt="Two" src="/pier?_s=z2r2BcgQuxMPw_cc"></div>
>> </div>
>> <img alt="Three" src="/pier?_s=LFE6L8UkDNIyzAdN"></div>
>>
>>
>> What am I doing wrong?
>>
>> Cheers,
>> Doru
>>
>> --
>> www.tudorgirba.com
>>
>> "Some battles are better lost than fought."
>>
>>
>>
>>
>> _______________________________________________
>> Magritte, Pier and Related Tools ...
>> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>>
>
>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
>
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki

--
www.tudorgirba.com

"Yesterday is a fact.
 Tomorrow is a possibility.
 Today is a challenge."




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

Re: trouble rendering widgets

Lukas Renggli
>> Are you correctly implementing #children?
>
> Yes. But, in this case, there are no children.

Rendering a structure might introduce new components (directly or
indirectly), so you have to declare #children.

Lukas

--
Lukas Renggli
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: trouble rendering widgets

Tudor Girba-2
Hi,

I know. I declared the children by collecting all the components. I just said that for the test with the files, there were no embedded

For reference, this is what I used for the children:

children
        ^ self sourceChildren
                inject: OrderedCollection new
                into: [:all :each | all addAll: (each componentsIn: self context)]

Cheers,
Doru



On 19 Aug 2011, at 08:27, Lukas Renggli wrote:

>>> Are you correctly implementing #children?
>>
>> Yes. But, in this case, there are no children.
>
> Rendering a structure might introduce new components (directly or
> indirectly), so you have to declare #children.
>
> Lukas
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki

--
www.tudorgirba.com

"The coherence of a trip is given by the clearness of the goal."





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

Re: trouble rendering widgets

Lukas Renggli
> I know. I declared the children by collecting all the components. I just said that for the test with the files, there were no embedded

Sorry, I must have misunderstood then :-)

Yes, the files and documents do not create components. You only get
components when you embed (directly or indirectly) a PRComponent.

Lukas

--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki