Skip to content Skip to sidebar Skip to footer

How To Call The Struts Action Class And Display The Data On Screen Using Jquery

I have JSP where I am displaying list of data in a tabular format. One of the columns in each will have 3 different links. Have 3 different methods in Action class, so that the res

Solution 1:

Premise: the sentence

could not assign the data returned by the Action class to the struts variable in JSP.

is wrong because there is nothing like a "Struts variable" in the rendered HTML page.

That said, there are several ways to achieve your goal (although not completely clear):

  1. Load the content when rendering the page, then hide / show it through javascript; this is the fastest way, but there are cases where it is discouraged, for example :

    • the content could have been changed after the page is loaded, because of other users or softwares updating it;
    • it's too big to load it for all the records, and the memory footprint and page loading time becomes unacceptable.
  2. Add / remove the content through a standard POST / GET submit; this is the old way, you reload everything, recharge everything and have to manually handle anchors and page-related operations.

  3. Add the content through AJAX calls, and remove it through javascript (raw javascript, jQuery, struts2-jQuery-plugin, or other libraries); this is probably what you need, if solution n.1 doesn't fit your case.

To stick with the current standards / best practices / tools that will simplify your work, you should use:

Side note: if you inject a JSP snippet containing others struts2-jquery tags, you need to read this.

Post a Comment for "How To Call The Struts Action Class And Display The Data On Screen Using Jquery"