WABatchedList\WATableReport example code-snap for Set

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

WABatchedList\WATableReport example code-snap for Set

Cong Tan
I tried to use WABatchedList and WATableReport to display a Set from my query engine, but failed to find any code examples online.  Can anyone providing me a code-snap of how to display them in renderContentOn?

Thanks

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WABatchedList\WATableReport example code-snap for Set

Lukas Renggli
Hi Cong,

Both widgets require sequenceable collections as the data source, they
do not work with unordered collections such as Sets. For example,
convert your Set to an Array:

   items := aSet asArray.

There are many examples in the one-click image for the WATableReport,
browse for its references.

The WABatchedList works very similar to the WATableReport. Set your
whole sequenceable collection as the items:

   batchedList items: anArray.

To get the currently selected batch ask it for its batch (which is a
subsequence of the items you set). You can use it to update the rows
in your WATableReport.

   tableReport rows: batchedList batch.

Cheers,
Lukas

On 3 August 2011 19:19, Cong Tan <[hidden email]> wrote:

> I tried to use WABatchedList and WATableReport to display a Set from
> my query engine, but failed to find any code examples online.  Can anyone
> providing me a code-snap of how to display them in renderContentOn?
> Thanks
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>



--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WABatchedList\WATableReport example code-snap for Set

Paul DeBruicker
In reply to this post by Cong Tan
a detailed guide to tables see:

http://www.shaffer-consulting.com/david/Seaside/WATableReport/index.html

but basically in your component initialise table in an inst var, add it
to the #children, and add the columns then set your Set as the rows.
then in the renderContentOn: method do something like

renderContentOn: html
html heading level3; with:'My Table'.
html render: table.




On 08/03/2011 01:19 PM, Cong Tan wrote:

> I tried to use WABatchedList and WATableReport to display a Set from
> my query engine, but failed to find any code examples online.  Can
> anyone providing me a code-snap of how to display them in renderContentOn?
>
> Thanks
>
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: WABatchedList\WATableReport example code-snap for Set

Cong Tan
I have followed the example, but still unable to get anything on the brower.

result_set is a set that contains an object called "triples", each triple has three instance variable, 'subject', 'predictor' and 'object'.  I have accessing and modifier method for each instances.

Here is what I have for renderResult: html:

result_array := result_set asArray.
rows := result_array.
columns := OrderedCollection new
add: (WAReportColumn selector: #subject title: 'Subject');
add: (WAReportColumn selector: #predicate title: 'Predictor');
add: (WAReportColumn selector: #object title: 'Object').
report := WATableReport new rows: rows; columns: columns.
html heading level3; with:'My Table'.
html render: report.

I don't get what the 'youself' in the example means, it gives me error regardless has it or not.

In addition, how to integrate WABatchedList with WABatchedTable?  I have following code for for BatchedList, but nothing is displayed either.
result_array := result_set asArray.
batchedlist := WABatchedList new.
batchedlist items: result_array.
batchedlist batchSize: 10.
batchedlist renderContentOn: html. 

On Wed, Aug 3, 2011 at 12:33 PM, Paul DeBruicker <[hidden email]> wrote:
a detailed guide to tables see:

http://www.shaffer-consulting.com/david/Seaside/WATableReport/index.html

but basically in your component initialise table in an inst var, add it to the #children, and add the columns then set your Set as the rows. then in the renderContentOn: method do something like

renderContentOn: html
html heading level3; with:'My Table'.
html render: table.





On 08/03/2011 01:19 PM, Cong Tan wrote:
I tried to use WABatchedList and WATableReport to display a Set from
my query engine, but failed to find any code examples online.  Can
anyone providing me a code-snap of how to display them in renderContentOn?

Thanks


_______________________________________________
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


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WABatchedList\WATableReport example code-snap for Set

Lukas Renggli
Did you follow the principles of how to compose components?

   http://book.seaside.st/book/components/embedding/children

Lukas

On 3 August 2011 22:55, Cong Tan <[hidden email]> wrote:

> I have followed the example, but still unable to get anything on the brower.
> result_set is a set that contains an object called "triples", each triple
> has three instance variable, 'subject', 'predictor' and 'object'.  I have
> accessing and modifier method for each instances.
> Here is what I have for renderResult: html:
> result_array := result_set asArray.
> rows := result_array.
> columns := OrderedCollection new
> add: (WAReportColumn selector: #subject title: 'Subject');
> add: (WAReportColumn selector: #predicate title: 'Predictor');
> add: (WAReportColumn selector: #object title: 'Object').
> report := WATableReport new rows: rows; columns: columns.
> html heading level3; with:'My Table'.
> html render: report.
> I don't get what the 'youself' in the example means, it gives me error
> regardless has it or not.
> In addition, how to integrate WABatchedList with WABatchedTable?  I have
> following code for for BatchedList, but nothing is displayed either.
> result_array := result_set asArray.
> batchedlist := WABatchedList new.
> batchedlist items: result_array.
> batchedlist batchSize: 10.
> batchedlist renderContentOn: html.
> On Wed, Aug 3, 2011 at 12:33 PM, Paul DeBruicker <[hidden email]> wrote:
>>
>> a detailed guide to tables see:
>>
>> http://www.shaffer-consulting.com/david/Seaside/WATableReport/index.html
>>
>> but basically in your component initialise table in an inst var, add it to
>> the #children, and add the columns then set your Set as the rows. then in
>> the renderContentOn: method do something like
>>
>> renderContentOn: html
>> html heading level3; with:'My Table'.
>> html render: table.
>>
>>
>>
>>
>> On 08/03/2011 01:19 PM, Cong Tan wrote:
>>>
>>> I tried to use WABatchedList and WATableReport to display a Set from
>>> my query engine, but failed to find any code examples online.  Can
>>> anyone providing me a code-snap of how to display them in
>>> renderContentOn?
>>>
>>> Thanks
>>>
>>>
>>> _______________________________________________
>>> 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
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>



--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WABatchedList\WATableReport example code-snap for Set

Cong Tan
Yes. I have several other components composed in renderContentOn:  I actually followed the example and have my result displayed, but i am interesting to know WABatchedList and WATableReport works together.  TableReport shows a table, but BatchedList controls what to show?  I am confused about this part.

On Wed, Aug 3, 2011 at 4:07 PM, Lukas Renggli <[hidden email]> wrote:
Did you follow the principles of how to compose components?

  http://book.seaside.st/book/components/embedding/children

Lukas

On 3 August 2011 22:55, Cong Tan <[hidden email]> wrote:
> I have followed the example, but still unable to get anything on the brower.
> result_set is a set that contains an object called "triples", each triple
> has three instance variable, 'subject', 'predictor' and 'object'.  I have
> accessing and modifier method for each instances.
> Here is what I have for renderResult: html:
> result_array := result_set asArray.
> rows := result_array.
> columns := OrderedCollection new
> add: (WAReportColumn selector: #subject title: 'Subject');
> add: (WAReportColumn selector: #predicate title: 'Predictor');
> add: (WAReportColumn selector: #object title: 'Object').
> report := WATableReport new rows: rows; columns: columns.
> html heading level3; with:'My Table'.
> html render: report.
> I don't get what the 'youself' in the example means, it gives me error
> regardless has it or not.
> In addition, how to integrate WABatchedList with WABatchedTable?  I have
> following code for for BatchedList, but nothing is displayed either.
> result_array := result_set asArray.
> batchedlist := WABatchedList new.
> batchedlist items: result_array.
> batchedlist batchSize: 10.
> batchedlist renderContentOn: html.
> On Wed, Aug 3, 2011 at 12:33 PM, Paul DeBruicker <[hidden email]> wrote:
>>
>> a detailed guide to tables see:
>>
>> http://www.shaffer-consulting.com/david/Seaside/WATableReport/index.html
>>
>> but basically in your component initialise table in an inst var, add it to
>> the #children, and add the columns then set your Set as the rows. then in
>> the renderContentOn: method do something like
>>
>> renderContentOn: html
>> html heading level3; with:'My Table'.
>> html render: table.
>>
>>
>>
>>
>> On 08/03/2011 01:19 PM, Cong Tan wrote:
>>>
>>> I tried to use WABatchedList and WATableReport to display a Set from
>>> my query engine, but failed to find any code examples online.  Can
>>> anyone providing me a code-snap of how to display them in
>>> renderContentOn?
>>>
>>> Thanks
>>>
>>>
>>> _______________________________________________
>>> 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
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>



--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WABatchedList\WATableReport example code-snap for Set

Lukas Renggli
> Yes. I have several other components composed in renderContentOn:  I
> actually followed the example and have my result displayed,

The code you posted looked very buggy:

1. you cannot instantiate components while rendering (otherwise they
get recreated each time)

2. you cannot send #renderContentOn: on other components (this messes
with the rendering)

Both bugs can be detected using Slime.

> but i am
> interesting to know WABatchedList and WATableReport works together.
>  TableReport shows a table, but BatchedList controls what to show?  I am
> confused about this part.

You renderContentOn: method should look as simple as that:

renderContentOn: html
    tableReport rows: batchedList batch.
    html render: tableReport.
    html render: batchedList

Lukas

--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WABatchedList\WATableReport example code-snap for Set

Cong Tan
I just got it working.  You are right, my code was buggy.  Once I clear up everything, I will put my code here for future reference.

On Thu, Aug 4, 2011 at 12:18 AM, Lukas Renggli <[hidden email]> wrote:
> Yes. I have several other components composed in renderContentOn:  I
> actually followed the example and have my result displayed,

The code you posted looked very buggy:

1. you cannot instantiate components while rendering (otherwise they
get recreated each time)

2. you cannot send #renderContentOn: on other components (this messes
with the rendering)

Both bugs can be detected using Slime.

> but i am
> interesting to know WABatchedList and WATableReport works together.
>  TableReport shows a table, but BatchedList controls what to show?  I am
> confused about this part.

You renderContentOn: method should look as simple as that:

renderContentOn: html
   tableReport rows: batchedList batch.
   html render: tableReport.
   html render: batchedList

Lukas

--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: WABatchedList\WATableReport example code-snap for Set

thiago_sl
Hi Lukas and Cong,
Testing this integration between WATableReport and WABatchedList, the pagination works fine, but not sorting the items grid. This way, only the current page items are sortable, not all items, because 'tableReport rows: batchedList batch.' message. IMHO, the idea is sort the entire collection, right?

Thiago S. Lino