Re: [Newbies] [Magritte] default value again

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

Re: [Newbies] [Magritte] default value again

stéphane ducasse-2
Mathieu

you should register to the maggrite smallwiki pier mailing-list this  
way lukas will reply to you.
looks for [hidden email]

Stef

On 28 mai 06, at 02:51, math wrote:

> Hello,
>
> I have folllowing the exercises of Magritte
> (http://www.lukas-renggli.ch/smalltalk/magritte) but I can't set the
> default value of nationality field.
> Here my code:
>
> descriptionNationality
>     ^ (MASingleOptionDescription auto: 'nationality' label:
> 'Nationality' priority: 55)
>         options: #( 'France' 'England' 'Switzerland' 'Span' );
>         default: 'Switzerland';
>         beSorted;
>         yourself
>
> Somthing strange is that I have 2 selected option blanck.
> I have try to do this with Title option and it work.:
>
> descriptionTitle
>     ^ (MASingleOptionDescription auto: 'title' label: 'Title'  
> priority: 10)
>         options: #( 'Mr.' 'Mrs.' 'Ms.' 'Miss.' );
>         default: 'Mrs';
>         yourself.
>
> If somone know what is going wrong :-\ ...
>
> Thanks.
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Newbies] [Magritte] default value again

Lukas Renggli-2
> you should register to the maggrite smallwiki pier mailing-list this
> way lukas will reply to you. looks for [hidden email]

Yes, this would be easier ;-)

>> I have folllowing the exercises of Magritte
>> (http://www.lukas-renggli.ch/smalltalk/magritte) but I can't set the
>> default value of nationality field.
>> Here my code:
>>
>> descriptionNationality
>>     ^ (MASingleOptionDescription auto: 'nationality' label:
>> 'Nationality' priority: 55)
>>         options: #( 'France' 'England' 'Switzerland' 'Span' );
>>         default: 'Switzerland';
>>         beSorted;
>>         yourself
>>
>> Somthing strange is that I have 2 selected option blanck.
>> I have try to do this with Title option and it work.:
>>
>> descriptionTitle
>>     ^ (MASingleOptionDescription auto: 'title' label: 'Title'
>> priority: 10)
>>         options: #( 'Mr.' 'Mrs.' 'Ms.' 'Miss.' );
>>         default: 'Mrs';
>>         yourself.

This works for me. I create a new class Tester with those two  
descriptions on the class side and tried in Seaside:

TesterTask>>go
        | t |
        t := Tester new.
        [ self call: (t asComponent addValidatedForm; yourself) ] repeat

1. For the 'title' nothing is selected, because the default value is  
not in the list of options.

2. For the 'nationality' Switzerland is selected.

How does your model code looks like? Is it already initialized with  
something other than nil? Maybe you should give a little more context  
(a file-out) so that your problem can be tackled ;-)

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch



_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Newbies] [Magritte] default value again

Mathieu SUEN
In reply to this post by stéphane ducasse-2

>>> Hello,
>>>
>>> I have folllowing the exercises of Magritte
>>> (http://www.lukas-renggli.ch/smalltalk/magritte) but I can't set the
>>> default value of nationality field.
>>> Here my code:
>>>
>>> descriptionNationality
>>>     ^ (MASingleOptionDescription auto: 'nationality' label:
>>> 'Nationality' priority: 55)
>>>         options: #( 'France' 'England' 'Switzerland' 'Span' );
>>>         default: 'Switzerland';
>>>         beSorted;
>>>         yourself
>>>
>>> Somthing strange is that I have 2 selected option blanck.
>>> I have try to do this with Title option and it work.:
>>>
>>> descriptionTitle
>>>     ^ (MASingleOptionDescription auto: 'title' label: 'Title'
>>> priority: 10)
>>>         options: #( 'Mr.' 'Mrs.' 'Ms.' 'Miss.' );
>>>         default: 'Mrs';
>>>         yourself.
>>>
>>> If somone know what is going wrong :-\ ...
>>>
>>> Thanks.
> This works for me. I create a new class Tester with those two  
> descriptions on the class side and tried in Seaside:
>
> TesterTask>>go
>     | t |
>     t := Tester new.
>     [ self call: (t asComponent addValidatedForm; yourself) ] repeat
>
> 1. For the 'title' nothing is selected, because the default value is  
> not in the list of options.
>
> 2. For the 'nationality' Switzerland is selected.
>
> How does your model code looks like? Is it already initialized with  
> something other than nil? Maybe you should give a little more context  
>  
In fact I use the tutorial package peek up from
http://mc.lukas-renggli.ch/tutorial/.

I have just saw the mistake with 'Mrs'  what is  strange is that  I have
a new option  'Mrs' with out the dot in my list.
Correcting this, nothing change for Nationality but he work for Title.

(I use Magritte 1.0.7 and Seaside 2.6)



 


       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Newbies] [Magritte] default value again

Mathieu SUEN

Hi,

>> This works for me. I create a new class Tester with those two  
>> descriptions on the class side and tried in Seaside:
>>
>> TesterTask>>go
>>     | t |
>>     t := Tester new.
>>     [ self call: (t asComponent addValidatedForm; yourself) ] repeat
>>
>> 1. For the 'title' nothing is selected, because the default value is  
>> not in the list of options.
>>
>> 2. For the 'nationality' Switzerland is selected.
>>
>> How does your model code looks like? Is it already initialized with  
>> something other than nil? Maybe you should give a little more context  
>>  
>>    
> In fact I use the tutorial package peek up from
> http://mc.lukas-renggli.ch/tutorial/.
>
> I have just saw the mistake with 'Mrs'  what is  strange is that  I have
> a new option  'Mrs' with out the dot in my list.
> Correcting this, nothing change for Nationality but he work for Title.
>
> (I use Magritte 1.0.7 and Seaside 2.6)
>  
Sorry.
I have found it out.
I have been modifing the accessor for  nationality to provide a default
Object.
+ I have make a stupide things:

MAPersonModel>>nationality
    ^ nationality isNil ifTrue: [ ^'' ] ifFalse: [ ^nationality ].

Those the problem could appear if I do sothing like this (suppose that
nationality is a String):

MAPersonModel>>nationality
    ^ nationality isNil ifTrue: [ nationality :='' ]

And why..

Thanks


       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Newbies] [Magritte] default value again

Ramon Leon-4
>
> MAPersonModel>>nationality
>     ^ nationality isNil ifTrue: [ nationality :='' ]
>
> And why..
>
> Thanks

Just a tip, try this pattern if you "need" to set the inst var...

nationality
   ^nationality ifNil:[nationality := '']

and this if you don't and always use the accessor regardless

nationality
   ^nationality ifNil:['']


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Newbies] [Magritte] default value again

Ramon Leon-4
In reply to this post by Mathieu SUEN
>
> MAPersonModel>>nationality
>     ^ nationality isNil ifTrue: [ ^'' ] ifFalse: [ ^nationality ].
>
> Those the problem could appear if I do sothing like this (suppose that
> nationality is a String):
>
> MAPersonModel>>nationality
>     ^ nationality isNil ifTrue: [ nationality :='' ]
>
> And why..
>
> Thanks


By the way, setting the default value via Magritte, only sets that value
"if" you actually hit an edit form and press save, otherwise Magritte
has not yet been invoked and the accessor will return null from your biz
object.  Setting the default value in the accessor will ensure the
default value is always returned regardless of whether the object has
been edited via a Magritte generated form.


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
_______________________________________________
Smallwiki mailing list
[hidden email]
http://impara.de/mailman/listinfo/smallwiki