G
gbattine
Hi guys,
i've a question for you for a problem that i have in my jsf application
from 10 day and i'm trying to solve it but nothing....please help me.
I'm using 2 nested datatables as described in BalusC article.
I need using them for input fields,so i have a command button at the
end of each row.
My jsp page is
<h:dataTable
value="#{biosamplesTable.outerList}"
var="outerItem"
binding="#{biosamplesTable.outerDataTable}"
cellpadding="5" border="3" cellspacing="5">
<h:column>
<h:inputText value="#{outerItem.name}" />
</h:column>
<h:column>
<h:inputText value="#{outerItem.value}" />
</h:column>
<h:column>
<h:dataTable
value="#{biosamplesTable.innerList}"
var="innerItem"
<h:inputText value="#{innerItem.nam}" />
</h:column>
<h:column>
<h:inputText value="#{innerItem.valor}" />
</h:column>
</h:dataTable>
</h:column>
<h:column>
<f:facet name="header">
<hutputText value="Actions" />
</f:facet>
<h:commandButton value="Invia"
actionListener="#{biosamplesTable.send}"/>
</h:column>
</h:dataTable
and i've one InnerListMap that maps the index of outerList with the
right innerList.
My problem is that i'm not able to pass the values inserted from user
to innerList,that have ever null values,while outerList go well.
This is my loadInnerListMap
public void loadInnerListMap() {
for (Iterator iter = outerList.iterator(); iter.hasNext() {
MyData outerItem = (MyData) iter.next();
List innerList = new ArrayList();
MyData2 mydata=new MyData2();
mydata.setNam("italy");
mydata.setValor("naples");
innerList.add(mydata);
innerList.add(new MyData2());
innerList.add(new MyData2());
innerListMap.put(outerItem.getId(), innerList);
}
}
with this code i set the value for the first row of each innerlist and
it goes well...for the second and third row i pass null values and i'm
not able to pass user'values.
This is my send action
public void send(ActionEvent e) throws Exception{
System.out.println("Il numero di lista passatoè "+ident);
List innerListNew = (List) innerListMap.get(((MyData)
outerDataTable.getRowData()).getId());
for (int i=0;i<innerListNew.size();i++){
System.out.println("Il nome dell'elemento è "+((MyData2)
innerListNew.get(i)).getNam());
System.out.println("Il nome dell'valore è "+((MyData2)
innerListNew.get(i)).getValor());
}
myDataItem = (MyData) getOuterDataTable().getRowData();
if (conn != null) {
PreparedStatement pst2 = null;
pst2 = conn.prepareStatement("INSERT INTO esterna(nome,valore)
values(?,?)");
pst2.setString(1, myDataItem.getName());
pst2.setString(2, myDataItem.getValue());
pst2.executeUpdate();
}
}
with this send method i send correctly outerList values to db table.
Can someone help me passing the right values from user to innerList and
from innerList to db table?
Please help me,i'm crazying and i need to go on....>
i've a question for you for a problem that i have in my jsf application
from 10 day and i'm trying to solve it but nothing....please help me.
I'm using 2 nested datatables as described in BalusC article.
I need using them for input fields,so i have a command button at the
end of each row.
My jsp page is
<h:dataTable
value="#{biosamplesTable.outerList}"
var="outerItem"
binding="#{biosamplesTable.outerDataTable}"
cellpadding="5" border="3" cellspacing="5">
<h:column>
<h:inputText value="#{outerItem.name}" />
</h:column>
<h:column>
<h:inputText value="#{outerItem.value}" />
</h:column>
<h:column>
<h:dataTable
value="#{biosamplesTable.innerList}"
var="innerItem"
<h:column>
<h:inputText value="#{innerItem.nam}" />
</h:column>
<h:column>
<h:inputText value="#{innerItem.valor}" />
</h:column>
</h:dataTable>
</h:column>
<h:column>
<f:facet name="header">
<hutputText value="Actions" />
</f:facet>
<h:commandButton value="Invia"
actionListener="#{biosamplesTable.send}"/>
</h:column>
</h:dataTable
and i've one InnerListMap that maps the index of outerList with the
right innerList.
My problem is that i'm not able to pass the values inserted from user
to innerList,that have ever null values,while outerList go well.
This is my loadInnerListMap
public void loadInnerListMap() {
for (Iterator iter = outerList.iterator(); iter.hasNext() {
MyData outerItem = (MyData) iter.next();
List innerList = new ArrayList();
MyData2 mydata=new MyData2();
mydata.setNam("italy");
mydata.setValor("naples");
innerList.add(mydata);
innerList.add(new MyData2());
innerList.add(new MyData2());
innerListMap.put(outerItem.getId(), innerList);
}
}
with this code i set the value for the first row of each innerlist and
it goes well...for the second and third row i pass null values and i'm
not able to pass user'values.
This is my send action
public void send(ActionEvent e) throws Exception{
System.out.println("Il numero di lista passatoè "+ident);
List innerListNew = (List) innerListMap.get(((MyData)
outerDataTable.getRowData()).getId());
for (int i=0;i<innerListNew.size();i++){
System.out.println("Il nome dell'elemento è "+((MyData2)
innerListNew.get(i)).getNam());
System.out.println("Il nome dell'valore è "+((MyData2)
innerListNew.get(i)).getValor());
}
myDataItem = (MyData) getOuterDataTable().getRowData();
if (conn != null) {
PreparedStatement pst2 = null;
pst2 = conn.prepareStatement("INSERT INTO esterna(nome,valore)
values(?,?)");
pst2.setString(1, myDataItem.getName());
pst2.setString(2, myDataItem.getValue());
pst2.executeUpdate();
}
}
with this send method i send correctly outerList values to db table.
Can someone help me passing the right values from user to innerList and
from innerList to db table?
Please help me,i'm crazying and i need to go on....>