getAsString converts the Object to a String and getAsObject converts
the String back to an Object.

The behaviour should be like this:

MyBean foo = // get a bean from somewhere
Converter converter = // get a converter that converts MyBeans.
String fooString = converter.getAsString(foo);
MyBean bar = converter.getAsObject(fooString);

foo.equals(bar);  // should return true.


Basically, the converter needs to convert an object to a String that
can be used later to recreate that Object.  You can do this many
different ways.  We have a unique id for every type of object and
store all objects in session.  Our converter just returns that unique
id and pulls the objects from session using a Map.


On Wed, 16 Mar 2005 16:49:25 +0000, Kostas Karadamoglou
<[EMAIL PROTECTED]> wrote:
> Hi again thank you for your reply,
> I am new to JSF so I need some information on how to create converters.
> Do you know any site one the internet that has such information?
> 
> I have already looked on the internet but I only foound converters for
> String not for
> other classes.
> 
> Can you give directions on how to implement the getAsString and
> getAsObject ?
> 
> 
> Heath Borders wrote:
> 
> >Yes, you must write a converter for Category.
> >
> >The object you pass as the 'value' of your SelectItem objects should
> >be of a type that is assignment-compatible with the property you've
> >bound to your component.
> >
> >
> >On Wed, 16 Mar 2005 10:05:13 +0000, Kostas Karadamoglou
> ><[EMAIL PROTECTED]> wrote:
> >
> >
> >>Hello I have a problem with the selectItems tag
> >>Bellow I have the method that brings the value attribute of the tag:
> >>
> >>   public List getCategories() {
> >>       ArrayList retValue = new ArrayList();
> >>       retValue.add(new SelectItem("","Choose a category..."));
> >>       for(Iterator iter=this.eventRegistry.getCategories().iterator();
> >>iter.hasNext();){
> >>           Category category=(Category)iter.next();
> >>           retValue.add(new SelectItem(category,category.getTitle()));
> >>       }
> >>       return retValue;
> >>   }
> >>
> >>When I run the web application I get the following exception:
> >>
> >>javax.faces.FacesException: There is no registered converter for class
> >>essex.cc403.hbeans.Category
> >>
> >>Do I really  need to write a converter for the Category? Can I avoid it?
> >>Can you axplain me what I have to do because I am not familiar with JSF
> >>
> >>Thank you in advanec, kostas
> >>
> >>
> >>
> >
> >
> >
> >
> 
> 


-- 
-Heath Borders-Wing
[EMAIL PROTECTED]

Reply via email to