convertEnum - ClassCastException
w17chm4n Nov 15, 2007 5:58 AMCan anybody tell me why I`m getting this:
java.lang.ClassCastException: com.blstream.inquisitor.ejb3.entities.Question
I`m trying to make checkManyCheckbox working
View
<h:form>
<h:selectManyCheckbox>
<ui:repeat var="cat" value="#{questionCategoryList}">
<fieldset>
<legend><h:outputText value="Category: #{cat.categoryName}" /></legend>
<h:selectManyCheckbox value="${pollQuestionsList}">
<s:selectItems var="question" value="#{cat.questionList}" label="#{question.question}"/>
<s:convertEnum />
</h:selectManyCheckbox>
</fieldset>
</ui:repeat>
</h:selectManyCheckbox>
<h:commandButton type="submit" value="Submit" action="#{PollController.addPoll}"/>
</h:form>
PollController
@Stateful
@Scope(ScopeType.SESSION)
@Name("PollController")
public class PollControllerBean implements PollController {
@Logger
Log log;
@In(create = true)
private Poll poll;
@In(required = false)
private List<Question> pollQuestionsList;
public PollControllerBean() {
}
public void addPoll() {
log.info(pollQuestionsList.toString());
}
public void removePoll() {
}
@Remove @Destroy
public void destroy() {}
}
Question entity
@Entity
@Scope(ScopeType.CONVERSATION)
@Name("question")
@Table(name="Questions")
public class Question implements Serializable {
@Id @GeneratedValue
private Long id;
@NotNull @Length(min=5, max=100)
private String question;
@NotNull @OneToOne
private QuestionType questionType;
@ManyToOne
private QuestionCategory category;
@OneToOne
private Picture picture;
@NotNull
private int questionValue;
@NotNull @Temporal(value = TemporalType.TIMESTAMP)
private Date created;
@OneToMany
private List<Answer> answers;
@ManyToMany
private List<Poll> pools;
@ManyToMany
private List<Test> tests;
@Override
public boolean equals(Object obj) {
if (!(obj instanceof QuestionCategory) || this.id == null) {
return false;
}
return this.id.equals(((QuestionCategory)obj).getId());
}
public Question() {
}
public Question(String question, QuestionCategory category) {
this.question = question;
this.category = category;
this.questionValue = 0;
}
public Question(String question, QuestionCategory category, int questionValue) {
this.question = question;
this.category = category;
this.questionValue = questionValue;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public QuestionCategory getCategory() {
return category;
}
public void setCategory(QuestionCategory category) {
this.category = category;
}
public int getQuestionValue() {
return questionValue;
}
public void setQuestionValue(int questionValue) {
this.questionValue = questionValue;
}
public List<Poll> getPools() {
return pools;
}
public void setPools(List<Poll> pools) {
this.pools = pools;
}
public List<Test> getTests() {
return tests;
}
public void setTests(List<Test> tests) {
this.tests = tests;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Picture getPicture() {
return picture;
}
public void setPicture(Picture picture) {
this.picture = picture;
}
public QuestionType getQuestionType() {
return questionType;
}
public void setQuestionType(QuestionType questionType) {
this.questionType = questionType;
}
public List<Answer> getAnswers() {
return answers;
}
public void setAnswers(List<Answer> answers) {
this.answers = answers;
}
}