wood burning stoves 2.0*
The moose likes Struts and the fly likes How to display a table data after clicking submit button in struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to display a table data after clicking submit button in struts?" Watch "How to display a table data after clicking submit button in struts?" New topic
Author

How to display a table data after clicking submit button in struts?

Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98
Hi,

In my application i want to display a table after clicking on submit button. I wrote the code like below,







Is the above code is correct? please correct me if i wrong..

Thanks
Vidya
Sandy Chatterjee
Ranch Hand

Joined: Jun 27, 2012
Posts: 55

The above code is correct.
But it's plain HTML.

The above code when written using Struts tags



Are you fetching the above values from the database?


Take up one idea. Make that one idea your life; dream of it; think of it; live on that idea. Let the brain, the body, muscles, nerves, every part of your body be full of that idea, and just leave every other idea alone. This is the way to success.
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98

No. Just hardcoding the values in a table and displaying the table on UI
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98


It is not displaying the table after clicking the calculate button..
Sandy Chatterjee
Ranch Hand

Joined: Jun 27, 2012
Posts: 55

It won't. You have to declare Action Form Bean and the Action class as well.
Sandy Chatterjee
Ranch Hand

Joined: Jun 27, 2012
Posts: 55

Hi Vidya,

Here is the entire code without using a database. In practical scenario you have to connect to the database through DAO.
But just for your understanding I have prepared this code.
struts-config.xml



The two Action Classes
NewStudentsAction.java


And
StudentsAction.java



The two Action Form Beans
StudentsActionForm.java



And
StudentsForm.java



And the Bean in the beans package is
Customers.java



The two jsp's are
welcomeStruts.jsp

And
showCustomers.jsp

The startup page
index.jsp


This will give you exactly what you wanted. I was planning the entire code so it took some time to reply.
If you face any problem reply back.
Sandy Chatterjee
Ranch Hand

Joined: Jun 27, 2012
Posts: 55

Hi,

Have you tried the above code.
ashish gusain
Greenhorn

Joined: Aug 21, 2013
Posts: 7
hello sandy .. i tried your example its good
but i want to create a mobile application using struts2 hibernate on eclipse .. in which i have to create a button which on clicking shows table from databse
can you help me
ashish gusain
Greenhorn

Joined: Aug 21, 2013
Posts: 7
hello sandy .. please help .. give me the codes to display table from database on button click using struts2 and hibernate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display a table data after clicking submit button in struts?