[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

JSF Enumeration SelectManyCheckbox Validation Error

Asked by asegner in Java Server Faces (JSF), Java Server Pages (JSP), J2EE

Tags: jsf, enum, selectmanycheckbox

I 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.featuresLabel}"/>
<h:selectManyCheckbox value="#{pWizard.features}" layout="pageDirection" id="Features">
      <f:selectItems value="#{pWizard.featureTypes}" />
</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().listIterator();
            while( i.hasNext() ){
                  features.add( i.next().getType() );
            }
      }
      return features;
}
public void setFeatures(List<FeatureTypes> featList){

      FProduct t=getTemplate();
      ListIterator<FeatureTypes> li = featList.listIterator();
      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("value").getType(context);
            return Enum.valueOf(enumType,value);
      }
      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.lang.Enum</converter-for-class>
            <converter-class>util.faces.EnumTypeConverter</converter-class>
      </converter>
-------------------------



Help.... any ideas?      
[+][-]06/08/07 09:43 PM, ID: 19247300Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Java Server Faces (JSF), Java Server Pages (JSP), J2EE
Tags: jsf, enum, selectmanycheckbox
Sign Up Now!
Solution Provided By: EE_AutoDeleter
Participating Experts: 1
Solution Grade: A
 
[+][-]05/18/07 01:24 PM, ID: 19118197Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92