Using Insertions and Script Aculo

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

Using Insertions and Script Aculo

Oleg Richards
Hello!

Does anybody knows how to use insertions in the following context:


This is function, which called from evaluator of InPlaceEditor:

renderDependentValuesForRow: aRow withReport: aReport on: script
       
        "HERE I NEED CHECK FOR VALUE AND DO FOLLOWING"
        " IF VALUE IS INVALID"
           " IF I ALREADY HAVE INVALID ROW MESSAGE THEN UPDATE IT  
CONTENTS" - REMOVE
          " IF I DONT HAVE INVALID ROW MESSAGE YET, I SHOULD INSERT IT AFTER  
THIS ROW" - INSERTION
        " IF VALUE IS VALID"
          " CHECK IF I HAVE INVALID ROW MESSAGE, IF YES REMOVE IT"

        (aRow allDependentRows select: [:each | each template = template])  
do: [:each |
                script element id: each fullCode; render:(NumberPrintPolicy print:
                        (aReport getInLocalCurrencyAt: (self fullRowCode: each  
withSegment: businessSegment)) using: '#,###').
        ]

I need help with the algorithm in UPPERCASE. How to check is object  
(DOM element) already exists? How to remove it,
  how to replace its content, how to insert object after the existing  
one.

Guys can somebody help me to implement the following with ScriptAculo  
in seaside. I understand many things, but i can't
understand how to do it in Seaside :(.



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

Re: Using Insertions and Script Aculo

Lukas Renggli
> How to remove it,

   html element id: 'foo'; remove.

>   how to replace its content

   " replace directly using a string "
   html element id: 'foo'; update: 'bar'.

or

   " replace directly using a rendering context r "
   html element id: 'foo'; render: [ :r | r text: 'bar' ].

or

  " replace asynchronously using a rendering context r "
  html update id: 'foo'; callback: [ :r | r text: 'bar' ].

> how to insert object after the existing
> one.

  " insert after the given object "
  html update id: 'foo'; insertion: SUInsertion after; callback: [ :r
| r div: 'bar' ]

Search the mailing list for #evaluator, if you want to combine
multiple of these actions into one.

> Guys can somebody help me to implement the following with ScriptAculo
> in seaside. I understand many things, but i can't
> understand how to do it in Seaside :(.

All in all you can do all the operations you ask for. Usually your can
make your job much simpler if you just drop to idea to insert/remove
as small DOM elements as possible, but instead just update a bigger
surrounding DOM element.

Lukas

--
Lukas Renggli
http://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: Using Insertions and Script Aculo

Oleg Richards
Thank you very much for your small "tutorial"..
But can you also help me to ensure, that DOM object exists. I need to check for existense, before removing it or making insertiong

Cheers, Oleg

Lukas Renggli wrote
> How to remove it,

   html element id: 'foo'; remove.

>   how to replace its content

   " replace directly using a string "
   html element id: 'foo'; update: 'bar'.

or

   " replace directly using a rendering context r "
   html element id: 'foo'; render: [ :r | r text: 'bar' ].

or

  " replace asynchronously using a rendering context r "
  html update id: 'foo'; callback: [ :r | r text: 'bar' ].

> how to insert object after the existing
> one.

  " insert after the given object "
  html update id: 'foo'; insertion: SUInsertion after; callback: [ :r
| r div: 'bar' ]

Search the mailing list for #evaluator, if you want to combine
multiple of these actions into one.

> Guys can somebody help me to implement the following with ScriptAculo
> in seaside. I understand many things, but i can't
> understand how to do it in Seaside :(.

All in all you can do all the operations you ask for. Usually your can
make your job much simpler if you just drop to idea to insert/remove
as small DOM elements as possible, but instead just update a bigger
surrounding DOM element.

Lukas

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

Re: Using Insertions and Script Aculo

Lukas Renggli
> Thank you very much for your small "tutorial"..
> But can you also help me to ensure, that DOM object exists. I need to check
> for existense, before removing it or making insertiong

As I said, it is much easier to do the whole logic in Smalltalk and
just regenerate the whole part without the element ...

Anyway, it is possible in JavaScript with something like that:

   "if the element #foo is there, remove it "
   (html selector new add: '#foo'; size)
       then: (html element id: 'foo'; remove)

This generates something like:

   $$('#foo').size() ? $('foo').remove()

Lukas

--
Lukas Renggli
http://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: Using Insertions and Script Aculo

Lukas Renggli
On 9/24/07, Lukas Renggli <[hidden email]> wrote:

> > Thank you very much for your small "tutorial"..
> > But can you also help me to ensure, that DOM object exists. I need to check
> > for existense, before removing it or making insertiong
>
> As I said, it is much easier to do the whole logic in Smalltalk and
> just regenerate the whole part without the element ...
>
> Anyway, it is possible in JavaScript with something like that:
>
>    "if the element #foo is there, remove it "
>    (html selector new add: '#foo'; size)
>        then: (html element id: 'foo'; remove)
>
> This generates something like:
>
>    $$('#foo').size() ? $('foo').remove()

Actually, I think the following code is much simpler (and doesn't
require the latest version of script.aculo.us):

     html selector add: '#foo'; do: [ :ea | ea element remove ]

This code just iterates over the elements matching #foo and removes
them (if there is one available).

Cheers,
Lukas

--
Lukas Renggli
http://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: Using Insertions and Script Aculo

Oleg Richards
Thank you my friend :)
I would like to explain you a task, and then if you have an idea you can recommend me how to do the same with smalltalk.

1 - I Have a financial report form with a lot of filled rows.
2 - I've created a view with an InPlaceEditing feature, which gives me ability to change values of rows, which have no formulas on fly. InPlaceEditor triggers also update of all dependent rows. All this works..
3 - I also want to display additional rows after some of them, to show that the previous row is invalid. And i also want to show in that row some info, that can help you to solve the problem. Maybe its better to be done with tooltips. I really don't know what is better. So now we have something like:

Row: Description - Value with inplaceeditior
Row: Information of validator

4 - I need to add one more trigger to inplaceeditor not only to update dependent rows, but to check for current situation in validation. And after that i should make decision to insert "invalid row message", change it, or remove it..

Do you have an idea of implementing it? Is it better to do this part without AJAX?

Cheers, Oleg
Reply | Threaded
Open this post in threaded view
|

Re: Using Insertions and Script Aculo

Sophie424
In reply to this post by Lukas Renggli

"Lukas Renggli" <[hidden email]> wrote in message
>> How to remove it,
>
>   html element id: 'foo'; remove.
> ...

Wow! Is there any place where such gems, invaluable to newbies, are or can
be organized and recorded?



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

Re: Re: Using Insertions and Script Aculo

Lukas Renggli
> Wow! Is there any place where such gems, invaluable to newbies, are or can
> be organized and recorded?

Maybe in a new section of the new Seaside FAQ?

   http://www.seaside.st/documentation/faq

Lukas

--
Lukas Renggli
http://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: Using Insertions and Script Aculo

Oleg Richards
In reply to this post by Lukas Renggli
And a little question:
How to use insertion with evaluator. I've tried neary everything but without success. So i have only script object and how can i execute insertion with rendering contenxt from it
Reply | Threaded
Open this post in threaded view
|

Re: Using Insertions and Script Aculo

Lukas Renggli
> And a little question:
> How to use insertion with evaluator. I've tried neary everything but without
> success. So i have only script object and how can i execute insertion with
> rendering contenxt from it

Did you try something like this:

    html evaluator callback: [ :script |
        script insertion
            id: 'foo';
            bottom;
            with: [ :r | r div: 'foo' ]

--
Lukas Renggli
http://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: Using Insertions and Script Aculo

Lukas Renggli
In reply to this post by Oleg Richards
> 3 - I also want to display additional rows after some of them, to show that
> the previous row is invalid. And i also want to show in that row some info,
> that can help you to solve the problem. Maybe its better to be done with
> tooltips. I really don't know what is better. So now we have something like:
>
> Row: Description - Value with inplaceeditior
> Row: Information of validator

Maybe change the class of the row to make it visually stand out:

    html element
        id: 'row231';
        addClassName: 'invalid'

And add a tooltip (this will be simpler as soon as Prototype 1.6 is out):

    html element
       id: 'row231';
       access: 'title';
       assign: 'This is invalid because of bla bla bla ...'

> Do you have an idea of implementing it? Is it better to do this part without
> AJAX?

I think the simplest is to update the whole table. Otherwise it very
much depends on your actual implementation and how you generate the
report. Without knowing more about your approach I cannot give further
suggestions ...

Lukas

--
Lukas Renggli
http://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: Using Insertions and Script Aculo

Oleg Richards
Lukas what do you think about it:

http://www.nickstakenburg.com/projects/prototip/ - this is a tooltip based on prototype. How do you is it good idea to use in for tooltip information about invalid rows (i need do display a lot of information, so i think that default title for row is not enough to show all info).

How can i execute JS code, that will add tooltip from this library to element. And then remove it? How do it from seaside SU?
Reply | Threaded
Open this post in threaded view
|

Re: Using Insertions and Script Aculo

Lukas Renggli
> Lukas what do you think about it:

That library looks cool and easy to integrate with Seaside and Scriptaculous.

> How can i execute JS code, that will add tooltip from this library to
> element. And then remove it? How do it from seaside SU?

I would follow the implementation of SUEffect:

1. Create a sibling to SUEffect called SUTip.

2. Override #defaultPrototype.

3. Implement helper methods as you find them in the documentation.

4. Import the JavaScript code into a WAFileLibrary.

5. Commit your changes to SqueakSource so that others can use your
library as well.

Cheers,
Lukas

--
Lukas Renggli
http://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: Using Insertions and Script Aculo

Sebastian Sastre-2
In reply to this post by Oleg Richards
I'm also will need that tips. If I can help with something just shout

        cheers,

Sebastian Sastre


> -----Mensaje original-----
> De: [hidden email]
> [mailto:[hidden email]] En nombre
> de Oleg Richards
> Enviado el: Lunes, 24 de Septiembre de 2007 15:13
> Para: [hidden email]
> Asunto: Re: [Seaside] Using Insertions and Script Aculo
>
>
> Lukas what do you think about it:
>
> http://www.nickstakenburg.com/projects/prototip/ - this is a
> tooltip based on prototype. How do you is it good idea to use
> in for tooltip information about invalid rows (i need do
> display a lot of information, so i think that default title
> for row is not enough to show all info).
>
> How can i execute JS code, that will add tooltip from this
> library to element. And then remove it? How do it from seaside SU?
> --
> View this message in context:
> http://www.nabble.com/Using-Insertions-and-Script-Aculo-tf4504
363.html#a12865099
> Sent from the Squeak - Seaside mailing list archive at Nabble.com.
>
> _______________________________________________
> 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