• 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

Report

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

how to create dynamic table with cell border from mvc controller, please help me to solve this problem its very urgent.








 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In MVC controller, declare a method which returns the object filled in ArrayList.
foward the ArrayList thru request dispatcher in servlet.

and in jsp make one loop which will run till the size of ArrayList.

E.g.

1. Signature of method in Model class.(Assuming the class name student)
public ArrayList<Student> getData(int std_id)
{
//Business logic...
}
2. Call from servlet
MyModel m=new MyModel();
ArrayList<Student> arr=new ArrayList<Student>();

arr=m.getData(10);

request.setAttribute("arr",arr);
RequestDispatcher rd=request.getRequestDispatcher("new.jsp");
request.forward(request,response);

3. In new.jsp
ArrayList<Student> arr=new ArrayList<Student>();
arr=request.getAttribute("arr");
Student s;
int i=arr.size();

for(int j=0;j<i;j++)
{
s=new Student();
s=arr.get(j);
//SOme code..
}


dont forget to use scriplets.and necessary import statement.

javascript:emoticon('');
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh sorry I forgot to mention table tag...

<table>
write for loop here and use <tr><td> tags...
</table>
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic