• 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

setting values from action class into table UI...

 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an object containing values to be persisted in table UI...

The table contains only header as it is dynamic,The row count depends on the DB...

The values in action class are obtained from the DB and I need to get the row values into table and this is to be done in Javascript call made onLoad...

How to achieve this? Or is there any other way?
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could have an action that outputs only the table data in whatever format is convenient for you (json, xml, etc.) and send an AJAX request to it from JS.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lorand can you elaborate... I din't absorb that completely. You meant (<body onLoad =callAjax()) Ajax call that gets values from action class and set them in your Javascript generated table???

 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I asumed that by a javascript call you meant an AJAX request...

You could give us a bit more information on this "javascript call" and the need for it!
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean I have a JSP with a table containing only a header


The rest of the rows are to be obtained from from the action class and set them in the table...

There are two things to be done here in same jsp...

1) If data is present in DB then I already have an object containing values for table...I just need to put them onto UI but it's linked with 2

2) if there are no data on DB i need to add rows here...so I used a JS to add rows dynamically to UI and DB(this is done)

My problem is with 1 here .I already have a JS to add rows to table... Now am confused how to put the data obtained from DB to table without disturbing the flow!
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can add the rows with the data from the DB on the server side, no need for JS, just put the row data in a Collection, add a getter for it in your action class, iterate over it in the JSP and output the rows! Which version of Struts are you using?
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
am using Struts-2... s:iterator would do rite?

Do you think i need a session?
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pradeep Adibatla wrote:s:iterator would do rite?



Rite.

Pradeep Adibatla wrote:
Do you think i need a session?



No, s:iterator can access the action class through the value stack, just add a getter that returns the Collection with the row data!
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks... I would get back to even greater detail if it doesn't work... struggling with struts and JS and their combo
reply
    Bookmark Topic Watch Topic
  • New Topic