control flow example not working?

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

control flow example not working?

FDominicus
Well I try to get into Aida, and to some extent I got somewhere, but
now I've troubles understanding how to do a simple thing as "CRUD"

Take this class
FooClass
id,name,value


Now I have an OrderedCollection with FooClass elements

I now want to have


id1, name1, value1,  <action>
id2, name2, value2, <action>



Now action in this case should be removing the line in which this action
is places. Now doe I have to use a button? A simple link or whatever.

And how do I "know" in which line I am?

For that to answer I tried to look into the ControlFlow example
but this  does nothing, at first it is not accessble but via the URL
entry field
http://localhost:8888/demo?view=ControlFlow

and there it just hangs around doing "nothing" while I'm clicking on the
Delete  button.

And another example does not wark also. If I click on Calendar I get an
exception

So would you mind to help me?

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

Re: control flow example not working?

Herbert König
Hi Friedrich,

look at the end of the post for how to do it with links.
FD> Well I try to get into Aida, and to some extent I got somewhere, but
FD> now I've troubles understanding how to do a simple thing as "CRUD"

Sorry I have to confess, that I tried to cook up a CRUD example with
AIDA's built in mechanism and failed badly. (see attached fileout from
Squeak trunk). Hopefully Janko finds the time to tell the canonical
ways to do this.

To use my code in a workspace you need to do:
test := DataModel new.
(AIDASite named: 'aidademo')
          urlResolver defaultURL: test preferedUrl forObject: test.

and open http://localhost:8888/cruddemo.html

But you can learn a bit from the code.

FD> Take this class
FD> FooClass
FD> id,name,value

I did something similar with my TestCustomer class.

FD> Now I have an OrderedCollection with FooClass elements
FD> I now want to have
FD> id1, name1, value1,  <action>
FD> id2, name2, value2, <action>

look at DataModelApp>>displayCustomersComponent:
on how to get this information into the WebGrid. (columnNames:,
columnAspects:).

FD> Now action in this case should be removing the line in which this action
FD> is places. Now doe I have to use a button? A simple link or whatever.

I would use a button but you could use the actionBlock: to do the deletion.
I use it to select a new line and to bring up an inspector, to know
that the block is triggered.

FD> And how do I "know" in which line I am?

look at DataModelApp>>displayCustomersComponent:
for how the line rowBlueIfTrue knows the line. Beware we don't deal
with indices into an Array each refers to the object (FooClass in your
case TestCustomer in my case)

And addBlock: also knows the object.

The part that doesn't work is: I don't want to update the single entry
in the grid but the container of the grid. That's why I pass
aWebElement into #displayCustomersComponent:

But when I change the line onClickUpdate: newText to
onClickUpdate: aWebElement the actionBlock isn't called any more.
So I'm stuck.

FD> For that to answer I tried to look into the ControlFlow example
FD> but this  does nothing, at first it is not accessble but via the URL
FD> entry field
FD> http://localhost:8888/demo?view=ControlFlow

same here.

FD> And another example does not wark also. If I click on Calendar I get an
FD> exception

works for me. So what's your Smalltalk and your Browser? BTW I had
issues when I put two calendars on a page (start date and end date for
a databese query) But that was Aida5.6 and I didn't check since then.

FD> So would you mind to help me?

As far as I can :-)) Hopefully Janko finds some time, to at least
confirm the issues or point out my mistakes.

I planned to extend my example with an entry component for adding or
changing a customer and three Buttons for create, update and delete
selected. I think this is a basic use of web applications so it would
fit well into the Aida examples.

Oh and BTW there is a way to achieve what you want to:
You take the telephone book tutorial as an example and put links to
the customers into the WebGrid. Then you create a TestCustomerApp
which in it's viewMain has Buttons for the crud operations, each of
which has an action: method associated with it which does the
operation and does a #redirectTo: to your data model. But this means
to go to a completely different page, losing the context of what you
delete before deletion.

Sorry for remembering this so late. You find it in:
http://www.aidaweb.si/tutorial.html, especially under:
7. Enhance the table


Cheers,

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

CRUD Demo.st (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: control flow example not working?

Herbert König
Hi again,

here is a version that works by using another event (onMouseOut:) to
(Ajax) update the list. Which means that you only see the update after
the mouse leaves the surname. Remember, selection is only implemented
on the surname.

The buttons use the more canonical way of action:

Use firebug to see why you want Ajax updates and no action: methods if
you (your customers) don't have a *lot* of bandwidth.

Anyway what an instructional Sunday. Bit frustrating though.

Still hoping for Janko do provide a canonical example or to fix the
actionBlock: OnClickUpdate issue.

Anyway please note, that the whole code is only 7K. Only 3K go into
the Aida application which I think is pretty good.

Cheers,

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

CRUD Demo.st (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: control flow example not working?

FDominicus
In reply to this post by Herbert König
Herbert König <[hidden email]> writes:

> Hi Friedrich,
>
> look at the end of the post for how to do it with links.
> FD> Well I try to get into Aida, and to some extent I got somewhere, but
> FD> now I've troubles understanding how to do a simple thing as "CRUD"
>
> Sorry I have to confess, that I tried to cook up a CRUD example with
> AIDA's built in mechanism and failed badly. (see attached fileout from
> Squeak trunk). Hopefully Janko finds the time to tell the canonical
> ways to do this.
>
> To use my code in a workspace you need to do:
> test := DataModel new.
> (AIDASite named: 'aidademo')
>           urlResolver defaultURL: test preferedUrl forObject: test.
>
> and open http://localhost:8888/cruddemo.html
>
> But you can learn a bit from the code.
>
> FD> Take this class
> FD> FooClass
> FD> id,name,value
>
> I did something similar with my TestCustomer class.
>
> FD> Now I have an OrderedCollection with FooClass elements
> FD> I now want to have
> FD> id1, name1, value1,  <action>
> FD> id2, name2, value2, <action>
>
> look at DataModelApp>>displayCustomersComponent:
> on how to get this information into the WebGrid. (columnNames:,
> columnAspects:).
I have this done and I think I understood it.

>
> FD> Now action in this case should be removing the line in which this action
> FD> is places. Now doe I have to use a button? A simple link or whatever.
>
> I would use a button but you could use the actionBlock: to do the deletion.
> I use it to select a new line and to bring up an inspector, to know
> that the block is triggered.

Well I tried the button.

>
> The part that doesn't work is: I don't want to update the single entry
> in the grid but the container of the grid. That's why I pass
> aWebElement into #displayCustomersComponent:

Well the container which shows the lines well be modified. So I thought
there must be way to say delete this line and "redisplay" yourself, but
I did not found a way on how to do it. This is really not good.
>
>
> works for me. So what's your Smalltalk and your Browser? BTW I had
> issues when I put two calendars on a page (start date and end date for
> a databese query) But that was Aida5.6 and I didn't check since then.
Pharo 1.1/Aida 6.1

>
> Oh and BTW there is a way to achieve what you want to:
> You take the telephone book tutorial as an example and put links to
> the customers into the WebGrid. Then you create a TestCustomerApp
> which in it's viewMain has Buttons for the crud operations, each of
> which has an action: method associated with it which does the
> operation and does a #redirectTo: to your data model. But this means
> to go to a completely different page, losing the context of what you
> delete before deletion.
I've got this  working for editin and adding. there I want to leave the
overview table, but I can not see one reason why I should go to another
page for deleting just a fow in a table. There must be a way achieving
that.

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

Re: control flow example not working?

FDominicus
In reply to this post by Herbert König
Thanks for taking the time, I appreciate it and will look into it.

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

Re: control flow example not working?

FDominicus
In reply to this post by Herbert König
Herbert König <[hidden email]> writes:

> Hi Friedrich,
>
> look at the end of the post for how to do it with links.
> FD> Well I try to get into Aida, and to some extent I got somewhere, but
> FD> now I've troubles understanding how to do a simple thing as "CRUD"
>
> Sorry I have to confess, that I tried to cook up a CRUD example with
> AIDA's built in mechanism and failed badly. (see attached fileout from
> Squeak trunk). Hopefully Janko finds the time to tell the canonical
> ways to do this.
>
> To use my code in a workspace you need to do:
> test := DataModel new.
> (AIDASite named: 'aidademo')
>           urlResolver defaultURL: test preferedUrl forObject: test.
>
> and open http://localhost:8888/cruddemo.html
I can not choose an entry, and if I do a search in the boxes above
nothing changes also. I'm using iceweasel on my box. and what I want is
a button at the end of one entry which allows me to delete the "current"
line.

Find attached the example I'm struggling with:

someTans := Tans new.
aTan := TansModel new.
aTan tanNr: '200'.

aTan tanNr isInteger.
aTan  amount: 100.0.
aTan comment: 'just a comment'.

This is the code I used to "populate" the example

I can not understand why such a baby example, gives me such headaches.


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

Aida-Tests-Tan-QSS-FriedrichDominicus.3.mcz (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: control flow example not working?

FDominicus
In reply to this post by Herbert König
sorry, I have send an older example which does not work at all:

Here's the correct version:


--
Q-Software Solutions GmbH; Sitz: Bruchsal; Registergericht: Mannheim
Registriernummer: HRB232138; Geschaeftsfuehrer: Friedrich Dominicus

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

Aida-Tests-Tan-QSS-frido.5.mcz (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: control flow example not working?

FDominicus
In reply to this post by Herbert König
Herbert König <[hidden email]> writes:

>
> Oh and BTW there is a way to achieve what you want to:
> You take the telephone book tutorial as an example and put links to
> the customers into the WebGrid. Then you create a TestCustomerApp
> which in it's viewMain has Buttons for the crud operations, each of
> which has an action: method associated with it which does the
> operation and does a #redirectTo: to your data model. But this means
> to go to a completely different page, losing the context of what you
> delete before deletion.
As you can see in the send example I've used the WebGrid, but I do *NOT*
want to leave the page go to another with the three button and run the
actions there. I want that I can change the line I'm at with just a
click on a link, it does not make sense to go to another page just to
delete the entry I'm directly seeing IMHO.


>
> Sorry for remembering this so late. You find it in:
> http://www.aidaweb.si/tutorial.html, especially under:
> 7. Enhance the table
See my example on what I did, but I'm stuck with the last part, where I
put a link or button in that row and which I want to use to delete the
line this button is in.

Regards
Friedrich
--
Q-Software Solutions GmbH; Sitz: Bruchsal; Registergericht: Mannheim
Registriernummer: HRB232138; Geschaeftsfuehrer: Friedrich Dominicus
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: control flow example not working?

FDominicus
In reply to this post by FDominicus
Friedrich Dominicus <[hidden email]> writes:

> Herbert König <[hidden email]> writes:
>
>> Hi Friedrich,
>>
>> look at the end of the post for how to do it with links.
>> FD> Well I try to get into Aida, and to some extent I got somewhere, but
>> FD> now I've troubles understanding how to do a simple thing as "CRUD"
>>
>> Sorry I have to confess, that I tried to cook up a CRUD example with
>> AIDA's built in mechanism and failed badly. (see attached fileout from
>> Squeak trunk). Hopefully Janko finds the time to tell the canonical
>> ways to do this.
>>
>> To use my code in a workspace you need to do:
>> test := DataModel new.
>> (AIDASite named: 'aidademo')
>>           urlResolver defaultURL: test preferedUrl forObject: test.
>>
>> and open http://localhost:8888/cruddemo.html
> I can not choose an entry, and if I do a search in the boxes above
> nothing changes also.
Sorry, I overread theline with selection on the Last name.

Regards
Friedrich

--
Q-Software Solutions GmbH; Sitz: Bruchsal; Registergericht: Mannheim
Registriernummer: HRB232138; Geschaeftsfuehrer: Friedrich Dominicus
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: control flow example not working?

FDominicus
In reply to this post by FDominicus
I'm getting nowhere can anyone explain to me why
this:
viewMain
        | e showTable |
        e := WebElement new.
        e addTextH1: 'Tans for QSS'.
        "self halt."
        e add: self errorReport.
        showTable := WebGrid new.
        showTable columnNames: #('Tan No' 'Amount' 'Comment' 'Action');
                columnFilters: #(true true true nil);
                sortOn: 1;
                sortOrder: #descending;
                collection: self observee usedTans;
                columnAspects: #(#tanNr #amount #comment nil);
                column: 1 addBlock: [ :each |
                        (WebElement new) addLinkTo: each text: each tanNr];
                column: 4 addBlock: [ :each | | el |
                        el := WebElement new.
                        el addLinkTo:   each text: 'Delete'.
                        el onClickDo: [ self removeTan: each].
                        ].
       
        e add: showTable.
         e addButtonText: 'Add a new entry'.
        self style pageFrameWideNoNavigationWith: e title: 'Tans for QSS'

Does not even get into removeTan ?

It can't be that terrible difficult to have more than one button on each
form.

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

Re: control flow example not working?

Janko Mivšek
Hi Frierdich,

On 06. 12. 2010 17:49, Friedrich Dominicus wrote:

> I'm getting nowhere can anyone explain to me why
> this:
> viewMain
> | e showTable |
> e := WebElement new.
> e addTextH1: 'Tans for QSS'.
> "self halt."
> e add: self errorReport.
> showTable := WebGrid new.
> showTable columnNames: #('Tan No' 'Amount' 'Comment' 'Action');
> columnFilters: #(true true true nil);
> sortOn: 1;
> sortOrder: #descending;
> collection: self observee usedTans;
> columnAspects: #(#tanNr #amount #comment nil);
> column: 1 addBlock: [ :each |
> (WebElement new) addLinkTo: each text: each tanNr];
> column: 4 addBlock: [ :each | | el |
> el := WebElement new.
> el addLinkTo:   each text: 'Delete'.
> el onClickDo: [ self removeTan: each].

Problem is in link which is active, that is, it actually send you to the
link you provided. You need to avoid that so that only click event will
be triggered. Fastest way is to use 'el adddNilLinkText:' instead. Here
the link will be 'non-clickable' but click event will be triggered.

Don't forget to add a refresh of this table too:

  el onClickUpdate: showTable.

> ].
>
> e add: showTable.
> e addButtonText: 'Add a new entry'.
> self style pageFrameWideNoNavigationWith: e title: 'Tans for QSS'
>
> Does not even get into removeTan ?
>
> It can't be that terrible difficult to have more than one button on each
> form.

Best regards
Janko


--
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: control flow example not working?

FDominicus
Janko Mivšek <[hidden email]> writes:

> Problem is in link which is active, that is, it actually send you to the
> link you provided. You need to avoid that so that only click event will
> be triggered. Fastest way is to use 'el adddNilLinkText:' instead. Here
> the link will be 'non-clickable' but click event will be triggered.
>
> Don't forget to add a refresh of this table too:
>
>   el onClickUpdate: showTable.
>> ].
Fine, I did that. Now my code looks like this:
column: 4 addBlock: [ :each | | el nL |
                        el := WebElement new.
                        (el addNilLinkText:    'Delete')
                                onClickDo: [ self removeTan: each].
                        el onClickUpdate: showTable.
                        el].

However the table is not refreshed I have to click reload. So what's
wrong with my code?

Regards
Friedrich

--
Q-Software Solutions GmbH; Sitz: Bruchsal; Registergericht: Mannheim
Registriernummer: HRB232138; Geschaeftsfuehrer: Friedrich Dominicus
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: control flow example not working?

Janko Mivšek


On 07. 12. 2010 07:56, Friedrich Dominicus wrote:

> Janko Mivšek <[hidden email]> writes:
>
>> Problem is in link which is active, that is, it actually send you to the
>> link you provided. You need to avoid that so that only click event will
>> be triggered. Fastest way is to use 'el adddNilLinkText:' instead. Here
>> the link will be 'non-clickable' but click event will be triggered.
>>
>> Don't forget to add a refresh of this table too:
>>
>>   el onClickUpdate: showTable.
>>> ].
> Fine, I did that. Now my code looks like this:
> column: 4 addBlock: [ :each | | el nL |
> el := WebElement new.
> (el addNilLinkText:    'Delete')
> onClickDo: [ self removeTan: each].
> el onClickUpdate: showTable.
> el].
>
> However the table is not refreshed I have to click reload. So what's
> wrong with my code?

Ups, I said wrongly. A link will be clickable, not an el, so:

  el := WebElement new.
  (el addNilLinkText:    'Delete')
  onClickDo: [ self removeTan: each];
  onClickUpdate: showTable.

Remember that all add methods return an argument and not receiver in
Aida, as is usual in Smalltalk add methods too.

Best regards
Janko

--
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: control flow example not working?

FDominicus
Janko Mivšek <[hidden email]> writes:

>
>   el := WebElement new.
>   (el addNilLinkText:    'Delete')
>   onClickDo: [ self removeTan: each];
>   onClickUpdate: showTable.
>
> Remember that all add methods return an argument and not receiver in
> Aida, as is usual in Smalltalk add methods too.
I'm quite aware of that anyway the code now looks like this:
column: 5 addBlock: [ :each | | el nL |
                        el := WebElement new.
                        (el addNilLinkText:    'Delete')
                                onClickDo: [ self removeTan: each];
                                onClickUpdate: showTable.
                        ].
but it does not matter. I have to manually refresh the browser to see
the line removed. So the question just persists, what am I supposed to
do to get the page "refreshed" ?

Regards
Friedrich

--
Q-Software Solutions GmbH; Sitz: Bruchsal; Registergericht: Mannheim
Registriernummer: HRB232138; Geschaeftsfuehrer: Friedrich Dominicus
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida