473,386 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Retrieving values of datatable..

Hi guys,
i've a very important question for you,i'm stopped my work from 10 days to solve it,but nothing....
i hope your can help me.
I'm developing a jsf application and i've created a datatable with empty fields, so each row of my datatable is an input row...i've associated a button to each row and cliccking them i retrieve values inserted by user(for each row) and i put them into a database.
What i want now is avoiding to use a button for each row,i want one only button at the end of page that send to database the data inserted in each row.
I've started

Expand|Select|Wrap|Line Numbers
  1. public void SendData(ActionEvent e){
  2.         System.out.println("inizio vedi riga");
  3.         List values=(List) (getBiosampleDataTable()).getValue();
  4.         System.out.println("La dimensione è "+values.size());
  5.         for (int j=0;j<values.size();j++){
  6.  
  7.             Object obj=values.get(j);
  8.             System.out.println(((Biosample) obj).getOrganism());
  9.  
  10.  
  11.             //System.out.println((String) biosampleItem.getLabel());
  12.  
  13.         }
  14.  
  15.     }

that is,
with
Expand|Select|Wrap|Line Numbers
  1. List values=(List) (getBiosampleDataTable()).getValue();
i retrieve values of datatable into a list called values.
With
Expand|Select|Wrap|Line Numbers
  1. Object obj=values.get(j);
i try to read a single row into an object

and with

Expand|Select|Wrap|Line Numbers
  1. System.out.println(((Biosample) obj).getOrganism());
i try to print the organism value for row i.
Biosample is type of managed bean used to wrapp the single row.

My question is:
Each value i retrieve is NULL!!!!!
Why?
Please help me,it's my first post....
Oct 4 '06 #1
5 5035
r035198x
13,262 8TB
Hi guys,
i've a very important question for you,i'm stopped my work from 10 days to solve it,but nothing....
i hope your can help me.
I'm developing a jsf application and i've created a datatable with empty fields, so each row of my datatable is an input row...i've associated a button to each row and cliccking them i retrieve values inserted by user(for each row) and i put them into a database.
What i want now is avoiding to use a button for each row,i want one only button at the end of page that send to database the data inserted in each row.
I've started

Expand|Select|Wrap|Line Numbers
  1. public void SendData(ActionEvent e){
  2.         System.out.println("inizio vedi riga");
  3.         List values=(List) (getBiosampleDataTable()).getValue();
  4.         System.out.println("La dimensione è "+values.size());
  5.         for (int j=0;j<values.size();j++){
  6.  
  7.             Object obj=values.get(j);
  8.             System.out.println(((Biosample) obj).getOrganism());
  9.  
  10.  
  11.             //System.out.println((String) biosampleItem.getLabel());
  12.  
  13.         }
  14.  
  15.     }

that is,
with
Expand|Select|Wrap|Line Numbers
  1. List values=(List) (getBiosampleDataTable()).getValue();
i retrieve values of datatable into a list called values.
With
Expand|Select|Wrap|Line Numbers
  1. Object obj=values.get(j);
i try to read a single row into an object

and with

Expand|Select|Wrap|Line Numbers
  1. System.out.println(((Biosample) obj).getOrganism());
i try to print the organism value for row i.
Biosample is type of managed bean used to wrapp the single row.

My question is:
Each value i retrieve is NULL!!!!!
Why?
Please help me,it's my first post....
Is there any data in the database?
what is the method SendData supposed to do and why does it take an ActionEvent if does not use it?
Oct 4 '06 #2
my datatable is generated by a list with empty values(the user has to fill its fields).
I want the method send data takes data inserted by user in the rows...
that is,the user see a datatable with many input forms(empty).
The user fill each row of the datatable,click sendData button and the values now inserted go into db...
is it possible?
With my method i retrieve only null values(as i don't retrieve inserted values,but the initial values of datatable...).
I've used actionListener to have not navigation to another page,but result don't change with action...

With my old method i've associated a command button to each row,i clicked on it and datatable row inserted go into db.
What i want know is avoiding those command button for each row,and create an only function that does it for each row...is it possible?
This is my working old method
Expand|Select|Wrap|Line Numbers
  1. public void editBiosample(ActionEvent event) throws SQLException {
  2.  
  3.  
  4.                 setBiosampleItem((Biosample) getBiosampleDataTable().getRowData());
  5.                 int index=getBiosampleDataTable().getRowIndex();
  6.  
  7.         if (conn != null) {
  8.             Experiment exp = (Experiment) ViewUtils
  9.             .eval("#{experiment}");
  10.             PreparedStatement pst3 = null;
  11.  
  12.             chiave=exp.getAutoKey();
  13.             pst3 = conn
  14.                     .prepareStatement("INSERT INTO  campione(id_campione,id_,organismo,protocollotrattamento,metodoestrazione,tipoamplificazione,protocolloibridazione,protocollomarcatura)     VALUES(null,?,?,?,?,?,?,?)");
  15.  
  16.             pst3.setInt(1, getChiave()+1);//per mantenere la coerenza con la transazione,l'id massimo della tabella precedente non è stato ancora incrementato!!
  17.             pst3.setString(2, getBiosampleItem().getOrganism());
  18.             pst3.setString(3, getBiosampleItem().getTreatmentProtocol());
  19.             pst3.setString(4, getBiosampleItem().getExtractionMethod());
  20.             pst3.setString(5, getBiosampleItem().getAmplification());
  21.             pst3.setString(6, getBiosampleItem().getHybridation());
  22.             pst3.setString(7, getBiosampleItem().getLabel());

Excuse my poor english and jsf experience...
Oct 4 '06 #3
r035198x
13,262 8TB
my datatable is generated by a list with empty values(the user has to fill its fields).
I want the method send data takes data inserted by user in the rows...
that is,the user see a datatable with many input forms(empty).
The user fill each row of the datatable,click sendData button and the values now inserted go into db...
is it possible?
With my method i retrieve only null values(as i don't retrieve inserted values,but the initial values of datatable...).
I've used actionListener to have not navigation to another page,but result don't change with action...

With my old method i've associated a command button to each row,i clicked on it and datatable row inserted go into db.
What i want know is avoiding those command button for each row,and create an only function that does it for each row...is it possible?
This is my working old method
Expand|Select|Wrap|Line Numbers
  1. public void editBiosample(ActionEvent event) throws SQLException {
  2.  
  3.  
  4.                 setBiosampleItem((Biosample) getBiosampleDataTable().getRowData());
  5.                 int index=getBiosampleDataTable().getRowIndex();
  6.  
  7.         if (conn != null) {
  8.             Experiment exp = (Experiment) ViewUtils
  9.             .eval("#{experiment}");
  10.             PreparedStatement pst3 = null;
  11.  
  12.             chiave=exp.getAutoKey();
  13.             pst3 = conn
  14.                     .prepareStatement("INSERT INTO  campione(id_campione,id_,organismo,protocollotrattamento,metodoestrazione,tipoamplificazione,protocolloibridazione,protocollomarcatura)     VALUES(null,?,?,?,?,?,?,?)");
  15.  
  16.             pst3.setInt(1, getChiave()+1);//per mantenere la coerenza con la transazione,l'id massimo della tabella precedente non è stato ancora incrementato!!
  17.             pst3.setString(2, getBiosampleItem().getOrganism());
  18.             pst3.setString(3, getBiosampleItem().getTreatmentProtocol());
  19.             pst3.setString(4, getBiosampleItem().getExtractionMethod());
  20.             pst3.setString(5, getBiosampleItem().getAmplification());
  21.             pst3.setString(6, getBiosampleItem().getHybridation());
  22.             pst3.setString(7, getBiosampleItem().getLabel());

Excuse my poor english and jsf experience...
should be possible. you'd need to name the inputs cleverly so that you'd use them in a loop. Are you using JTextFields or HTML form inputs?
You could also use JTable
Oct 4 '06 #4
Thanks for you reply but i've not understood very well....
i use this to insert data
Expand|Select|Wrap|Line Numbers
  1. <h:column>
  2.         <f:facet name="header">
  3.             <h:outputText value="#{msg.IdBiosample}" styleClass="outputText"/>
  4.         </f:facet>
  5.         <h:outputText value="Campione#{biosampleItem.id}" />
  6.     </h:column>
  7.  
  8.  
  9.     <h:column >
  10.         <f:facet name="header">
  11.             <h:outputText value="#{msg.Organism}" styleClass="outputText"/>
  12.         </f:facet>
  13.        <h:selectOneMenu value="#{biosampleItem.organism}">
  14.            <f:selectItems value="#{getDropList.selectOrganism}"/>
  15.  
  16.        </h:selectOneMenu>
  17.     </h:column>
  18.  
  19.     <h:column>
  20.         <f:facet name="header">
  21.             <h:outputText value="#{msg.Treatment}" styleClass="outputText"/>
  22.         </f:facet>
  23.         <h:inputText value="#{biosampleItem.treatmentProtocol}" styleClass="inputText"/>
  24.     </h:column>
  25.  
  26.  
what code i need to solve my problem?
Thanks very much,i hope you help me,you are my last hope....
Help me with easy code,please....i'm a newbie
Oct 4 '06 #5
r035198x
13,262 8TB
Thanks for you reply but i've not understood very well....
i use this to insert data
Expand|Select|Wrap|Line Numbers
  1. <h:column>
  2.         <f:facet name="header">
  3.             <h:outputText value="#{msg.IdBiosample}" styleClass="outputText"/>
  4.         </f:facet>
  5.         <h:outputText value="Campione#{biosampleItem.id}" />
  6.     </h:column>
  7.  
  8.  
  9.     <h:column >
  10.         <f:facet name="header">
  11.             <h:outputText value="#{msg.Organism}" styleClass="outputText"/>
  12.         </f:facet>
  13.        <h:selectOneMenu value="#{biosampleItem.organism}">
  14.            <f:selectItems value="#{getDropList.selectOrganism}"/>
  15.  
  16.        </h:selectOneMenu>
  17.     </h:column>
  18.  
  19.     <h:column>
  20.         <f:facet name="header">
  21.             <h:outputText value="#{msg.Treatment}" styleClass="outputText"/>
  22.         </f:facet>
  23.         <h:inputText value="#{biosampleItem.treatmentProtocol}" styleClass="inputText"/>
  24.     </h:column>
  25.  
  26.  
what code i need to solve my problem?
Thanks very much,i hope you help me,you are my last hope....
Help me with easy code,please....i'm a newbie
Sorry my friend but that's just as much I could contribute. You see I'm also new jsf. I only work with servlets, jsps and ejbs. I hope someone else will be able to help you. This java forum is usually quiet though. If you don't get help soon enough, you might have to try (I don't like doing this but ...) sun
Oct 4 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: anon | last post by:
I have a datatable of values and I am trying to obtain the values of a range of the columns. Imagine I have a table defined with columns headed "A" through to "Z" Now I decide that I want to...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
5
by: Dylan Parry | last post by:
Hi, At the moment I use code like the following: string myString = this.dataReader.IsDBNull(2) ? null : this.dataReader.GetString(2); With a record from the DB that looks like: ...
6
by: AlveenX | last post by:
Hi, I am trying to pick a Guid from a data row using the following code: foreach(DataRow row in MyDataTable.Rows) { (Guid)row }
0
by: funky4you | last post by:
I am using a simple select query in C# app that fetches a row which has a datatime field. The query is simple "SELECT * FROM THE USERS WHERE USER_NAME = 'ABC' ", the users table contains a...
1
by: Olaf Rabbachin | last post by:
Hi folks, I'm looking for a way of retrieving the default-value of a table's field within an Access 2003 MDB. Any hints on how to accomplish this from ASP.Net? Thanks, Olaf -- My .02:...
1
by: Chris | last post by:
Hi, I'm using the following code DataTable tables = ((OleDbConnection)oleconn).GetOleDbSchemaTable( OleDbSchemaGuid.Tables, new object { null, null, null, "TABLE" }); foreach (DataRow r in...
0
by: Phijo | last post by:
Hello, I'm a Java developer but brand new to ASP (i have done some of the tutorials) so I have some ASP programming background however I cannot find the cause or the fix to this problem. I am...
3
by: preethadotnet | last post by:
Hi, Can anyone tell me how to retrieve record values from a datatable?.My requirement is like: Within a for loop I am executing different stored procedures and storing records in a datatable...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.