1

I'm trying to create a simple HTML project using the Struts framework. I'm trying to add dynamically the tag <html:submit property="switchsubmit" ...... >

I have created a table and I gave it the id='idTable'. I have created a button which have the goal to add a new line in the table, this line contains a submit button created in tag based on Struts concept.

In the onClick() function of the button, I wrote the code as below:

var table = document.getElementById('idTable');

var row = table .insertRow(0);
var cell = row.insertCell(0);
cell.style="border: 1px #376BAD solid;";

var submit = document.createElement("html:submit");  
submit.property="switchsubmit";
submit.value="Add";
cell.appendChild(submit);

I've been adapted All about the struts-config.xml.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Ahmad MOUSSA
  • 2,729
  • 19
  • 31

1 Answers1

1

You are made a mistake by adding Struts tag html:submit to the DOM element. This tag is a JSP tag and should be compiled and executed on the server side not in the client browser via JavaScript. If you want the Struts to render JSP tags, you should make an Ajax call to the server which will execute an action and process JSP page or fragment and return a response with HTML content type, then you can inner HTML to the element with JavaScript.

Roman C
  • 49,761
  • 33
  • 66
  • 176