I have tried this a lot since last couple of days, but still not able to solve this.
I am using liferay 6.1 and struts 2. Basically i have two dropdowns in my liferay portlet, one for country and other for states. When selecting the country, state list needs to be in drop down list according to the country selected. I am trying to do this through AJAX. (Below code I found from google, its working in a separate Dynamic Web Project, but when i tried this in liferay portlet its throwing error.
Below is my Code:
StartPage.jsp
<script >
$(document).ready(function() {
$('#country').change(function(event) {
var country = $("select#country").val();
alert(country);
$.getJSON("<s:url action='ajaxAction' namespace='ajax' includeParams='none' />", {countryName : country}, function(jsonResponse) {
$('#ajaxResponse').text(jsonResponse.dummyMsg);
alert($('#ajaxResponse').text(jsonResponse.dummyMsg));
var select = $('#states');
select.find('option').remove();
$.each(jsonResponse.stateMap, function(key, value) {
$('<option>').val(key).text(value).appendTo(select);
});
});
});
});
</script>
<s:form name="StartPage" id="StartPage">
<s:select id="country" name="country"
list="{'Select Country','India','US'}" label="Select Country" />
<br />
<br />
<s:select id="states" name="states" list="{'Select State'}"
label="Select State" />
<br />
<br />
<div id="ajaxResponse"></div>
</s:form>
struts.xml
<package name="default" extends="json-default">
<action name="ajaxAction" class="com.action.AjaxJsonAction">
<result type="json">/WEB-INF/view/StartPage.jsp
</result>
</action>
</package>
Action Class:
public class AjaxJsonAction extends DefaultActionSupport{
private Map<String, String> stateMap = new LinkedHashMap<String, String>();
private String dummyMsg;
//Parameter for Jquery
private String countryName;
#Override
public String execute() {
System.out.println("i am executed...");
System.out.println("CountryName: " + countryName);
if (countryName.equals("India")) {
stateMap.put("1", "Kerala");
stateMap.put("2", "Tamil Nadu");
stateMap.put("3", "Jammu Kashmir");
stateMap.put("4", "Assam");
} else if (countryName.equals("US")) {
stateMap.put("1", "Georgia");
stateMap.put("2", "Utah");
stateMap.put("3", "Texas");
stateMap.put("4", "New Jersey");
} else if (countryName.equals("Select Country")) {
stateMap.put("1", "Select State");
}
dummyMsg = "Ajax action Triggered";
System.out.println("exiting.....");
return "success";
}
public Map<String, String> getStateMap() {
return stateMap;
}
public String getDummyMsg() {
return dummyMsg;
}
public String getCountryName() {
return countryName;
}
public void setStateMap(Map<String, String> stateMap) {
this.stateMap = stateMap;
}
public void setDummyMsg(String dummyMsg) {
this.dummyMsg = dummyMsg;
}
public void setCountryName(String countryName) {
this.countryName = countryName;
}
}
Errro Log:
java.lang.IllegalArgumentException: application/json;charset=UTF-8 is not a supported mime type
at com.liferay.portlet.MimeResponseImpl.setContentType(MimeResponseImpl.java:159)
at org.apache.struts2.portlet.servlet.PortletServletResponse.setContentType(PortletServletResponse.java:219)
at org.apache.struts2.json.JSONUtil.writeJSONToResponse(JSONUtil.java:225)
at org.apache.struts2.json.JSONResult.writeToResponse(JSONResult.java:211)
at org.apache.struts2.json.JSONResult.execute(JSONResult.java:172)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
You can use AJAX AUI script for this. I am using Liferay 6.2 sp2 SDK and Liferay MVC portlet. You can try this with struts approach to see if it helps you.
Use liferay.provide function in your AUI script.
<aui:script>
Liferay.provide(
window,
'<portlet:namespace />updatePermState',
function() {
var A = AUI();
var url = '<%= ajaxCallResourceURL.toString() %>';
A.io.request(
url,
{
//data to be sent to server
data: {
<portlet:namespace />param1: (document.getElementById('<portlet:namespace/>mCountry').value),
}, .....
}
Create servResource function in your portlet class. This will be wired with your AUI call:
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException {
resourceResponse.setContentType("text/javascript");
... ...
//Send Data Back
resourceResponse.setContentType("text/html");
}
In your calling JSP file add this:
<!-- Create a serveResource URL -->
<portlet:resourceURL var="ajaxCallResourceURL" />
AJAX call. I am using onChange method when on the Country field. My UpdatePermState() function is creating a div with the states dynamically.
<aui:select name="mCountry" id="mCountry" label="Country of permanent address*" inlineLabel="left" onChange='<%= renderResponse.getNamespace() + "updatePermState();" %>'>
Related
This question already exists:
action class do not passing objects to jsp class ,using struts2 in liferay
Closed 7 years ago.
i am using liferay with Struts2, i have two action method in one action class, i create an object from a class in first action method(execute()) and passing that to the view and showing it successfully, in view.jsp i'm using that object but when i submit the form and going to second action method(sendMessage()) an exception happened.
what should i do? what is the problem?
struts.xml
<struts>
<constant name="struts.devMode" value="true" />
<package namespace="/support" extends="struts-portlet-default,json-default"
name="subjectview">
<action name="index" class="com.xxx.actions.SupportFormAction"
method="execute">
<result>/html/support/view.jsp</result>
</action>
<action name="sendmsg" class="com.xxx.actions.SupportFormAction"
method="sendMessage">
<result name="success">/html/support/send-message-success-ajax.jsp</result>
<result name="error">/html/support/send-message-fail-ajax.jsp</result>
</action>
</package>
</struts>
SupportFormAction.java
package com.xxx.actions;
import com.iknito.model.SendEmail;
import com.opensymphony.xwork2.ActionSupport;
public class SupportFormAction extends ActionSupport {
private SendEmail sendEmail;
#Override
public String execute() throws Exception {
sendEmail = new SendEmail();
return "success";
}
public String sendMessage(){
try{
System.out.println(sendEmail.getName()); /* nullpointer exception happened here*/
return "success";
}
catch(Exception ex){
ex.printStackTrace();
return "error";
}
}
public SendEmail getSendEmail() {
return sendEmail;
}
public void setSendEmail(SendEmail sendEmail) {
this.sendEmail = sendEmail;
}
}
SendEmail.java
package iknito.com.actions;
public class SendEmail {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
view.jsp
<%# include file="/html/init.jsp" %>
<%# taglib prefix="s" uri="/struts-tags" %>
<s:form id="form1" action="addsubjects" theme="simple">
<label for="name">Name:</label>
<s:textfield type="text" name="sendEmail.name" placeholder="Hamed Yousefi" required="required"/>
<s:submit value="enter name"/>
</s:form>
Your object is lost after it is rendered on JSP page.
You need to either
put it in the page, for example in hidden inputs, and re-trasmit it completely (in your case, one hidden parameter for each attribute of the object)
or (much better when there is an entire object and not a simple String) put it in the session, and retrieve it later.
I have an application where i login and it takes me to the next page and displays a table.
I have handled session by implementing the SessionAware interface.
When i refresh the page with the refresh button on the browser or F5, it works fine. However, if i press enter on the url, it takes me to the login page because the username and password is null.
Please find below my java code and jsp code and struts.xml
JAVA class:
public String Authentication()
{
// return userInfo.getUserLoginId() + "_BUSINESS_SERVICES";
if(j_username == null)
{
status="failure3";
return status;
}
System.out.println("get username and get password" +j_username + j_password);
// if no userName stored in the session,
// check the entered userName and password
if (j_username != null && j_password != null) {
System.out.println("inside function");
// add userName to the session
sessionMap.put("j_username", j_username);
status = otlAuthenticationController.loginAuthentication(j_username,j_password);
if(status == "success")
{
this.otlUserList= otlAuthenticationController.obtainList();
System.out.println("size is"+otlUserList.size());
}
}
return status;
}
public String logout()
{
if (sessionMap instanceof org.apache.struts2.dispatcher.SessionMap) {
try {
//((org.apache.struts2.dispatcher.SessionMap) sessionMap).invalidate();
if (sessionMap.containsKey("userName")) {
sessionMap.remove(j_username);
System.out.println("session killed");
status ="success";
}
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
return "success";
}
JSP page:
<div class="label" style="margin-top:10px;"><s:text name="login.password" /></div><input id="j_password" name="j_password" type="password" placeholder="Password" size="31" autocomplete="off"/><br><br>
<div class="left" style="padding-left:150px; horizontal-align:right;text-align:center;"><input type="submit" name="login" value=<s:text name="login"/> class="button normal normal1" onClick="validate1()"/></div>
<br> <br><s:if test="status=='failure'">
<center><p style="color:RED" text-align :"center"><b> Invalid username. Please enter a valid username</b></p></center>
</s:if>
<s:if test="status=='failure2'">
<center><p style="color:RED" text-align :"center"><b> Invalid password. Please enter a valid password</b></p></center>
</s:if>
<s:if test="status=='failure3'">
<center><p style="color:RED" text-align :"center"><b> Login to the application to continue</b></p></center>
</s:if>
</div>
struts.xml:
<action name="logout" class ="com.opentext.planning.view.OTLAuthentication" method="logout">
<result name="success">/WEB-INF/index.jsp</result>
<result name="failure">/WEB-INF/error.jsp</result>
</action>
<action name ="Otl_Homepage"
class="com.opentext.planning.view.OTLAuthentication" method="Authentication">
<result name="success">/WEB-INF/Otl_Homepage.jsp</result>
<result name="failure">/WEB-INF/index.jsp</result>
<result name="failure2">/WEB-INF/index.jsp</result>
<result name="failure3">/WEB-INF/index.jsp</result>
</action>
The required parameters are in the action context, but if you are using the action, which for some reason doesn't get parameters from the params interceptor, then you still can get parameters if your action implements ParameterAware.
public class OLTAuthentication implements ParameterAware {
private Map<String, String[]> parameters;
public void setParameters(Map<String, String[]> parameters){
this.parameters = parameters;
}
public String Authentication() {
String j_username = parameters.get("j_username")[0];
String j_password = parameters.get("j_password")[0];
...
I have an iterator which requires to use mapped properties or indexed properties but my getter-setter are not getting those values.
For Ex:
(This is just an example. Ultimately the idea is whether I can use mapped property in struts 2 or not. If yes, then how.)
index.jsp:
<s:form action="hello" namespace="foo">
<s:textfield name="arp(0)" /> <br/>
<s:textfield name="prp(0)" /> <br/>
<s:textfield name="arp(1)" /> <br/>
<s:textfield name="prp(1)" /> <br/>
<s:submit value="Say Hello" />
</s:form>
helloWorld.action:
class PRLists {
String arp;
String prp;
public String getArp() {
return Arp;
}
public void setArp(String aRP) {
arp = aRP;
}
public String getPrp() {
return prp;
}
public void setPrp(String pRP) {
prp = pRP;
}
}
public class HelloWorldAction {
ArrayList<PRLists> prlist = new ArrayList<PRLists>();
public String execute() throws Exception {
System.out.println("ruuning execute");
return "success";
}
public ArrayList<PRLists> getPrlist() {
return prlist;
}
public void setPrlist(ArrayList<PRLists> prlist) {
this.prlist = prlist;
}
public String getArp(String key) {
int index = Integer.parseInt(key);
return prlist[index].arp;
}
public void setArp(String key, Object value) {
System.out.println("set ARP: index:" + index + ", value" + value);
int index = Integer.parseInt(key);
prlist[index].arp = value.toString();
}
public String getPrp(String key) {
int index = Integer.parseInt(key);
return prlist[index].prp;
}
public void setPrp(String key, Object value) {
System.out.println("set PRP, Key:" + key + ", value:" + value);
int index = Integer.parseInt(key);
prlist[index].prp = value.toString();
}
}
Earlier I was having this kind of working functions in struts 1 but now I am trying to move it to struts 2. Now my setter functions in HelloWorldAction.java for arp and prp are not getting called upon form submit.
public void setArp(String key, Object value);
public void setPrp(String key, Object value);
<s:textfield name="prlist[0].arp" /> can work but we have some dependent code which requires to use fields with name such as <s:textfield name="arp(0)" />.
I do not know whether struts 2 supports mapped properties or not. If it supports, then how can I use it.
I also found a related issue: https://issues.liferay.com/browse/LPS-14128
Note: I have made some modifications in question description
Thanks in advance.
You're violating a lot of "rules" here, other than avoiding almost any mechanism provided by the framework. Never put logic in accessors / mutators (getters / setters), never use capitalized variable names, avoid using variables starting with an uppercase letter, read struts Type Conversion, use Struts tags (eg. <s:textfield/> instead of <input type="text" />) whenever possible, and reduce your code to:
public class HelloWorldAction{
private String name;
private List<PRLists> arnList = new ArrayList<PRLists>();
public String execute() throws Exception {
System.out.println("running execute");
return "success";
}
public List<PRLists> getArnList(){
return arnList;
}
public void setArnList(List<PRLists> arnList){
this.arnList = arnList;
}
public String getName() {
return name;
}
public void setName(String name) {
System.out.println("set name: "+name);
this.name = name;
}
}
<s:form action="hello" namespace="foo">
<s:textfield name="name" label="name" />
<s:textfield name="arnList[0].arp" /> <br/>
<s:textfield name="arnList[0].prp" /> <br/>
<s:textfield name="arnList[1].arp" /> <br/>
<s:textfield name="arnList[1].prp" /> <br/>
<s:submit value="Say Hello" />
</s:form>
of in an iterator, as you said (without showing it), like
<s:form action="hello" namespace="foo">
<s:textfield name="name" label="name" />
<s:iterator value="arnList" status="rowStatus">
<s:textfield name="arnList[%{#rowStatus.index}].arp" /> <br/>
<s:textfield name="arnList[%{#rowStatus.index}].prp" /> <br/>
</s:iterator>
<s:submit value="Say Hello" />
</s:form>
I have a login form in my jsp file that is referring to a javascript function using onclick function,
The javascript function is supposed to to call an action method to do the authorization process and return the results.
Result can be a message of error (user name is wrong) or (username or password is wrong) or a success message (return "SUCCESS") to get to new page,
any time that it calls the action the alert(xmlHttp.status) shows that it receives "undefined"
it is calling a correct action but its problem is on receiving the response.
how should I define the struts.xml? maybe the problem is caused by it.
<s:submit onclick="auth(this.form)" />
xmlhttp.open("get","Login.action?usrname="+usr+"&pass="+psw,false);
xmlhttp.send();
You need to do like this (Struts2, JSON, Ajax)
struts.xml
<package name="default" extends="json-default">
<action name="ValidateUserName" class="com.controller.JSONUserAction">
<result type="json"></result>
</action>
</package>
Controller Class Code JSONUserAction.java (in your case Login.java)
package com.controller;
import com.opensymphony.xwork2.ActionSupport;
public class JSONUserAction extends ActionSupport {
private String username;
private String result;
// all struts logic here
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String execute() {
if(username.equalsIgnoreCase("admin")) {
result = "VALID";
} else {
result = "INVALID";
}
System.out.println("username : " + username + "======== result :" + result);
return ActionSupport.SUCCESS;
}
}
login.jsp code
<%# page contentType="text/html; charset=UTF-8"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<script type="text/javascript">
var http;
if(window.XMLHttpRequest) {
http = new XMLHttpRequest();
} else {
http = new ActiveXObject("Microsoft.XMLHTTP");
}
function AuthenticateUser() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
http.open("POST", "ValidateUserName.action", true);
http.setRequestHeader("Content-type","application/x-www-form-urlencoded");
http.onreadystatechange = ValidUser;
http.send("username="+username +"&password="+password);
}
function ValidUser() {
if(http.readyState == 4 && http.status == 200) {
var jsonOP = eval ("(" + http.responseText + ")");
var result = jsonOP.result;
document.getElementById("message").innerHTML = result;
if(result == "VALID") {
//redirect to welcome page
}
}
}
</script>
</head>
<body>
<s:form action="Welcome">
<div id="message"></div>
<s:textfield name="username" label="Username" id="username" />
<s:password name="password" label="Password" id="password"/>
<s:submit id="login" onClick="AuthenticateUser();"/>
</s:form>
</body>
</html>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%#taglib uri="/struts-tags" prefix="s"%>
<%# taglib prefix="sj" uri="/struts-jquery-tags"%>
<jsp:include page="checkLogin.jsp" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Allocate Tans</title>
<script type="javascript" src="jquery-1.7.js"></script>
<sj:head jqueryui="true" jquerytheme="cupertino" />
</head>
<script type="text/javascript">
$(document).ready(function()
{
$('#batchID').change(function(event) {
var batch=$('#batchID').val();
$.ajax({
url : "doShowAllocationStatus.action",
data : "batch="+batch,
success : function(html) {
$('#table').html(html);
},
error : function(html) {
alert("error");
}
});
});
});
</script>
<body>
<div id=table>
<s:form action="doAllocate" name="allocate" executeResult="true">
<s:actionerror />
<s:actionmessage />
<s:select label="Select Batch" headerKey="-1"
headerValue="Select a Batch..." list="%{#session.Batchs}"
Value="batch" name="batch" id="batchID" />
<s:select label="Select User" headerKey="-1"
headerValue="Select an User..." list="%{#session.users}" name="user"
value="user" />
<s:radio list="#{'Curator':'Curator','QC':'QC'}" name="user_work_as" />
<s:submit value="Allocate" id="AllocateID" />
<table align="center" border="2" width="800">
<tr>
<th>TAN</th>
<th>Curator</th>
<th>Curator Status</th>
<th>QC</th>
<th>QC Status</th>
</tr>
<s:iterator value="allocationList" var="tableID">
<tr>
<td><s:checkbox name="Tans" fieldValue="%{#tableID.tan}"
theme="simple" />
<s:property value="tan" /></td>
<td><s:property value="curator" /></td>
<td><s:property value="curator_status" /></td>
<td><s:property value="qc" /></td>
<td><s:property value="qc_status" /></td>
</tr>
</s:iterator>
</table>
</s:form>
</div>
</body>
</html>
In this when I use the for all content inside the dropdown select works fine as i expected for dropdown list and table but it react different I mean the table is appended with same rows once again when I submit and if I select some thing in batch dropdown list then the table comes to it correct list. If I used only for table, it prints the full page once again. I can understand what had happen, but could not find solution to achieve what I need.
My aim is to display the table based on the batch selected and the submit should do what it actually has to do.
server side code...
package controller;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import model.BatchInfo;
import model.CationDAO;
//import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
#SuppressWarnings("serial")
public class AllocateTAN extends ActionSupport {
//Fields that hold data...
private List<BatchInfo> allocationList =new ArrayList<BatchInfo>();
private String batch;
private List<String> batchs = new ArrayList<String>();
private String TAN;
private String Tans[];
private String user;
private List<String> users = new ArrayList<String>();
private String user_work_as;
//getters and setters....
public List<BatchInfo> getAllocationList() {
return allocationList;
}
public void setAllocationList(List<BatchInfo> allocationList) {
this.allocationList = allocationList;
}
//#RequiredStringValidator(message = "Batch Not Selected")
public String getBatch() {
return batch;
}
public void setBatch(String batch) {
this.batch = batch;
}
public List<String> getBatchs() {
return batchs;
}
public void setBatchs(List<String> batchs) {
this.batchs = batchs;
}
//#RequiredStringValidator(message = "TAN Not Selected")
public String getTAN() {
return TAN;
}
public void setTAN(String tAN) {
TAN = tAN;
}
public String[] getTans() {
return Tans;
}
public void setTans(String[] tans) {
Tans = tans;
}
//#RequiredStringValidator(message = "Worker Not Selected")
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public List<String> getUsers() {
return users;
}
public void setUsers(List<String> users) {
this.users = users;
}
//#RequiredStringValidator(message = "Select Any One")
public String getUser_work_as() {
return user_work_as;
}
public void setUser_work_as(String user_work_as) {
this.user_work_as = user_work_as;
}
//variable used to access DataBase...
CationDAO dao1 = new CationDAO() ;
//flow 1.: making all details available for the allocate TAN page...when page page is loaded 1st time
public String AllocatingTANpageDetails() throws SQLException{
Map<String, Object>session=ActionContext.getContext().getSession();
this.batchs=dao1.Batch_List();
session.put("Batchs", batchs);
//Tans=dao1.Tan_list(getBatch());
this.users=dao1.Users_List();
session.put("users", users);
return SUCCESS;
}
/*TAN list
private void showTANlist(String Batch1) throws SQLException{
Map<String, Object>session=ActionContext.getContext().getSession();
Tans=dao1.Tan_list(Batch1);
session.put("Tans", Tans);
}*/
//flow 2.: showing Allocation Status in Table form...in same page
public String showAllocationStatus() throws SQLException {
System.out.println("Inside Show Allocation Status");
if(batch==null||"-1".equals(batch)){
addActionMessage("Please!... Select a Batch");
return ERROR;
}
Map<String, Object>session=ActionContext.getContext().getSession();
//setBatch(batch_value);
String bth=getBatch();
if (bth==null || bth=="-1"){
System.out.println("batch is empty "+bth);
}
System.out.println(bth);
session.put("Batch",bth);
// showTANlist(bth);
System.out.println("Processing Allocation List... ");
this.allocationList=(List<BatchInfo>)dao1.status(bth);
System.out.println(allocationList);
session.put("AllocationList",allocationList);
System.out.println("Finished...");
return SUCCESS;
}
//execute method form allocating a TAN for a user...
public String execute(){
String statusTable=null;
String er = null;
if(Tans==null||"-1".equals(Tans)){
addActionError("Please!... Select a TAN"); er="er";
}
if (user==null||"-1".equals(user)){
addActionError("Please!... Select an Worker");er="er";
}
if (user_work_as==null||user_work_as==""||"-1".equals(user_work_as)){
addActionError("Please!... Select either Curation or QC");er="er";
}
try {
statusTable=showAllocationStatus();
} catch (SQLException e) {
e.printStackTrace();
}
if(!"er".equals(er)&& "success".equals(statusTable)){
System.out.println("inside Execute metho of AllocateTAN.java");
if ("QC".equalsIgnoreCase(user_work_as)){
try {
if(!"Complete".equalsIgnoreCase(dao1.CheckCurator(batch,Tans))){
addActionMessage("Curation Not yet completed");
return ERROR;
}
dao1.AllocateTANforUser( batch, Tans, user, user_work_as);
this.allocationList=(List<BatchInfo>)dao1.status(getBatch());
return SUCCESS;
} catch (SQLException e) {
e.printStackTrace();
}
}else if("Curator".equalsIgnoreCase(user_work_as)){
try {
dao1.AllocateTANforUser( batch, Tans, user, user_work_as);
} catch (SQLException e) {
e.printStackTrace();
}
this.allocationList=(List<BatchInfo>)dao1.status(getBatch());
return SUCCESS;
}
}
return ERROR;
}
}
First, I would suggest that you change your structure as you are using AJAX hardly at all (you only use one on load and that's it, and that is not different than passing all those values from the very beginning from the action). As you only have 3 values to pass, is fairly easy to capture them with jQuery("#myid").val() and pass them with jQuery.ajax. something like
<s:button value="Allocate Me!!!" onclick="allocating_you()"/>
and then
function allocationg_you(){
var val1 = jQuery("#value1").val();
var val2 = jQuery("#value2").val();
var val3 = jQuery("#value3").val();
jQuery.ajax({
url: "allocator",
data: "val1=" + val1 +"&val2=" + val2 + "&val3=" + val3 + "&r=" //dont forget to add a random number
success: function(data){
jQuery("#mytable").html(data).load();
}
});
}
finally, you should reduce the ajax refreshment to the minimun necessary, as it will be easier to mantain and to give aesthetics. so for example your template should be divided like this
<your form>
<your table header>
<div id="mytable">
with this template you would only have to refresh the actual content and everything else will remain intact (true AJAX), so in your JSP response for your AJAX call there should be only the iterator part. you will even be able to create the table with a scrollbar and a static header, only needing to put some matching sizes in your ajax cells along with the table tag.
Hope this helps you. If you manage to crack this you will be able to do wonders. jQuery + Struts2 + (seems that you are not using Hbernate, but oh well) it's a monstrous combination.