• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF / Primefaces Inputtext inside datatable trouble with passing value to ArrayList  RSS feed

 
Mikael Ghazarian
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I'm working on a new School Project.
I've got a datatable with Patient data also I've created for that a Model Patient.
Now I've add one column more inside this column I've got four inputtext(inputmask) (Morning, Afternoon, Evening, Night) field which allows just one number.

Each field got a binding of type String. In the getter Method I add each of this values in a ArrayList.
The User Need to pass one number to each field to say how many cigarettes the Patient smoked each day.
There is a submit button in my Controller I check if every field got a value inside if not there will Popup a Message.

If there User changes the value after Submit it just adding new values to the ArrayList and doesn't Change the first value.
I want that it changes the value inside the Arraylist at the right Position rather than to add a new one and Keep the old (and wrong) value inside the Arraylist.

Patient Model


My Controller


My Datatable


 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your "Controller" is not a Controller and I don't care what the NetBeans people say otherwise. JSF backing beans are Models with optional business logic and event listeners. In JSF the real Controllers are the FacesServlet and the logic within the tags that handles keeping the Model and View in sync (which is the very definition of a MVC Controller).

Also, this codeis just plain wrong:


A value is supposed to be a property reference not a method call.

In fact, your Table Model seems to be tilted 90 degrees. As I read it, you have a separate array for each column. The common usage is to define a Model class for the table row with a property corresponding to each column. The actual Table DataModel then consists of a collection (array, List, or other ordered collection) of Model class row instances.

Finally, if you wrap such a Table Model with a JSF DataModel class (ListDataModel or ArrayDataModel), then your action method can easily determine the row that was selected and its row number.
 
Mikael Ghazarian
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim thank your for your answer.

I tried to Change my code as you told me.
Also created a Model for my datatable.



But I still got the Problem, that I can't pass the Input values from morning, noon, evening and night.
If I put a value in it and press my commandbutton I get null returned.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!