Yes, in my situation, the converters are all registered by class, so I
cannot call a Converter constructor (or a converter property).
Having a value binding was the best possible compromise -- after all,
I can change the registered managed bean in the config file or in the
code if it came to that.   Realistically, my backing bean doesn't
change all that often.  My "database-layer backed select item
provider" beans are code-generated and static.

On 9/15/06, Sławek Sobótka <[EMAIL PROTECTED]> wrote:
thanx for response and sharing of Your ideas.

i would like to register ma converter and use it on many pages.
but when i hardcode this
#{backingBean.selectItemList}
than obvoiusly my converter is coupled with one specific bean (and
few specific pages - in optimistic case) :/


btw: now im doing it like this:


public class BackingBean{

        private List<SelectItem> items;

        public List<SelectItem> getItems(){
                return items
        };

        public Converter getConverter(){
                return new MyClassConverter(getItems());
        }
}


i dont like my solution cause i just dont want to repeat:
public Converter getConverter(){
        return new MyClassConverter(getItems());
}
in every bean that backs my combo controls (but it works and is
flexible)

best regards and once again thanks for response

Sławek S.

> Yeah, this is an ugly situation because converters don't allow
> StateHolder like Validators and Components and it's hard to
initialize
> them with a set of values.
>
> Here's how I handle it.  I store the stuff in a backing bean and
> programmically fetch a reference to the backing bean.  In your case,
> the value binding would be the same one used in the page tag.
>
>         ValueBinding binding =
>
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{backingBean.selectItemList}");
>         List list = (List
> )binding.getValue(FacesContext.getCurrentInstance());
>
>
>
> On 9/15/06, Sławek Sobótka <[EMAIL PROTECTED]> wrote:
>> welome back guys. after 1 year of coding fat swt/swing clients i'm
>> backing to jsf business (and to your great comunity;).
>>
>> i can't find SelectItems list in nym converter:(
>>
>> here is the situation:
>> i have selectManyListbox thats value is binded to List<Workplcae>.
>> select items are binded to List<SelectItem> but each SelectItem's
>> value is set to one of the Workplace object.
>>
>> so we have class situation that needs converter - im working on
object
>> instead of threis IDs cause it is comfortable with hibernate stuff.
>>
>> w would like to do it like this:
>> //========================================
>> public Object getAsObject(FacesContext fc, UIComponent comp, String
>> str) throws ConverterException {
>>                 UISelectMany selectMany = (UISelectMany) comp;
>>                 List<SelectItem> workplaces = selectMany.
>> getAllSelectItemsThatAreBindedToComponent(); //<<<======= problem
>>                 Integer id = new Integer(str);
>>                 for (SelectItem o : workplaces)
>>                         if
(((Workplace)o.getValue()).getWorkPlaceId().
>> equals(id))
>>                                 return o.getValue();
>>                 return null;
>>         }
>> //========================================
>>
>> where can i find method like this:
>> List<SelectItem> workplaces = selectMany.
>> getAllSelectItemsThatAreBindedToComponent();
>> cause i dont want to fetch all Workplaces from DB once again?
>>
>> best regards Sławek S.
>>
>> ----------------------------------------------------
>> Codziennie nowe oferty pracy czekają na Ciebie - Sprawdż!
>> Kliknij: http://klik.wp.pl/?adr=www.praca.wp.pl&sid=870
>>
>>
>>



----------------------------------------------------
Mega koncert - Duran Duran - Warszawa Służewiec 23 września 2006!
Zdobądź bilet dla siebie i swoich przyjaciół - Kliknij:
http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Fd2.html&sid=862



Reply via email to