This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Problem to save Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem to save" Watch "Problem to save" New topic

Problem to save

William Flores

Joined: Dec 14, 2011
Posts: 29

Hi guys!
I have problem with selectManyCheckbox. Not is saving my object selected on selectManyCheckBox.
I have a selectManyCheckBox in my view and the values from database.

"alunoController.alunoMotivo" is a List of AlunoMotivo. AlunoMotivo is a bean class of a relationship NxN.
Below is a piece of my controller class AlunoController.

"alunoMotivo.get(i).getCodMotivo()" is null, I don't know why. But "alunoMotivo.get(i)" has the value. So I can't save them.
Do you undestand my problem?
Thanks for while!

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15947

If I read that correctly, you are attempting to use a scalar JDBC function (setInt) to store a vector object (collection of ints). That doesn't work, JSF or not.

Customer surveys are for companies who didn't pay proper attention to begin with.
William Flores

Joined: Dec 14, 2011
Posts: 29

Yes, I have a collection of AlunoMotivo and I did that "for" to insert id of aluno one per one "ps.setInt(2, alunoMotivo.get(i).getCodMotivo())"

That "getCodMotivo()" return a int, follow below my class AlunoMotivo.
William Flores

Joined: Dec 14, 2011
Posts: 29

One question...
selectManyCheckbox return a array of String or a List of String?
William Flores

Joined: Dec 14, 2011
Posts: 29

I solved this problem. I set List of String(List<String>) and now it is working
It is sorta covered in the JavaRanch Style Guide.
subject: Problem to save
Similar Threads
NullPointerException in selectManyCheckbox
Checked SelectManyCheckbox Values are not written to Backingbean Property
selectManyCheckBox within a panelgrid?
jsf:datatable with selectManyCheckbox problem