Issue with WebGrid

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

Issue with WebGrid

Herbert König
Hi,

i got a strange WebGrid, which displays two of its items in one row.

The table can be seen in funnyTable.png, the underlying collection in
collection.png

The table is displayed via displayProfilComponent, which is used in
viewProdile.

Any insight why this happens is highly appreciated.

Cheers,

Herbert                          mailto:[hidden email]
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida

collection.png (16K) Download Attachment
funnyTable.PNG (75K) Download Attachment
EllingWebTabsApp-displayProfilComponent.st (1K) Download Attachment
EllingWebTabsApp-viewProfile.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Alex Baran
Hi Herbert,

It seems if you have object the same as (tested by equality) last
object in your grid, creation of a new row will be omitted. I think it
should be changed in Aida.
Look at
WebGrid>>buildTableRows
...
                object ~= objects last ifTrue: [self newRow].
...

In your case first and last object looks similar.


Alex

2009/4/7 Herbert König <[hidden email]>:

> Hi,
>
> i got a strange WebGrid, which displays two of its items in one row.
>
> The table can be seen in funnyTable.png, the underlying collection in
> collection.png
>
> The table is displayed via displayProfilComponent, which is used in
> viewProdile.
>
> Any insight why this happens is highly appreciated.
>
> Cheers,
>
> Herbert                          mailto:[hidden email]
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
>
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Alex Baran
In reply to this post by Herbert König
Herbert, you can try simple example. In that case instead of two rows,
'boxsocks' will be displayed.

viewMain
        | grid |
        grid := WebGrid new.
        grid
                columnNames: #('Simple string');
                columnAspects: #(displayString);
                collection: #(fox box socks box).
        self
                pageFrameWith: grid
                title: ''.

Alex

2009/4/7 Herbert König <[hidden email]>:

> Hi,
>
> i got a strange WebGrid, which displays two of its items in one row.
>
> The table can be seen in funnyTable.png, the underlying collection in
> collection.png
>
> The table is displayed via displayProfilComponent, which is used in
> viewProdile.
>
> Any insight why this happens is highly appreciated.
>
> Cheers,
>
> Herbert                          mailto:[hidden email]
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
>
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Alex Baran
My fix of the problem:

WebGrid>>buildTableRows
        | inx objects pageLength |
        self collection notEmpty ifTrue: [self newRow].
        objects := self filtered.
        self resetSummary. inx := 0. objects do: [:object | inx := inx + 1.
"summary in advance!"
                self columns do: [:column | self summaryForColumn: column index: inx
object: object]].
        inx := 1. pageLength := self hasPages ifTrue: [self rowsOnPage]
ifFalse: [objects size].
        (self page-1) * pageLength > objects size ifTrue: [self page: 1].
        objects := objects
                copyFrom: ((self page-1) * pageLength)+1 to: (self page * pageLength
min: objects size).
        objects
                do:
                        [:object |
                        self setRowAttributesFor: self row object: object.
                        self columns do:
                                [:column |
                                (object == objects first and: [column width notNil])
                                        ifTrue: [self cell width: column width].
                                self printColumn: column index: inx object: object in: self cell.
                                column ~= self columns last ifTrue: [self newCell] ].
                        inx := inx + 1 ]
                doButLast: [:object | self newRow].


SequenceableCollection>>do: aBlock doButLast: butLastBlock
        self isEmpty ifTrue: [^self].

        (1 to: self size - 1) do:
                [:index |
                | val |
                val := self at: index.
                aBlock value: val.
                butLastBlock value: val].

        aBlock value: (self at: self size)


In WebGrid>>buildTableRows  I factored creation of new row into
separate block. The block is executed for each except last element of
a collection.

Hope this help,
Alex Baran

2009/4/7 Alex Baran <[hidden email]>:

> Herbert, you can try simple example. In that case instead of two rows,
> 'boxsocks' will be displayed.
>
> viewMain
>        | grid |
>        grid := WebGrid new.
>        grid
>                columnNames: #('Simple string');
>                columnAspects: #(displayString);
>                collection: #(fox box socks box).
>        self
>                pageFrameWith: grid
>                title: ''.
>
> Alex
>
> 2009/4/7 Herbert König <[hidden email]>:
>> Hi,
>>
>> i got a strange WebGrid, which displays two of its items in one row.
>>
>> The table can be seen in funnyTable.png, the underlying collection in
>> collection.png
>>
>> The table is displayed via displayProfilComponent, which is used in
>> viewProdile.
>>
>> Any insight why this happens is highly appreciated.
>>
>> Cheers,
>>
>> Herbert                          mailto:[hidden email]
>> _______________________________________________
>> Aida mailing list
>> [hidden email]
>> http://lists.aidaweb.si/mailman/listinfo/aida
>>
>>
>
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Herbert König
In reply to this post by Alex Baran
Hi Alex,

AB> It seems if you have object the same as (tested by equality) last
AB> object in your grid, creation of a new row will be omitted. I think it
AB> should be changed in Aida.
thanks, yes the points represent a closed polygon and the format
requires the first point repeated.

WebGrid>>buildTableRows only has one sender and is private, so I could
probably change it without endangering other code.

WebGrid is only used in WebDemoApp and WebAdminApp but I'd like to
know the rationale before changing it.

Wrote that yesterday evening on the train.

Now I see your fix. Took me some time to understand the whole thing
but now I disagree with extending SequencableCollection. Because the
extension is needed once and I don't see where else it could be needed.
(which may be because I can't see enough so tell me I'm wrong)

I think we either should use SequencableCollection>>withIndexDo:
to not insert the last row. And inx seems to come handy.

So why not just change the offending
object ~= objects last ifTrue: [self newRow].
into
inx ~= objects size ifTrue: [self newRow].

Same with the beginning of the self columns do: block
(object == objects first and: [column width notNil])
change it to:
(inx = 1 and: [column width notNil])

Because the whole thing has nothing to do with the contents of the
collection. Think of a games high score list, always 10 Players
initialized all to the same default player.

I'm trying to take Smalltalk and Aida lessons here :-))

Cheers,

Herbert                            mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Alex Baran
Hi Herbert,

2009/4/8 Herbert König <[hidden email]>:

> Hi Alex,
>
> AB> It seems if you have object the same as (tested by equality) last
> AB> object in your grid, creation of a new row will be omitted. I think it
> AB> should be changed in Aida.
> thanks, yes the points represent a closed polygon and the format
> requires the first point repeated.
>
> WebGrid>>buildTableRows only has one sender and is private, so I could
> probably change it without endangering other code.
 >
> WebGrid is only used in WebDemoApp and WebAdminApp but I'd like to
> know the rationale before changing it.
>

For me the main argument to change is that this is the situation that
I will prefer not to have in a production code. Because it requries to
follow some hidden rule, something like "Collection must be without
duplicates. Duplication is checked by equality.". So you need to
mention the rule or change the code. The situation can also be danger
with sorting, when it appear with one order and disappear with
another.


> Wrote that yesterday evening on the train.
>
> Now I see your fix. Took me some time to understand the whole thing
> but now I disagree with extending SequencableCollection. Because the
> extension is needed once and I don't see where else it could be needed.
> (which may be because I can't see enough so tell me I'm wrong)
>

Making extension of SequencableCollection is a way of raising
abstraction and reuse. It's often the case with printing on some media
that you need to insert something between elements representation. But
to justify such change, you need to have multiple usage inside Aida.
So, I think I will prefer your way without changing
SequencableCollection.

> I think we either should use SequencableCollection>>withIndexDo:
> to not insert the last row. And inx seems to come handy.
>
> So why not just change the offending
> object ~= objects last ifTrue: [self newRow].
> into
> inx ~= objects size ifTrue: [self newRow].
>
> Same with the beginning of the self columns do: block
> (object == objects first and: [column width notNil])
> change it to:
> (inx = 1 and: [column width notNil])

Yes, it's another potential problem, I have not grasp it before. And
it makes argument to not extend SequantialCollection, because you need
to work with index in two places anyway.

>
> Because the whole thing has nothing to do with the contents of the
> collection. Think of a games high score list, always 10 Players
> initialized all to the same default player.
>
> I'm trying to take Smalltalk and Aida lessons here :-))
>

I think it what the community is about :)


All the best,
Alex

> Cheers,
>
> Herbert                            mailto:[hidden email]
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Nicholas Moore
Herbert and Alex - thanks for the discussion, I am just starting to use WebGrid and have found your comments useful.

Nicholas


Alex Baran wrote:
Hi Herbert,

2009/4/8 Herbert K�nig [hidden email]:
  
Hi Alex,

AB> It seems if you have object the same as (tested by equality) last
AB> object in your grid, creation of a new row will be omitted. I think it
AB> should be changed in Aida.
thanks, yes the points represent a closed polygon and the format
requires the first point repeated.

WebGrid>>buildTableRows only has one sender and is private, so I could
probably change it without endangering other code.
    
 >
  
WebGrid is only used in WebDemoApp and WebAdminApp but I'd like to
know the rationale before changing it.

    

For me the main argument to change is that this is the situation that
I will prefer not to have in a production code. Because it requries to
follow some hidden rule, something like "Collection must be without
duplicates. Duplication is checked by equality.". So you need to
mention the rule or change the code. The situation can also be danger
with sorting, when it appear with one order and disappear with
another.


  
Wrote that yesterday evening on the train.

Now I see your fix. Took me some time to understand the whole thing
but now I disagree with extending SequencableCollection. Because the
extension is needed once and I don't see where else it could be needed.
(which may be because I can't see enough so tell me I'm wrong)

    

Making extension of SequencableCollection is a way of raising
abstraction and reuse. It's often the case with printing on some media
that you need to insert something between elements representation. But
to justify such change, you need to have multiple usage inside Aida.
So, I think I will prefer your way without changing
SequencableCollection.

  
I think we either should use SequencableCollection>>withIndexDo:
to not insert the last row. And inx seems to come handy.

So why not just change the offending
object ~= objects last ifTrue: [self newRow].
into
inx ~= objects size ifTrue: [self newRow].

Same with the beginning of the self columns do: block
(object == objects first and: [column width notNil])
change it to:
(inx = 1 and: [column width notNil])
    

Yes, it's another potential problem, I have not grasp it before. And
it makes argument to not extend SequantialCollection, because you need
to work with index in two places anyway.

  
Because the whole thing has nothing to do with the contents of the
collection. Think of a games high score list, always 10 Players
initialized all to the same default player.

I'm trying to take Smalltalk and Aida lessons here :-))

    

I think it what the community is about :)


All the best,
Alex

  
Cheers,

Herbert � � � � � � � � � � � � � �[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida

    
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
  

--
NJM TSR-i

Nicholas J Moore
Limoges
France


_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Janko Mivšek
In reply to this post by Alex Baran
Hi Herbert and Alex,

Many thanks to both of you to dig into that problem, which is a result
of my too naive detection of end of WebGrid collection. Silly me, I also
have once the same problem but was not able to solve it :) Thanks a lot
Alex to catch it!

I also think that Herbert's solution is most practical and simple so let
me just implement it in WebGrid ...

Best regards
Janko

>> So why not just change the offending
>> object ~= objects last ifTrue: [self newRow].
>> into
>> inx ~= objects size ifTrue: [self newRow].
>>
>> Same with the beginning of the self columns do: block
>> (object == objects first and: [column width notNil])
>> change it to:
>> (inx = 1 and: [column width notNil])

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Alex Baran
In reply to this post by Nicholas Moore
Hi Nicholas,

You are welcome!


2009/4/8 Nicholas Moore <[hidden email]>:

> Herbert and Alex - thanks for the discussion, I am just starting to use
> WebGrid and have found your comments useful.
>
> Nicholas
>
>
> Alex Baran wrote:
>
> Hi Herbert,
>
> 2009/4/8 Herbert K�nig <[hidden email]>:
>
>
> Hi Alex,
>
> AB> It seems if you have object the same as (tested by equality) last
> AB> object in your grid, creation of a new row will be omitted. I think it
> AB> should be changed in Aida.
> thanks, yes the points represent a closed polygon and the format
> requires the first point repeated.
>
> WebGrid>>buildTableRows only has one sender and is private, so I could
> probably change it without endangering other code.
>
>
>  >
>
>
> WebGrid is only used in WebDemoApp and WebAdminApp but I'd like to
> know the rationale before changing it.
>
>
>
> For me the main argument to change is that this is the situation that
> I will prefer not to have in a production code. Because it requries to
> follow some hidden rule, something like "Collection must be without
> duplicates. Duplication is checked by equality.". So you need to
> mention the rule or change the code. The situation can also be danger
> with sorting, when it appear with one order and disappear with
> another.
>
>
>
>
> Wrote that yesterday evening on the train.
>
> Now I see your fix. Took me some time to understand the whole thing
> but now I disagree with extending SequencableCollection. Because the
> extension is needed once and I don't see where else it could be needed.
> (which may be because I can't see enough so tell me I'm wrong)
>
>
>
> Making extension of SequencableCollection is a way of raising
> abstraction and reuse. It's often the case with printing on some media
> that you need to insert something between elements representation. But
> to justify such change, you need to have multiple usage inside Aida.
> So, I think I will prefer your way without changing
> SequencableCollection.
>
>
>
> I think we either should use SequencableCollection>>withIndexDo:
> to not insert the last row. And inx seems to come handy.
>
> So why not just change the offending
> object ~= objects last ifTrue: [self newRow].
> into
> inx ~= objects size ifTrue: [self newRow].
>
> Same with the beginning of the self columns do: block
> (object == objects first and: [column width notNil])
> change it to:
> (inx = 1 and: [column width notNil])
>
>
> Yes, it's another potential problem, I have not grasp it before. And
> it makes argument to not extend SequantialCollection, because you need
> to work with index in two places anyway.
>
>
>
> Because the whole thing has nothing to do with the contents of the
> collection. Think of a games high score list, always 10 Players
> initialized all to the same default player.
>
> I'm trying to take Smalltalk and Aida lessons here :-))
>
>
>
> I think it what the community is about :)
>
>
> All the best,
> Alex
>
>
>
> Cheers,
>
> Herbert � � � � � � � � � � � � � �mailto:[hidden email]
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
>
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
>
> --
>
> Nicholas J Moore
> Limoges
> France
>
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
>
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Janko Mivšek
In reply to this post by Janko Mivšek
Ok, done. And it seems it work well. I'll patched my VW Aida and I hope
we will soon sync to Squeak version too.

I also put both of you to http://www.aidaweb.si/contributors.html. Now
let me look at Aleks's WebApplication patch as well...

Janko

Janko Mivšek pravi:

> Hi Herbert and Alex,
>
> Many thanks to both of you to dig into that problem, which is a result
> of my too naive detection of end of WebGrid collection. Silly me, I also
> have once the same problem but was not able to solve it :) Thanks a lot
> Alex to catch it!
>
> I also think that Herbert's solution is most practical and simple so let
> me just implement it in WebGrid ...
>
> Best regards
> Janko
>
>>> So why not just change the offending
>>> object ~= objects last ifTrue: [self newRow].
>>> into
>>> inx ~= objects size ifTrue: [self newRow].
>>>
>>> Same with the beginning of the self columns do: block
>>> (object == objects first and: [column width notNil])
>>> change it to:
>>> (inx = 1 and: [column width notNil])
>

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Alex Baran
In reply to this post by Janko Mivšek
Hi Janko,

My pleasure!

Alex
2009/4/8 Janko Mivšek <[hidden email]>:

> Hi Herbert and Alex,
>
> Many thanks to both of you to dig into that problem, which is a result
> of my too naive detection of end of WebGrid collection. Silly me, I also
> have once the same problem but was not able to solve it :) Thanks a lot
> Alex to catch it!
>
> I also think that Herbert's solution is most practical and simple so let
> me just implement it in WebGrid ...
>
> Best regards
> Janko
>
>>> So why not just change the offending
>>> object ~= objects last ifTrue: [self newRow].
>>> into
>>> inx ~= objects size ifTrue: [self newRow].
>>>
>>> Same with the beginning of the self columns do: block
>>> (object == objects first and: [column width notNil])
>>> change it to:
>>> (inx = 1 and: [column width notNil])
>
> --
> Janko Mivšek
> AIDA/Web
> Smalltalk Web Application Server
> http://www.aidaweb.si
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Herbert König
In reply to this post by Janko Mivšek
Hi Janko,

JM> I also put both of you to
JM> http://www.aidaweb.si/contributors.html. Now

Thanks
I'll try to really earn that honour some day.


Cheers,

Herbert                            mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Issue with WebGrid

Alex Baran
In reply to this post by Janko Mivšek
Janko,

Thank you for acknowledgement.

Alex

2009/4/8 Janko Mivšek <[hidden email]>:

> Ok, done. And it seems it work well. I'll patched my VW Aida and I hope
> we will soon sync to Squeak version too.
>
> I also put both of you to http://www.aidaweb.si/contributors.html. Now
> let me look at Aleks's WebApplication patch as well...
>
> Janko
>
> Janko Mivšek pravi:
>> Hi Herbert and Alex,
>>
>> Many thanks to both of you to dig into that problem, which is a result
>> of my too naive detection of end of WebGrid collection. Silly me, I also
>> have once the same problem but was not able to solve it :) Thanks a lot
>> Alex to catch it!
>>
>> I also think that Herbert's solution is most practical and simple so let
>> me just implement it in WebGrid ...
>>
>> Best regards
>> Janko
>>
>>>> So why not just change the offending
>>>> object ~= objects last ifTrue: [self newRow].
>>>> into
>>>> inx ~= objects size ifTrue: [self newRow].
>>>>
>>>> Same with the beginning of the self columns do: block
>>>> (object == objects first and: [column width notNil])
>>>> change it to:
>>>> (inx = 1 and: [column width notNil])
>>
>
> --
> Janko Mivšek
> AIDA/Web
> Smalltalk Web Application Server
> http://www.aidaweb.si
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida