JQuery Datatable using Ajax Innerhtml

Problem (JQuery Datatable using Ajax Innerhtml)

I can't seem to the data inserted into the datatable. I got a search button and upon clicked, will fetch the data (json array) using ajax. The data format is like [{"statusID":1,"inspectorID":1}, {"statusID":2,"inspectorID":2}]

The data is constructed as a html format and inserted into the datatable using innerhtml method. Can I insert the data using Ajax Innerhtml?

$(document).ready(function() {
} );
function searchWork(){
    url: "../../../work/WorkAction.do?formAction=loadListingByCriteria",
      type: $("#requestForm").find("select[name='cbType']").val()
    dataType: "json",
    success: function( json ) {
      if(json != null){
         var content = "";
         content += "<table id=\"listing\" class=\"display\" cellspacing=\"0\" width=\"100%\">";
         content += "<thead>";
         content += "<tr>";
         content += "<th>Status</th>";
         content += "<th>Inspector</th>";
         content += "</tr>";
         content += "</thead>";
         content += "<tfoot>";
         content += "<tr>";
         content += "<th>Status</th>";
         content += "<th>Inspector</th>";
         content += "</tr>";
         content += "</tfoot>";
         content += "<tbody>";
         $.each(json, function(){
             content += "<tr>";
             content += "<td>" + this.status + "</td>";
             content += "<td>" + this.inspector + "</td>";
             content += "</tr>";
         content += "</tbody>";
         content += "</table>";
         document.getElementById('listing').innerHTML = content;  


View Solution


Unable to set to form bean using Indexed=true

Problem (Unable to set to form bean using Indexed=true)


I was unable to set to form bean using Indexed=true struts properties in the struts iterator. I have a list of items and each item has a id, description and status. The item's status is editable. I have used "Indexed=true" to cater for editing multiple items' status.

<logic:iterate name="customerActionForm" property="customerBean.checklistItems" id="listItemID">
   <div id="<%=index%>" class="toggle toggle-light" style="width: 118px; height: 22px;">
   <html:hidden name="listItemID" property="itemStatus" indexed="true" />

This is how the html text will look like if do a view source of the page:

<input type="hidden" name="listItemID[0].itemStatus" value="N"/>
<input type="hidden" name="listItemID[1].itemStatus" value="N"/>
<input type="hidden" name="listItemID[2].itemStatus" value="Y"/>
<input type="hidden" name="listItemID[3].itemStatus" value="Y"/>


View Solution


java.lang.Exception: Port 8083 already in use

Problem (Port 8083 already in use)


I encountered this issue when run the JBOSS 5 application server, either in eclipse or run as a script.
The server is running under port 8080 and the system complains that port 8083 is in used. Am I using port 8083? That is when I noticed that the sentence "Using RMI server codebase:" when running the JBoss server in Eclipse.

View Solution


How to increase JQuery datatable loading speed?

Problem (How to increase JQuery datatable loading speed)


There is no issue of loading the datatable if there are only a few records in the datatable.

But what if there is a large number of records to be displayed? Can we still load the page in a short time?

If there is a large number of records to be displayed (e.g. 10,000 records), then the jsp page really takes

a long time to load the records. At times, the browser e.g.Internet Explorer will prompt the user whether

to continue to load the records or terminate the loading process. The question is "how can I increase

JQuery datatable loading speed?" This is the code that I written:


JSP page

$(document.ready(function() {
          "bProcessing" : true,
          "sPaginationType" : "full_numbers",
          "bFilter" : false,
          "bLengthChange" : false,
          "aaSorting" : [[0, "asc"]],
          "aoColumns" : [null, null]

<table id="listing" class="display">
         <s:iterator var="item" value="fruitPO.fruitListing" status="i">
                  <th><s:property value="#item.fruitId" escapeHtml="false"/></th>
                  <th><s:property value="#item.fruitDesc" escapeHtml="false"/></th>

View Solution


When to use hidden fields in struts2?

Problem (When to use hidden fields in struts2)


Currently, I got two functions - view and save functions. On first load of the page, I will trigger the view function

to display the page by populating the data. Populating the data for dropdownlist, textfield, textarea upon

viewing of the page. This page allows the user to edit the data and clicks on the "Save" button upon completion.


JSP page

<s:form action="/saveFruit.do" method="post">

<s:textfield name="fruitPO.name" id="name" size="100" maxlength="66"/>

<s:textfield name="fruitPO.description" id="description" size="100" maxlength="66"/>

//blah blah blah  fields added

<input type="button" name="btnSave" value="Save" onClick="saveFruit()" />



The problem is when saving to the database, the system unable to insert the records into the database as

one of the field is null. I was wondering why is the form field empty, as all the fields within the form are entered

and sent to the Action file for saving into the database.


View Solution


How to check request attribute in jsp in struts2?

Problem (how to check request attribute in jsp in struts2)


I got a problem of checking or comparing the request attribute value at jsp.

<s:if test='%{#request.fruitPO != null}'>

//do something


If the request attribute named fruitPO has value, then it should go into the IF statement

and the code will do something. The problem is why is the request attribute fruitPO always not null,

even though I didn't call request.setAttribute("fruitPO", fruitPO); at FruitAction.java


View Solution


Struts2 manual validation on specific action?

Problem (Struts2 manual validation on specific action)


I was thinking how to do a validation check on a specific action method.

I got a few action methods like "doSearch", doActivate", doDeactivate", "doCreate".

I will require to have different validation on each action method.

For example, the validated fields for action method "doSearch" are the Date From and Date To.

The validated fields for action method "doCreate" are Name, Description, Modified by, Date updated etc.

For now, I only use validate() method to validate the fields and is executed by the Validation Interceptor.


public void validate() {

    if(getName().length == 0) {

       addActionError("name","Name is required");


   if(getDescription().length == 0) {

      addActionError("description","Description is required");


  // follow by all the other fields validation

  // blah blah blah



View Solution


Redirect struts2 action to different namespace?

Problem (Redirect struts2 action to different namespace?)


I got a problem of redirecting struts2 action to another namespace at the jsp page.

The action method name "Search" is not called when I clicked on the button "Search".

The listing of fruits should be displayed upon clicking on the "Search" button.

The strange thing is that the action method is called when I entered the url directly on the address bar.

The action method path name is created dynamically by joining the action path.

e.g. document.forms[0].action += "_"+ action + ".do"


JSP page

function submitReport(action) {

document.forms[0].action += "_"+ action + ".do"




<s:form action="/user/manageUser" method="post">

<input type="button" name="btnCreate" onClick="submitReport('Create')" />

<input type="button" name="btnSearch" onClick="submitReport('Search')" />



I have a struts.xml that includes a list of xml files. e.g. user-struts.xml, admin-struts.xml.

The xml that I used is user-struts.xml, which extends the default struts.xml and having a different namespace.




<package name="user" extends="struts.default" namespace="/user">

<action name="manageUser_*" method="{1}">

<result name="input">/WEB-INF/jsp/userListing.jsp</result>

<result name="success">/WEB-INF/jsp/userListing.jsp</result>





View Solution


Why is the struts2 action method calling multiple times?

Problem (Why is the struts2 action method calling multiple times)


Upon clicking on the link "Fruit Listing" on the menu, the fruit listing is to be displayed on the screen.

There is no issue of displaying the fruit listing, just that the action method calling multiple times at the jsp page.

I only realised this issue when comes to debugging, because the debug messages are printed on the server console.



<action name="fruitCatListing" class="lee.fruit.action.FruitAction" 
     <result name="input">ui/Fruit/FruitCatListing.jsp</result>
     <result name="success">ui/Fruit/FruitCatListing.jsp</result>


The question is "why is the action method "getFruitCatListing" calling 2 times?" AND

"why is the action method "getFruitCatDetails" calling once?"

I really don't get it, as the action methods are called and triggered from the jsp page.


View Solution


How to auto resize height of iframe?

Problem (How to auto resize height of iframe)


I got a parent page that has a iframe and is able to resize to fit the contents of the main page.


<iframe name="mainFrame" id="home" src="home.jsp" frameborder="0" style="width:1000px;"
  onload="resizeIframe(this.id)"> </iframe>


I got a child page that contains an "Add Fruit" button. Initially all input fields are hidden, and upon clicking

on the add button, two input fields - the Fruit Name and the Fruit Description are displayed. As the fields are

hidden, the iframe will only auto-resize to fit the height where the add button is. When I clicked on the "Add Fruit"

button, the height of the scrollbar is restricted to the height where the add button is, the two input fields are

squeezed according to the height of the scrollbar and the bottom of the page has a big blank space. Very ugly indeed!

The question is "How to auto resize the height of iframe to fit the contents of my page nicely?"


View Solution

Back to Top