asegner,
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.
EE_AutoDeleter
Main Topics
Browse All TopicsI am in the process of learning JSF and have been working on this for some number of days with no success. I have an Enum and want to display its values on a page as checkboxes and have those populate a bean when submitted. It never seems to even try to populate the bean as i never see setFeatures get called. The only message i get back is
Validation Error "Features": Value is not a valid option.
Despite many hours, I cannot get it to work. Please let me know if you see what I am doing wrong.
JSP
-----------------------
<h:outputText value="#{pageMsgs.features
<h:selectManyCheckbox value="#{pWizard.features}
<f:selectItems value="#{pWizard.featureTy
</h:selectManyCheckbox>
-----------------------
Java File
-----------------------
//Feature methods
public List<SelectItem> getFeatureTypes(){
List<SelectItem> types = new LinkedList<SelectItem>();
for( FeatureTypes type : FeatureTypes.values() ){
types.add(new SelectItem( type, type.toString() ) );
}
return types;
}
public List<FeatureTypes> getFeatures(){
FProduct t=getTemplate();
if (features==null){
features = new LinkedList<FeatureTypes>()
ListIterator<FFeature> i = t.getFeatures().listIterat
while( i.hasNext() ){
features.add( i.next().getType() );
}
}
return features;
}
public void setFeatures(List<FeatureTy
FProduct t=getTemplate();
ListIterator<FeatureTypes>
LinkedList<FFeature> ffList = new LinkedList<FFeature>();
while( li.hasNext() ){
FeatureTypes ftype = li.next();
ffList.add( new FFeature(ftype) );
}
features=featList;
t.setFeatures(ffList);
}
private FProduct template=null;
List<FeatureTypes> features;
-----------------------
And I found this Enum converter while wandering around on Google, doesnt seem to help with much, I dont ever see the getAsObject method called, although JSF loves the getAsString method.
Enum Converter
-----------------------
public class EnumTypeConverter implements Converter {
public Object getAsObject(FacesContext context, UIComponent comp, String value) throws ConverterException {
Class enumType = comp.getValueBinding("valu
return Enum.valueOf(enumType,valu
}
public String getAsString(FacesContext context, UIComponent comp, Object object) throws ConverterException {
if (object == null) {
return null;
}
Enum type = (Enum) object;
return type.toString();
}
}
------------------------
faces-config.xml
------------------------
<converter>
<converter-for-class>java.
<converter-class>util.face
</converter>
-------------------------
Help.... any ideas?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: asegnerPosted on 2007-05-18 at 13:24:30ID: 19118197
For anyone experiencing this issue, changing the implementation from using Lists to the basic arrays seems to work just fine. Apparently JSF just has piss poor support for Lists at the moment.
featTypeList){ features);
e").getTyp e(context) ; ); e);
A small snippet of what I'm talking about:
public void setFeatures(FeatureTypes[]
List<FFeature> features = new ArrayList<FFeature>();
for(int i=0; i < featTypeList.length; i++){
features.add( new FFeature( featTypeList[i] ) );
}
getTemplate().setFeatures(
}
and i had to modify the converter slightly to account for the array types:
public class EnumTypeConverter implements Converter {
public Object getAsObject(FacesContext context, UIComponent comp, String value) throws ConverterException {
Class enumType = comp.getValueBinding("valu
if( enumType.isArray() ) enumType = enumType.getComponentType(
return Enum.valueOf(enumType,valu
}
....