[vwnc] ComboBox Display String Fails

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

[vwnc] ComboBox Display String Fails

Juan Pablo Cook
Hi All!! I'm looking for your help because it doesn't work what I want to do, I don't know why.
I read the Vw Docs and see the videos of James: http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/14/08:_The_ComboBox_Widget&entry=3404103177 and http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/17/08:_ComboBox_Widget_Part_2&entry=3404359439.
So I have a comboBox where the type property is set to Object. The read method is: #stringToEmployee: and print: #employeeToString: .
First I have this:

#employeeToString: anEmployee
      ^anEmployee name

And works perfect, but later I want to add something to that string, so James told me that I have to define the #displayString method in the Employee class. I did all.
Now I have:

#employeeToString: anEmployee
       ^anEmployee displayString.

Employee Class:
#displayString
       ^self name,'  ','---',empNo.

And this fails, the error says " #, " so I can't join nothing to the string.

I hope someone knows my "stupid" problem that I can't resolve.

Thanks a lot

JP Cook



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] ComboBox Display String Fails

Juan Pablo Cook
Thanks for your reply, I put that like an example, in that case empNo is a string.
But the problem it's before, nothing works because the ,' after name don't work.
What can I do?

Thanks

On Tue, Jun 23, 2009 at 5:44 PM, Richard Wettel <[hidden email]> wrote:
Hi,

It's just a guess, but if empNo is not a string you won't be able to append it as is to another string. For example if empNo is a number, you need to send printString to it to get a string representation of the number.

Cheers,
Ricky

On Jun 23, 2009, at 10:18 PM, Juan Pablo Cook wrote:

Hi All!! I'm looking for your help because it doesn't work what I want to do, I don't know why.
I read the Vw Docs and see the videos of James: http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/14/08:_The_ComboBox_Widget&entry=3404103177 and http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/17/08:_ComboBox_Widget_Part_2&entry=3404359439.
So I have a comboBox where the type property is set to Object. The read method is: #stringToEmployee: and print: #employeeToString: .
First I have this:

#employeeToString: anEmployee
      ^anEmployee name

And works perfect, but later I want to add something to that string, so James told me that I have to define the #displayString method in the Employee class. I did all.
Now I have:

#employeeToString: anEmployee
       ^anEmployee displayString.

Employee Class:
#displayString
       ^self name,'  ','---',empNo.

And this fails, the error says " #, " so I can't join nothing to the string.

I hope someone knows my "stupid" problem that I can't resolve.

Thanks a lot

JP Cook


<ATT00001.txt>



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] ComboBox Display String Fails

Richard Wettel-2
In reply to this post by Juan Pablo Cook
Hi,

It's just a guess, but if empNo is not a string you won't be able to append it as is to another string. For example if empNo is a number, you need to send printString to it to get a string representation of the number.

Cheers,
Ricky

On Jun 23, 2009, at 10:18 PM, Juan Pablo Cook wrote:

Hi All!! I'm looking for your help because it doesn't work what I want to do, I don't know why.
I read the Vw Docs and see the videos of James: http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/14/08:_The_ComboBox_Widget&entry=3404103177 and http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/17/08:_ComboBox_Widget_Part_2&entry=3404359439.
So I have a comboBox where the type property is set to Object. The read method is: #stringToEmployee: and print: #employeeToString: .
First I have this:

#employeeToString: anEmployee
      ^anEmployee name

And works perfect, but later I want to add something to that string, so James told me that I have to define the #displayString method in the Employee class. I did all.
Now I have:

#employeeToString: anEmployee
       ^anEmployee displayString.

Employee Class:
#displayString
       ^self name,'  ','---',empNo.

And this fails, the error says " #, " so I can't join nothing to the string.

I hope someone knows my "stupid" problem that I can't resolve.

Thanks a lot

JP Cook


<ATT00001.txt>


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] ComboBox Display String Fails

Mark Plas
In reply to this post by Juan Pablo Cook

Could it be that the employee's name is nil? in that case sending ',' to it won't work.

 

You could try this:

 

displayString
       ^(self name ifNil: ['']),'  ','---',empNo.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Juan Pablo Cook
Sent: dinsdag 23 juni 2009 22:54
To: Richard Wettel; [hidden email]
Subject: Re: [vwnc] ComboBox Display String Fails

 

Thanks for your reply, I put that like an example, in that case empNo is a string.
But the problem it's before, nothing works because the ,' after name don't work.
What can I do?

Thanks

On Tue, Jun 23, 2009 at 5:44 PM, Richard Wettel <[hidden email]> wrote:

Hi,

 

It's just a guess, but if empNo is not a string you won't be able to append it as is to another string. For example if empNo is a number, you need to send printString to it to get a string representation of the number.

 

Cheers,

Ricky

 

On Jun 23, 2009, at 10:18 PM, Juan Pablo Cook wrote:

 

Hi All!! I'm looking for your help because it doesn't work what I want to do, I don't know why.
I read the Vw Docs and see the videos of James: http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/14/08:_The_ComboBox_Widget&entry=3404103177 and http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/17/08:_ComboBox_Widget_Part_2&entry=3404359439.
So I have a comboBox where the type property is set to Object. The read method is: #stringToEmployee: and print: #employeeToString: .
First I have this:

#employeeToString: anEmployee
      ^anEmployee name

And works perfect, but later I want to add something to that string, so James told me that I have to define the #displayString method in the Employee class. I did all.
Now I have:

#employeeToString: anEmployee
       ^anEmployee displayString.

Employee Class:
#displayString
       ^self name,'  ','---',empNo.

And this fails, the error says " #, " so I can't join nothing to the string.

I hope someone knows my "stupid" problem that I can't resolve.

Thanks a lot

JP Cook

<ATT00001.txt>

 

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] ComboBox Display String Fails

Juan Pablo Cook
Thanks for your reply!
I try and now it works! ;)
I put this:

^(self name ifNil: [''] ), '  ' , '---' ,self empNo.

Now I have 2 problems I think:

First one is, when I open the window, it's nothing selected so it's show , '  ' , '---', this strings.
Second one, is that the #stringToEmployee now doesn't work because don't recognize the object. This is the method:

#stringToEmployee: aString
| emp |
emp := self employeeList value
detect: [:each | each name = aString]
ifNone: [nil].

^ciud

How can I change that?

Thanks again for your help.

Hugs,
JP Cook


On Wed, Jun 24, 2009 at 4:21 AM, Mark Plas <[hidden email]> wrote:

Could it be that the employee's name is nil? in that case sending ',' to it won't work.

 

You could try this:

 

displayString
       ^(self name ifNil: ['']),'  ','---',empNo.


From: [hidden email] [mailto:[hidden email]] On Behalf Of Juan Pablo Cook
Sent: dinsdag 23 juni 2009 22:54
To: Richard Wettel; [hidden email]
Subject: Re: [vwnc] ComboBox Display String Fails

 

Thanks for your reply, I put that like an example, in that case empNo is a string.
But the problem it's before, nothing works because the ,' after name don't work.
What can I do?

Thanks

On Tue, Jun 23, 2009 at 5:44 PM, Richard Wettel <[hidden email]> wrote:

Hi,

 

It's just a guess, but if empNo is not a string you won't be able to append it as is to another string. For example if empNo is a number, you need to send printString to it to get a string representation of the number.

 

Cheers,

Ricky

 

On Jun 23, 2009, at 10:18 PM, Juan Pablo Cook wrote:

 

Hi All!! I'm looking for your help because it doesn't work what I want to do, I don't know why.
I read the Vw Docs and see the videos of James: http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/14/08:_The_ComboBox_Widget&entry=3404103177 and http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/17/08:_ComboBox_Widget_Part_2&entry=3404359439.
So I have a comboBox where the type property is set to Object. The read method is: #stringToEmployee: and print: #employeeToString: .
First I have this:

#employeeToString: anEmployee
      ^anEmployee name

And works perfect, but later I want to add something to that string, so James told me that I have to define the #displayString method in the Employee class. I did all.
Now I have:

#employeeToString: anEmployee
       ^anEmployee displayString.

Employee Class:
#displayString
       ^self name,'  ','---',empNo.

And this fails, the error says " #, " so I can't join nothing to the string.

I hope someone knows my "stupid" problem that I can't resolve.

Thanks a lot

JP Cook

<ATT00001.txt>

 

 



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] ComboBox Display String Fails

Thomas Brodt
To find an employee in the list, you have to use the same string
representation to find him, that you also use to convert the object to a
string.

If you print with (self name ifNil: [''] ), '  ' , '---' ,self empNo.),
your detect block must use the same construct to find this string
representation in the list:
    detect: [:each | ((each name ifNil: [''] ), '  ' , '---' ,each
empNo) = aString].

Or, because you wrote that in the specific method #displayString, change
the detect to:
    detect: [:each | each displayString = aString].

HTH

Thomas
 

Juan Pablo Cook schrieb:

> Thanks for your reply!
> I try and now it works! ;)
> I put this:
>
> ^(self name ifNil: [''] ), '  ' , '---' ,self empNo.
>
> Now I have 2 problems I think:
>
> First one is, when I open the window, it's nothing selected so it's
> show , '  ' , '---', this strings.
> Second one, is that the #stringToEmployee now doesn't work because
> don't recognize the object. This is the method:
>
> #stringToEmployee: aString
> | emp |
> emp := self employeeList value
> detect: [:each | each name = aString]
> ifNone: [nil].
>
> ^ciud
>
> How can I change that?
>
> Thanks again for your help.
>
> Hugs,
> JP Cook
>
>
> On Wed, Jun 24, 2009 at 4:21 AM, Mark Plas <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Could it be that the employee's name is nil? in that case sending
>     ',' to it won't work.
>      
>     You could try this:
>      
>     displayString
>            ^(self name ifNil: ['']),'  ','---',empNo.
>
>
>
>     *From:* [hidden email] <mailto:[hidden email]>
>     [mailto:[hidden email]
>     <mailto:[hidden email]>] *On Behalf Of *Juan Pablo Cook
>     *Sent:* dinsdag 23 juni 2009 22:54
>     *To:* Richard Wettel; [hidden email] <mailto:[hidden email]>
>     *Subject:* Re: [vwnc] ComboBox Display String Fails
>      
>     Thanks for your reply, I put that like an example, in that case
>     empNo is a string.
>     But the problem it's before, nothing works because the ,' after
>     name don't work.
>     What can I do?
>
>     Thanks
>     On Tue, Jun 23, 2009 at 5:44 PM, Richard Wettel
>     <[hidden email] <mailto:[hidden email]>>
>     wrote:
>     Hi,
>      
>     It's just a guess, but if empNo is not a string you won't be able
>     to append it as is to another string. For example if empNo is a
>     number, you need to send printString to it to get a string
>     representation of the number.
>      
>     Cheers,
>     Ricky
>      
>     On Jun 23, 2009, at 10:18 PM, Juan Pablo Cook wrote:
>      
>
>         Hi All!! I'm looking for your help because it doesn't work
>         what I want to do, I don't know why.
>         I read the Vw Docs and see the videos of James:
>         http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/14/08:_The_ComboBox_Widget&entry=3404103177
>         <http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/14/08:_The_ComboBox_Widget&entry=3404103177>
>         and
>         http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/17/08:_ComboBox_Widget_Part_2&entry=3404359439
>         <http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/17/08:_ComboBox_Widget_Part_2&entry=3404359439>.
>         So I have a comboBox where the type property is set to Object.
>         The read method is: #stringToEmployee: and print:
>         #employeeToString: .
>         First I have this:
>
>         #employeeToString: anEmployee
>               ^anEmployee name
>
>         And works perfect, but later I want to add something to that
>         string, so James told me that I have to define the
>         #displayString method in the Employee class. I did all.
>         Now I have:
>
>         #employeeToString: anEmployee
>                ^anEmployee displayString.
>
>         Employee Class:
>         #displayString
>                ^self name,'  ','---',empNo.
>
>         And this fails, the error says " #, " so I can't join nothing
>         to the string.
>
>         I hope someone knows my "stupid" problem that I can't resolve.
>
>         Thanks a lot
>
>         JP Cook
>
>         <ATT00001.txt>
>
>      
>      
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

[vwnc] ComboBox Display String Fails

Juan Pablo Cook
On Wed, Jun 24, 2009 at 10:01 AM, Thomas Brodt <[hidden email]> wrote:
To find an employee in the list, you have to use the same string representation to find him, that you also use to convert the object to a string.

If you print with (self name ifNil: [''] ), '  ' , '---' ,self empNo.), your detect block must use the same construct to find this string representation in the list:
  detect: [:each | ((each name ifNil: [''] ), '  ' , '---' ,each empNo) = aString].

Or, because you wrote that in the specific method #displayString, change the detect to:
  detect: [:each | each displayString = aString].

HTH

Thomas


Juan Pablo Cook schrieb:
Thanks for your reply!
I try and now it works! ;)
I put this:

^(self name ifNil: [''] ), '  ' , '---' ,self empNo.

Now I have 2 problems I think:

First one is, when I open the window, it's nothing selected so it's show , '  ' , '---', this strings.
Second one, is that the #stringToEmployee now doesn't work because don't recognize the object. This is the method:

#stringToEmployee: aString
| emp |
emp := self employeeList value
detect: [:each | each name = aString]
ifNone: [nil].

^ciud

How can I change that?

Thanks again for your help.

Hugs,
JP Cook


On Wed, Jun 24, 2009 at 4:21 AM, Mark Plas <[hidden email] <mailto:[hidden email]>> wrote:

   Could it be that the employee's name is nil? in that case sending
   ',' to it won't work.
       You could try this:
       displayString
          ^(self name ifNil: ['']),'  ','---',empNo.



   *From:* [hidden email] <mailto:[hidden email]>
   [mailto:[hidden email]
   <mailto:[hidden email]>] *On Behalf Of *Juan Pablo Cook
   *Sent:* dinsdag 23 juni 2009 22:54
   *To:* Richard Wettel; [hidden email] <mailto:[hidden email]>

   *Subject:* Re: [vwnc] ComboBox Display String Fails
       Thanks for your reply, I put that like an example, in that case
   empNo is a string.
   But the problem it's before, nothing works because the ,' after
   name don't work.
   What can I do?

   Thanks
   On Tue, Jun 23, 2009 at 5:44 PM, Richard Wettel
   <[hidden email] <mailto:[hidden email]>>

   wrote:
   Hi,
       It's just a guess, but if empNo is not a string you won't be able
   to append it as is to another string. For example if empNo is a
   number, you need to send printString to it to get a string
   representation of the number.
       Cheers,
   Ricky
       On Jun 23, 2009, at 10:18 PM, Juan Pablo Cook wrote:
   
       Hi All!! I'm looking for your help because it doesn't work
       what I want to do, I don't know why.
       I read the Vw Docs and see the videos of James:
       http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/14/08:_The_ComboBox_Widget&entry=3404103177
       <http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/14/08:_The_ComboBox_Widget&entry=3404103177>
       and
       http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/17/08:_ComboBox_Widget_Part_2&entry=3404359439
       <http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_11/17/08:_ComboBox_Widget_Part_2&entry=3404359439>.
       So I have a comboBox where the type property is set to Object.
       The read method is: #stringToEmployee: and print:
       #employeeToString: .
       First I have this:

       #employeeToString: anEmployee
             ^anEmployee name

       And works perfect, but later I want to add something to that
       string, so James told me that I have to define the
       #displayString method in the Employee class. I did all.
       Now I have:

       #employeeToString: anEmployee
              ^anEmployee displayString.

       Employee Class:
       #displayString
              ^self name,'  ','---',empNo.

       And this fails, the error says " #, " so I can't join nothing
       to the string.

       I hope someone knows my "stupid" problem that I can't resolve.

       Thanks a lot

       JP Cook

       <ATT00001.txt>
       


------------------------------------------------------------------------

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



Thanks for your help, I put detect: [:each | each displayString = aString] and works perfectly. Now I have the other problem I commented.
When I entered the window, I want that the comboBox show nothing. Now with this string: ^(self name ifNil: [''] ), '  ' , '---' ,self empNo, it's showing: " --- nil " until you select one of the list.
How can I say that when it's nothing selected shows '' (nothing) ??

The next point is that I want to show the name of the job of the employee too. I have this in another table in the DB, so I call a message that I put the number of the Employee and he give me the job!. I will add:

#displayString
                       | adm jobs |
            adm := Administrator new.
            jobs := adm searhJob: empNo value.

^(self name ifNil: ['']) , '  ' , '---' ,self empNo, '  ' , '---' , jobs name.

But jobs name fails because it's nil I think, I don't know If it's correct to do it here what I want to do. (I'm not sure but It think it's entering like in a infinitive loop).

Thanks a lot for your patience.

Bye friends!

Juan Cook



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc