in home.xhtml:

  |     <h:form id="selectSubject">
  |       <h:selectOneMenu value="#{subject}">
  |         <si:selectItems value="#{subjects}" var="s" label="#{s.title}" 
key="#{s.id}" ></si:selectItems>
  |       </h:selectOneMenu>
  |     </h:form>
  | 

in Subject.java:

  | 
  | @Name("subject")
  | public class Subject implements java.io.Serializable {
  |     private static final long serialVersionUID = -1926918108184076192L;
  |     private String id = "";
  |     private String title = "";
  |     private String description = "";
  | }
  | 
It also contains getters and setters, but for brevity I left them out.

In SubjectFactoryBean.java

  | @Stateless
  | @Name("subjectFactory")
  | @Scope(APPLICATION)
  | public class SubjectFactoryBean implements SubjectFactory {
  |     
  |     @Logger
  |     private Log log;
  |     
  |     @Out
  |     private List<Subject> subjects;
  | 
  |     @Factory("subjects")
  |         public void load() {
  |             log.debug("Loading subject list.");
  |             
  |             subjects = new ArrayList<Subject>();
  |             subjects.add( new Subject("sub-a", "Subject A") );
  |             subjects.add( new Subject("sub-b", "Subject B") );
  |             subjects.add( new Subject("sub-c", "Subject C") );
  |             
  |             log.debug("Subject list contains #0 entries.", subjects.size() 
);
  |     }
  | }
  | 

I'm getting the following error:


  | Value is no String 
(class=mil.fits.survey.Subject$$EnhancerByCGLIB$$5cdc06c9, value=subject = ) 
and component selectSubject:_id12with path: {Component-Path : [Class: 
javax.faces.component.UIViewRoot,ViewId: /home.xhtml][Class: 
javax.faces.component.html.HtmlForm,Id: selectSubject][Class: 
javax.faces.component.html.HtmlSelectOneMenu,Id: _id12]} does not have a 
Converter
  | 

So I try adding a converter....

Adding this method to SubjectFactoryBean.java

  |     public Converter getConverter() {
  |             return new SelectItemsConverter() {
  |                     @Override
  |                     protected Object convertToObject(FacesContext arg0, 
UIComponent arg1, String arg2) 
  |                             throws ConverterException {
  |                             log.debug("convertToObject(#0, #1, #2)", arg0, 
arg1, arg2);
  |                             // TODO Auto-generated method stub
  |                             return new Subject(arg2, arg2);
  |                     }
  | 
  |                     @Override
  |                     protected String convertToString(FacesContext arg0, 
UIComponent arg1, Object arg2) 
  |                             throws ConverterException {
  |                             log.debug("convertToString(#0, #1, #2)", arg0, 
arg1, arg2);
  |                             // TODO Auto-generated method stub
  |                             return arg2.toString();
  |                     }
  |                     
  |             };
  |     }
  | 

And in home.xhtml...

  |     <h:form id="selectSubject">
  |       <h:selectOneMenu value="#{subject}" 
converter="#{subjectFactory.converter}">
  |         <si:selectItems value="#{subjects}" var="s" label="#{s.title}" 
key="#{s.id}" ></si:selectItems>
  |       </h:selectOneMenu>
  |     </h:form>
  | 
  | 

Gives me the following error...

  | /home.xhtml @16,83 converter="#{subjectFactory.converter}": Exception 
  | getting value of property converter of base of type : 
  | org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$4461012a
  | 



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4000535#4000535

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4000535
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to