Re: confused about selectOneItem and converter and data binding

2008-11-09 Thread papayaone

Papayaone.com is a online wholesale electronics web. Maybe you are finding
China products all the time. Maybe you are finding the cheap 
http://www.papayaone.com China Wholesale Electronics .But you can't find the
satisfaction goods most time. You may feel the price is high or the quality
is not so good .and the service is not so fast.
Now I give you a good choice, at this website you can buy cheap electronics
you want. It supply  
http://www.papayaone.com/alcohol-breath-testers-c-52.html   Alcohol Breath
Testers  ,  http://www.papayaone.com/women-clothing-c-73_75.html Korea
Fahion Clothing  ,  http://www.papayaone.com/cameras-camcorders-c-45.html 
Carmeras Camcorders , and   http://www.papayaone.com/car-c-47.html Car
accessories .the   http://www.papayaone.com/cell-phone-accessories-c-3.html
cell phone accessories ,the cheap China 
http://www.papayaone.com/cell-phones-c-2.html cell phone , 
http://www.papayaone.com/cell-phone-watches-c-2_25.html cell phone watches 
and  http://www.papayaone.com/triband-phones-c-2_24.html Tri-brand cell
phone .The web also give a fashion  
http://www.papayaone.com/digital-quran-c-72.html Digital Quran ,
http://www.papayaone.com/tv-cell-phones-c-2_26.html TV cell phone  
http://www.papayaone.com/iphone-accessories-c-43.html iPhone accessories , 
http:// http://www.papayaone.com/flashlights-c-57.html Flashlights , 
http://www.papayaone.com/audio-c-1.html MP3/4 Audio .Wish you can choice a
satisfaction items from it.

Hope you do a good job!

-
China wholesale electronics
http://www.papayaone.com papayaone 
http://www.papayaone.com/triband-projector-mobile-p-658.html
http://www.papayaone.com/triband-projector-mobile-p-658.html 
-- 
View this message in context: 
http://www.nabble.com/confused-about-selectOneItem-and-converter-and-data-binding-tp20358278p20415034.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.



Re: confused about selectOneItem and converter and data binding

2008-11-08 Thread Anton Gavazuk
Hi Simon

THANKS YOU VERY MUCH

I always forget that this is HTML and everything must be in the html -
its my mistake - thats why I was wondered about calls to getAsString

You are right about converter

about getAsString
If value in item property has type Number or so - just return object.toString();

Again thanks!

2008/11/7 Simon Kitching <[EMAIL PROTECTED]>:
> An html select element looks like this:
>  
>Volvo
>Saab
>Fiat
>Audi
>  
>
> You have:
>  
> 
> where the getSelectItems() method returns a list of SelectItem objects
> whose string is the text  you want to display, and the value is a
> ComplexProp object, right?
>
> So the renderer for the f:selectItems writes out one  tag for
> each item in the list. The body text for the  tag is taken from
> the SelectItem.label property. The SelectItem.value is a ComplexProp
> object, and so the converter.getAsString method is called to generate
> the string to write out as the "value" attribute. Obviously this occurs
> once for each item in the list.
>
> When the form is posted back, the browser will include in the posted
> form data the *string value* of whatever option was selected by the
> user. JSF calls the converter once, to map this string back to a
> ComplexProp object, then (in update-model phase) stores the resulting
> object using the "value" EL-expression of the h:selectOneMenu component.
>
> So on render, getAsString is called N times, and on postback getAsObject
> is called once.
>
> Regards, Simon
>
> Anton Gavazuk schrieb:
>> Hi dushyant,
>>
>> thanks for response -
>>
>> which value I should return in getAsString method? - actual Key
>> element or Value element? - because the selectOneItem is populated by
>> SelectItem's elements.
>>
>> and why in debug I see that getAsString method is being called for N
>> times (over all elements in binded array)?
>>
>> 2008/11/7 dushyant agarwal <[EMAIL PROTECTED]>:
>>
>>> In case of selection,  the getAsObject would convert the selected value as 
>>> specified and send it to BB. In getAsString() method you again have to 
>>> specify some code to change the BB value into one of the values in the 
>>> selectItem list, bound to the selectOneMenu component.
>>>
>>>
>>>
>>> --- On Fri, 7/11/08, Anton Gavazuk <[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>> From: Anton Gavazuk <[EMAIL PROTECTED]>
>>>> Subject: Re: confused about selectOneItem and converter and data binding
>>>> To: "MyFaces Discussion" 
>>>> Date: Friday, 7 November, 2008, 3:41 PM
>>>> Guys,
>>>> does anyone have any idea?
>>>>
>>>> 2008/11/6 Anton Gavazuk <[EMAIL PROTECTED]>:
>>>>
>>>>> Hi all,
>>>>>
>>>>> have a problem
>>>>>
>>>>> I have the JSF Bean dataBean with property complexprop
>>>>>
>>>> - the type of
>>>>
>>>>> field is ComplexType
>>>>> I want to set an certain property to the bean via
>>>>>
>>>> selectItems, which
>>>>
>>>>> is being collected from the
>>>>>
>>>> anotherDataBean.selectItems - it returns
>>>>
>>>>> array of SelectItems.
>>>>>
>>>>> so it looks like
>>>>>
>>>>> 
>>>>> >>>>
>>>> value="#{dataBean.complexprop}">
>>>>
>>>>>>>>>
>>>> value="#{anotherDataBean.selectItems}"/>
>>>>
>>>>>>>>>
>>>> converterId="geoConverter"/>
>>>>
>>>>> 
>>>>>
>>>>> Of course it wouldnt not work because JSF would try
>>>>>
>>>> convert the String
>>>>
>>>>> value from UI to internal dataBean.complexprop type
>>>>>
>>>> and vice versa so
>>>>
>>>>> I added the converter
>>>>> But I cannot understand how to work properly with it -
>>>>>
>>>> during the call
>>>>
>>>>> the method is being called for count =
>>>>>
>>>> selectItems.size()
>>>>
>>>>> Converter.getAsString(FacesContext facesContext,
>>>>>
>>>> UIComponent
>>>>
>>>>> uiComponent, Object o)
>>>>>
>>>>> What could be wrong?
>>>>>
>>>>> How to link together all such things?
>>>>>
>>>>>
>>>  Add more friends to your messenger and enjoy! Go to 
>>> http://messenger.yahoo.com/invite/
>>>
>>>
>>
>>
>
>
> --
> -- Emails in "mixed" posting style will be ignored
> -- (http://en.wikipedia.org/wiki/Posting_style)
>
>


Re: confused about selectOneItem and converter and data binding

2008-11-07 Thread Simon Kitching
An html select element looks like this:
  
Volvo
Saab
Fiat
Audi
  

You have:
  
 
where the getSelectItems() method returns a list of SelectItem objects
whose string is the text  you want to display, and the value is a
ComplexProp object, right?

So the renderer for the f:selectItems writes out one  tag for
each item in the list. The body text for the  tag is taken from
the SelectItem.label property. The SelectItem.value is a ComplexProp
object, and so the converter.getAsString method is called to generate
the string to write out as the "value" attribute. Obviously this occurs
once for each item in the list.

When the form is posted back, the browser will include in the posted
form data the *string value* of whatever option was selected by the
user. JSF calls the converter once, to map this string back to a
ComplexProp object, then (in update-model phase) stores the resulting
object using the "value" EL-expression of the h:selectOneMenu component.

So on render, getAsString is called N times, and on postback getAsObject
is called once.

Regards, Simon

Anton Gavazuk schrieb:
> Hi dushyant,
>
> thanks for response -
>
> which value I should return in getAsString method? - actual Key
> element or Value element? - because the selectOneItem is populated by
> SelectItem's elements.
>
> and why in debug I see that getAsString method is being called for N
> times (over all elements in binded array)?
>
> 2008/11/7 dushyant agarwal <[EMAIL PROTECTED]>:
>   
>> In case of selection,  the getAsObject would convert the selected value as 
>> specified and send it to BB. In getAsString() method you again have to 
>> specify some code to change the BB value into one of the values in the 
>> selectItem list, bound to the selectOneMenu component.
>>
>>
>>
>> --- On Fri, 7/11/08, Anton Gavazuk <[EMAIL PROTECTED]> wrote:
>>
>> 
>>> From: Anton Gavazuk <[EMAIL PROTECTED]>
>>> Subject: Re: confused about selectOneItem and converter and data binding
>>> To: "MyFaces Discussion" 
>>> Date: Friday, 7 November, 2008, 3:41 PM
>>> Guys,
>>> does anyone have any idea?
>>>
>>> 2008/11/6 Anton Gavazuk <[EMAIL PROTECTED]>:
>>>   
>>>> Hi all,
>>>>
>>>> have a problem
>>>>
>>>> I have the JSF Bean dataBean with property complexprop
>>>> 
>>> - the type of
>>>   
>>>> field is ComplexType
>>>> I want to set an certain property to the bean via
>>>> 
>>> selectItems, which
>>>   
>>>> is being collected from the
>>>> 
>>> anotherDataBean.selectItems - it returns
>>>   
>>>> array of SelectItems.
>>>>
>>>> so it looks like
>>>>
>>>> 
>>>> >>> 
>>> value="#{dataBean.complexprop}">
>>>   
>>>>>>> 
>>> value="#{anotherDataBean.selectItems}"/>
>>>   
>>>>>>> 
>>> converterId="geoConverter"/>
>>>   
>>>> 
>>>>
>>>> Of course it wouldnt not work because JSF would try
>>>> 
>>> convert the String
>>>   
>>>> value from UI to internal dataBean.complexprop type
>>>> 
>>> and vice versa so
>>>   
>>>> I added the converter
>>>> But I cannot understand how to work properly with it -
>>>> 
>>> during the call
>>>   
>>>> the method is being called for count =
>>>> 
>>> selectItems.size()
>>>   
>>>> Converter.getAsString(FacesContext facesContext,
>>>> 
>>> UIComponent
>>>   
>>>> uiComponent, Object o)
>>>>
>>>> What could be wrong?
>>>>
>>>> How to link together all such things?
>>>>
>>>> 
>>  Add more friends to your messenger and enjoy! Go to 
>> http://messenger.yahoo.com/invite/
>>
>> 
>
>   


-- 
-- Emails in "mixed" posting style will be ignored
-- (http://en.wikipedia.org/wiki/Posting_style)



Re: confused about selectOneItem and converter and data binding

2008-11-07 Thread Anton Gavazuk
Hi dushyant,

thanks for response -

which value I should return in getAsString method? - actual Key
element or Value element? - because the selectOneItem is populated by
SelectItem's elements.

and why in debug I see that getAsString method is being called for N
times (over all elements in binded array)?

2008/11/7 dushyant agarwal <[EMAIL PROTECTED]>:
> In case of selection,  the getAsObject would convert the selected value as 
> specified and send it to BB. In getAsString() method you again have to 
> specify some code to change the BB value into one of the values in the 
> selectItem list, bound to the selectOneMenu component.
>
>
>
> --- On Fri, 7/11/08, Anton Gavazuk <[EMAIL PROTECTED]> wrote:
>
>> From: Anton Gavazuk <[EMAIL PROTECTED]>
>> Subject: Re: confused about selectOneItem and converter and data binding
>> To: "MyFaces Discussion" 
>> Date: Friday, 7 November, 2008, 3:41 PM
>> Guys,
>> does anyone have any idea?
>>
>> 2008/11/6 Anton Gavazuk <[EMAIL PROTECTED]>:
>> > Hi all,
>> >
>> > have a problem
>> >
>> > I have the JSF Bean dataBean with property complexprop
>> - the type of
>> > field is ComplexType
>> > I want to set an certain property to the bean via
>> selectItems, which
>> > is being collected from the
>> anotherDataBean.selectItems - it returns
>> > array of SelectItems.
>> >
>> > so it looks like
>> >
>> > 
>> > > value="#{dataBean.complexprop}">
>> >> value="#{anotherDataBean.selectItems}"/>
>> >> converterId="geoConverter"/>
>> > 
>> >
>> > Of course it wouldnt not work because JSF would try
>> convert the String
>> > value from UI to internal dataBean.complexprop type
>> and vice versa so
>> > I added the converter
>> > But I cannot understand how to work properly with it -
>> during the call
>> > the method is being called for count =
>> selectItems.size()
>> > Converter.getAsString(FacesContext facesContext,
>> UIComponent
>> > uiComponent, Object o)
>> >
>> > What could be wrong?
>> >
>> > How to link together all such things?
>> >
>
>
>  Add more friends to your messenger and enjoy! Go to 
> http://messenger.yahoo.com/invite/
>


Re: confused about selectOneItem and converter and data binding

2008-11-07 Thread dushyant agarwal
In case of selection,  the getAsObject would convert the selected value as 
specified and send it to BB. In getAsString() method you again have to specify 
some code to change the BB value into one of the values in the selectItem list, 
bound to the selectOneMenu component.



--- On Fri, 7/11/08, Anton Gavazuk <[EMAIL PROTECTED]> wrote:

> From: Anton Gavazuk <[EMAIL PROTECTED]>
> Subject: Re: confused about selectOneItem and converter and data binding
> To: "MyFaces Discussion" 
> Date: Friday, 7 November, 2008, 3:41 PM
> Guys,
> does anyone have any idea?
> 
> 2008/11/6 Anton Gavazuk <[EMAIL PROTECTED]>:
> > Hi all,
> >
> > have a problem
> >
> > I have the JSF Bean dataBean with property complexprop
> - the type of
> > field is ComplexType
> > I want to set an certain property to the bean via
> selectItems, which
> > is being collected from the
> anotherDataBean.selectItems - it returns
> > array of SelectItems.
> >
> > so it looks like
> >
> > 
> >  value="#{dataBean.complexprop}">
> > value="#{anotherDataBean.selectItems}"/>
> > converterId="geoConverter"/>
> > 
> >
> > Of course it wouldnt not work because JSF would try
> convert the String
> > value from UI to internal dataBean.complexprop type
> and vice versa so
> > I added the converter
> > But I cannot understand how to work properly with it -
> during the call
> > the method is being called for count =
> selectItems.size()
> > Converter.getAsString(FacesContext facesContext,
> UIComponent
> > uiComponent, Object o)
> >
> > What could be wrong?
> >
> > How to link together all such things?
> >


  Add more friends to your messenger and enjoy! Go to 
http://messenger.yahoo.com/invite/


Re: confused about selectOneItem and converter and data binding

2008-11-07 Thread Anton Gavazuk
Guys,
does anyone have any idea?

2008/11/6 Anton Gavazuk <[EMAIL PROTECTED]>:
> Hi all,
>
> have a problem
>
> I have the JSF Bean dataBean with property complexprop - the type of
> field is ComplexType
> I want to set an certain property to the bean via selectItems, which
> is being collected from the anotherDataBean.selectItems - it returns
> array of SelectItems.
>
> so it looks like
>
> 
> 
>
>
> 
>
> Of course it wouldnt not work because JSF would try convert the String
> value from UI to internal dataBean.complexprop type and vice versa so
> I added the converter
> But I cannot understand how to work properly with it - during the call
> the method is being called for count = selectItems.size()
> Converter.getAsString(FacesContext facesContext, UIComponent
> uiComponent, Object o)
>
> What could be wrong?
>
> How to link together all such things?
>


confused about selectOneItem and converter and data binding

2008-11-06 Thread Anton Gavazuk
Hi all,

have a problem

I have the JSF Bean dataBean with property complexprop - the type of
field is ComplexType
I want to set an certain property to the bean via selectItems, which
is being collected from the anotherDataBean.selectItems - it returns
array of SelectItems.

so it looks like







Of course it wouldnt not work because JSF would try convert the String
value from UI to internal dataBean.complexprop type and vice versa so
I added the converter
But I cannot understand how to work properly with it - during the call
the method is being called for count = selectItems.size()
Converter.getAsString(FacesContext facesContext, UIComponent
uiComponent, Object o)

What could be wrong?

How to link together all such things?