I have an application that uses struts 2. My problem is whenever I'm using IE, I get the attribute value fine from my HTML page to my action class, but when I use firefox, I'm getting a null value.
I'm using javascript to dynamically create the textarea where I map the value of my action class attribute "explanation".
function showExplain(){
if(document.getElementById("equivalentExp").checked){
document.getElementById('explaintxt').style.display = "inline";
var taspan = document.getElementById("taSpan");
var ta = document.createElement('textarea');
ta.setAttribute("name", "explanation");
ta.setAttribute("id", "explanation");
ta.setAttribute("cols", "45");
ta.setAttribute("rows", "5");
ta.setAttribute("class", "textAreaField");
ta.innerHTML = '<%if(explanation != null){%><%= explanation %><%}%>';
taspan.appendChild(ta);
}else{
document.getElementById('explaintxt').style.display = "none";
if(document.getElementById("explanation") != null){
var taspan = document.getElementById("taSpan");
taspan.removeChild(document.getElementById("explanation"));
}
}
}
I have my getter/setter for the "explanation" attribute in my action class, so I know that's not the problem. I also tried to alert("document.getElementById("explanation").value); and it's displaying the right value that I have in my textarea, both in IE and firefox, but when it get to the controller, it's null when I use firefox.
I also tried to just use a regular textarea declared in the html, it works fine in both browsers.
What's confusing is why doesn't the value reach my action class, when, before submitting the form, I have the right value when I try to display it.
I'm stuck, does anyone have an answer to this?
Thanks,