Forums Register Login
adding an empty row to a datatable
i am having a dataTable in my jsf page. i have to add an empty row to the existing table. How can i be possible any body know this pleas help me. It is my 5th day on this issue..
Just add a blank record to the arraylist that is bound to your data table.
thank you Mr.Richard Green ,

The situaltion is like that. while clicking on my add button i have to add a new row to the data table. which contain a text box too. and when clicking on the save i have to save all the data from the datatable. How can i get the values of all the text box in the datatable.
hi i tryied adding a blank record to my existng list and it doesnt worked
Maybe you could provide us with more info. Like what happened when you tried to add blank record? What exceptions are you getting?
<h:dataTable binding="#{Page2.dataTable1}" headerClass="list-header" id="dataTable1" rowClasses="list-row-even,list-row-odd"
style="left: 168px; top: 72px; position: absolute" value="#{Page2.dat}" var="currentRow">
<h:column binding="#{Page2.column1}" id="column1">
<h:inputText id="outputText1" value="#{currentRow.name}"/>
<f:facet name="header">
<hutputText binding="#{Page2.outputText2}" id="outputText2" value="column1"/>

Bean clas
//adding two new elements to datatable.
//am using my constructor Page2(Strig name) to set the values for the obj
public List getDat()
list.add(new Page2("test"));
//page[0]=new Page2("biny");
return list;
//this is for adding the new row.
public Page2[] test()
list.add(new Page2(""));

return page;
am not getting any kind of exeption but the row is not added
Make sure the page is refreshed once you add the row.
Can you post the code that the ADD button is calling? Is that an action or actionListener?
Also from your code below, I could not figure out when this test() is called and why it is returning an array.

//this is for adding the new row.
public Page2[] test()
list.add(new Page2(""));

return page;

What A. Dusi means is that an action processor returns a String. If you attempted to define this method to be called directly as an action processor, it wouldn't match the signature requirements and wouldn't get called.
thanks for your replay,

the ruturn type was the problem..
i need to replay list..
but now i added a single row. but when agin i am clicking the add buttion i am not able to add the second add row insted the page is getting refressed and only one row is getting added..

i will send the code in detail to you soon.. i have to make sure am not done any mistake since i send it to you.

Example of adding a new client to a clienttable (left out irrelevant details).

In JSF page:

<h:commandButton id="addbutton" value="Add Client" action="#{clientBean.addClientAction}">
In backing bean (clientBean):

List<Client> clients;

public String addClientAction() {

Client client = new Client();
return null;
[ November 29, 2007: Message edited by: Pascal Zelen ]
Hi Biny,

I am Facing the same Situation. Could you please post your XHTML tag for adding new Rows and the Action Event for AddAction in Backing Bean?
Welcome to the JavaRanch, Ramakrishnan!

You have "awakened a zombie". That is the term we use to describe threads that have been dormant for a long period of time. We don't encourage that. After this long, it's very possible that none of the people in the thread still frequent this forum, have the same jobs, or even are working with the same technology. For that matter, the technology they were working with has probably changed a lot since then.

So it's better to just start a new thread of your own. We don't charge extra!
Fire me boy! Cool, soothing, shameless self promotion:
Rocket Oven Kickstarter - from the trailboss

This thread has been viewed 17220 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 15, 2018 15:25:29.