Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > sending a value from a datatable column..

Reply
Thread Tools

sending a value from a datatable column..

 
 
gbattine
Guest
Posts: n/a
 
      09-06-2006
Hi guys,
i've one important question for you....
I've developed a jsf datatable with 5 fixed columns and a button that
allows to user to add a dynamic column. I've a submit button for each
row of datatable that when it's clicked send the first 5 column values
into a table and the dynamic columns values added from user into
another table,as different rows.
For example
usa french england italy germany rome naples

i want that usa french england italy germany go as a row into a table
while rome and naples as different rows into another table.
My problem is with rome and naples that i'm not able to send into table
because i'vent understood how binding column value to bean
property...can you help me?
This is my jsp page(important code)
<t:columns value="#{biosamplesTable.columnDataModel}" var="column" >
<f:facet name="header">
<hanelGroup>
<hutputText value="#{column}" />
<h:commandLink actionListener="#{biosamplesTable.removeColumn}">
<hutputText value="Elimina"/>
</h:commandLink>
</hanelGroup>
</f:facet>
<h:inputText value="#{biosampleProperties.value}" />
</t:columns>

and this is my class


public class BiosamplesTable {
private List biosamples= new ArrayList();
private List columns;
private HtmlDataTable biosampleDataTable;
private int autokey2;
private Biosample biosampleItem;

private int nrows;
private DataModel mColumns;
private int load=0;
private String columnLabel;
public HtmlDataTable getBiosampleDataTable() {

return biosampleDataTable;
}

public void setBiosampleDataTable(HtmlDataTable biosampleDataTable) {
this.biosampleDataTable = biosampleDataTable;
}

public Biosample getBiosampleItem() {
return biosampleItem;
}

public void setBiosampleItem(Biosample biosampleItem) {
this.biosampleItem = biosampleItem;
}

public List getBiosamples() throws Exception {

loadBiosamples();
// Reload after every request.

return biosamples;
}


public void setBiosamples(List biosamples) {
this.biosamples = biosamples;
}

public void loadBiosamples() throws Exception {

if (load==0){


for (int i = 0; i < nrows; i++) {
Biosample biosample = new Biosample();
biosamples.add(biosample);
setBiosamples(biosamples);
load=1;
}
}
else
{
setBiosamples(biosamples);
}
}


public void editBiosample(ActionEvent event) throws SQLException {

setBiosampleItem((Biosample) getBiosampleDataTable().getRowData());
//biosamples.add(getBiosampleItem());

DataSource dataSource = Singleton.getInstance().getDataSource();

Connection conn = dataSource.getConnection();


for (int i=0;i<columns.size();i++){
PreparedStatement pst4 = null;
pst4 = conn.prepareStatement("INSERT INTO
proprietacampione(IdCampione,Valore) VALUES(?,?)");

pst4.setInt(1, autokey2);
pst4.setString(2,bio.getValue());

pst4.executeUpdate();

pst4.close();

}

conn.close();
FacesContext facesContext = FacesContext
.getCurrentInstance();
facesContext.addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_ERROR,"",
"Biosample aggiunto"));
}
}

public DataModel getColumnDataModel()
{
if (mColumns == null)
{
String[] result = new String[]{};
mColumns = new ListDataModel(new
ArrayList(Arrays.asList(result)));
}
return mColumns;
}
public void addColumn(ActionEvent e)
{
if(columnLabel!=null);//metter l'if
{
columns = (List) getColumnDataModel().getWrappedData();
columns.add(columnLabel);

}

}

public void removeColumn(ActionEvent e)
{
if (mColumns != null && mColumns.isRowAvailable())
{
Object column = mColumns.getRowData();
List columns = (List) getColumnDataModel().getWrappedData();
columns.remove(column);
}
}

public int getAutokey2(){
return autokey2;
}
public void setAutokey2(int autokey2){
this.autokey2=autokey2;
}


public String getColumnLabel(){
return columnLabel;
}
public void setColumnLabel(String columnLabel){
this.columnLabel=columnLabel;
}
public List getColumns(){
return columns;
}
public void setColumns(List columns){
this.columns=columns;
}

}

please help me

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort a datatable and create a new datatable Fredrik Rodin ASP .Net 3 09-28-2007 07:28 AM
How can I add a row from a typed datatable to another instance of that typed datatable? Ersin Gençtürk ASP .Net 1 10-06-2004 01:11 PM
Create a Datatable from a SQL datatable column shema? jg ASP .Net 1 08-17-2004 09:43 PM
Casting DataTable to class inherit from DataTable =?Utf-8?B?Qmx1ZWZsb3dlcg==?= ASP .Net 0 04-02-2004 05:41 AM
Adding DataTable Rows To another DataTable J. Babe ASP .Net 1 08-15-2003 05:04 PM



Advertisments