• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

adding an empty row to a datatable

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
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..
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just add a blank record to the arraylist that is bound to your data table.
 
biny panackal
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
biny panackal
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i tryied adding a blank record to my existng list and it doesnt worked
 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you could provide us with more info. Like what happened when you tried to add blank record? What exceptions are you getting?
 
biny panackal
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Datatabl
<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">
<h:outputText binding="#{Page2.outputText2}" id="outputText2" value="column1"/>
</f:facet>
</h:column>
</h:dataTable>


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;
}
 
biny panackal
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
am not getting any kind of exeption but the row is not added
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}

 
Saloon Keeper
Posts: 27762
196
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
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.
 
biny panackal
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

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();
clients.add(client);
FacesContext.getCurrentInstance().renderResponse();
return null;
}
[ November 29, 2007: Message edited by: Pascal Zelen ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
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
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!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic