• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
Hibernate Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

No. Just hardcoding the values in a table and displaying the table on UI
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


It is not displaying the table after clicking the calculate button..
 
Sandy Chatterjee
Ranch Hand
Posts: 55
Hibernate Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It won't. You have to declare Action Form Bean and the Action class as well.
 
Sandy Chatterjee
Ranch Hand
Posts: 55
Hibernate Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
Hibernate Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Have you tried the above code.
 
ashish gusain
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello sandy .. please help .. give me the codes to display table from database on button click using struts2 and hibernate
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic