• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Saloon Keeper
Posts: 28417
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic