Creating a date component to avoid repeating code

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

Creating a date component to avoid repeating code

Sanjay Minni
Hi,

How can I create a date component when I can use at several places.  
Currently I end up repeating code below wherever I need to accept date (with the JQuery date picker).
I would attempt something similar to accept currency (right justified, fixed decimal places and commas)
===
    html textInput
        value: ( tr date printFormat: #(1 2 3 $/ 1 1 2) );
        placeholder: 'dd/mm/yyyy';
        callback: [ :value |  <method>: ( Date readFrom: value pattern: 'dd/mm/yyyy' ) ];
        script: (html jQuery new datepicker
                autoSize: true;
                dateFormat: 'dd/mm/yy';
                changeMonth: true;
                changeYear: true;
                onSelect: ( html jQuery ajax serializeThis ) )
===

regards
Sanjay
cheers,
Sanjay
Reply | Threaded
Open this post in threaded view
|

Re: Creating a date component to avoid repeating code

jtuchel
Hi Sanjay,

Subclass WAComponent, implement your render code in renderContentOn:, that's basically it.
It is probably a good idea to add an instvar for the date instance to that new Component.

Hth,

Joachim

Am 26.03.2015 11:23 schrieb Sanjay Minni <[hidden email]>:

>
> Hi,
>
> How can I create a date component when I can use at several places. 
> Currently I end up repeating code below wherever I need to accept date (with
> the JQuery date picker).
> I would attempt something similar to accept currency (right justified, fixed
> decimal places and commas)
> ===
>     html textInput
> value: ( tr date printFormat: #(1 2 3 $/ 1 1 2) );
> placeholder: 'dd/mm/yyyy';
> callback: [ :value |  <method>: ( Date readFrom: value pattern:
> 'dd/mm/yyyy' ) ];
> script: (html jQuery new datepicker
> autoSize: true;
> dateFormat: 'dd/mm/yy';
> changeMonth: true;
> changeYear: true;
> onSelect: ( html jQuery ajax serializeThis ) )
> ===
>
> regards
> Sanjay
>
>
>
> -----
> ---
> Regards, Sanjay
> --
> View this message in context: http://forum.world.st/Creating-a-date-component-to-avoid-repeating-code-tp4815256.html 
> Sent from the Seaside General 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
Reply | Threaded
Open this post in threaded view
|

Re: Creating a date component to avoid repeating code

Sanjay Minni
Hi Joachim

I got that and have a date component now,
MyDateComponent with accessors myDate and myDate:

but what is the usual approach to using the component ... will it be a child component  (seaside book section 12.1) - so I need to
- initialize
- add it as a child in >>children
- html render: dateComponent

the issue will be that if the entry screen is like a table with n rows, each having a date component then while creating / deleting a row I will have to sync the entry in the >>children method. or am I totally offtrack here

what is the usual approach to use this component

Regards
Sanjay

jtuchel wrote
Hi Sanjay,

Subclass WAComponent, implement your render code in renderContentOn:, that's basically it.
It is probably a good idea to add an instvar for the date instance to that new Component.

Hth,

Joachim

Am 26.03.2015 11:23 schrieb Sanjay Minni <[hidden email]>:
>
> Hi,
>
> How can I create a date component when I can use at several places. 
> Currently I end up repeating code below wherever I need to accept date (with
> the JQuery date picker).
> I would attempt something similar to accept currency (right justified, fixed
> decimal places and commas)
> ===
>     html textInput
> value: ( tr date printFormat: #(1 2 3 $/ 1 1 2) );
> placeholder: 'dd/mm/yyyy';
> callback: [ :value |  <method>: ( Date readFrom: value pattern:
> 'dd/mm/yyyy' ) ];
> script: (html jQuery new datepicker
> autoSize: true;
> dateFormat: 'dd/mm/yy';
> changeMonth: true;
> changeYear: true;
> onSelect: ( html jQuery ajax serializeThis ) )
> ===
>
> regards
> Sanjay
>
>
>
> -----
> ---
> Regards, Sanjay
> --
> View this message in context: http://forum.world.st/Creating-a-date-component-to-avoid-repeating-code-tp4815256.html 
> Sent from the Seaside General 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
cheers,
Sanjay