[Seaside] JQWidget nested options

Gastón Dall' Oglio gaston.dalloglio at gmail.com
Thu Sep 1 21:50:15 UTC 2011


Ok. I ask you becouse GRSmallDictionary have method with js concern.

Now, in my image Pharo 1.3, the class comment on SmallDictionary is same to
RBSmallDictionary, but last class is smaller even. But, with neither of
those classes the code of example works fine.

|dict array value1 value2|
value1 := 'abcd'.
value2 := 12345.
dict:= SmallDictionary new.
dict at: 'subop1' put: value1.
dict at: 'subop2' put: value2.
array:=Array with: dict.
 array asJson =>  '[["abcd",12345]]'

and this one throw a exception

|dict array value1 value2|
value1 := 'abcd'.
value2 := 12345.
dict:= RBSmallDictionary new.
dict at: 'subop1' put: value1.
dict at: 'subop2' put: value2.
array:=Array with: dict.
array asJson  => 'Override #jsonOn: to make the receiver serializeable as
JSON'


Finally, I will use the Dictionary class, and I go on coding my widget :)

Thanks Paul.


2011/9/1 Paul DeBruicker <pdebruic at gmail.com>

> I don't know when it would matter or when users would notice a difference,
> performance wise.  See the class comment on SmallDictionary and see if that
> is better suited to your plugin's use case than just a regular Dictionary.
>  The GRSmallDictionary is a cross platform compatible implementation of the
> SmallDictionary.
>
> I'm sure both would be fine for most use cases.
>
>
>
>
>
> On 09/01/2011 05:12 PM, Gastón Dall' Oglio wrote:
>
>> I see in the JQPluing class
>>
>> optionAt: aKey put: aValue
>>  ^ self options at: aKey put: aValue
>>
>> and
>>
>> options
>> ^ options ifNil: [ options := GRSmallDictionary new ]
>>
>> Then, is better use GRSmallDictionary for the subops pairs? Like this:
>>
>> |dict array value1 value2|
>> value1 := 'abcd'.
>> value2 := 12345.
>> dict:= GRSmallDictionary new.
>> dict at: 'subop1' put: value1.
>> dict at: 'subop2' put: value2.
>> array:=Array with: dict.
>> array asJson
>>
>>
>> 2011/9/1 Gastón Dall' Oglio <gaston.dalloglio at gmail.com
>> <mailto:gaston.dalloglio at gmail.com>>
>>
>>
>>    Ohhhhh of course, a Array with a Dictionary!!! This was so obvious
>>    (but not for me jeje).
>>    When I complete my first JQWidget, I share it with you.
>>    Thanks.
>>
>>    2011/9/1 Paul DeBruicker <pdebruic at gmail.com
>>    <mailto:pdebruic at gmail.com>>
>>
>>
>>        You need to create a Dictionary and then put that in your array
>>
>>        You can test it in a workplace like this:
>>
>>        |dict array  value1 value2|
>>        value1 := 'abcd'.
>>        value2 := 12345.
>>        dict:=Dictionary new.
>>        dict at: 'subop1' put: value1.
>>        dict at: 'subop2' put: value2.
>>        array:=Array with: dict.
>>        array asJson
>>
>>
>>
>>
>>
>>        so your code should become
>>
>>        self optionAt: 'op1' put (Array with: aDictionary).
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>        On 09/01/2011 10:40 AM, Gastón Dall' Oglio wrote:
>>
>>            Hello.
>>
>>            I'm writing a new JQWidget component and I need generate js
>>            code like
>>            this for correctly load of the wrapped plugin:
>>
>>  $("#id").funcname({"op1":[{"subop1":"value1","subop2":"value2",...}],...});
>>
>>
>>            I don't know how do it. I have a method
>>            JQMyWidget>>subop1:value, where
>>            I write some [stupid] implementation:
>>
>>            1) self optionAt: 'op1' put: (Array with: 'subop1' with:
>>            value)     =>
>>                $("#id").funcname({"op1":["subop1","value"]})
>>
>>            2) self optionAt: 'op1' put: ('subop1' -> value)     =>
>>            $("#id").funcname({"op1":'subop1'->'value'})
>>
>>            3) self optionAt: 'op1' put: (self optionAt: 'subop1' put:
>>            value)     =>
>>                $("#id").funcname({"op1":"value","subop1":"value"})
>>
>>            Any idea? Thanks in advance.
>>
>>
>>            _______________________________________________
>>            seaside mailing list
>>            seaside at lists.squeakfoundation.org
>>            <mailto:seaside at lists.squeakfoundation.org>
>>
>>
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>>        _______________________________________________
>>        seaside mailing list
>>        seaside at lists.squeakfoundation.org
>>        <mailto:seaside at lists.squeakfoundation.org>
>>
>>        http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>>
>>
>>
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110901/071c3285/attachment.htm


More information about the seaside mailing list