Michael Stitch

Greenhorn
+ Follow
since Nov 09, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michael Stitch

Hi:
I have a JSP page in my Struts application that displays months in a <Table> as followed:

<table><TBODY class=dates id=anotherList onclick="getDate()" >
<tr>
<td style="cursor:hand" onclick="selectedMth=1">Jan</td>
<td style="cursor:hand" onclick="selectedMth=2">Feb</td>
<td style="cursor:hand" onclick="selectedMth=3">Mar</td>
</tr>
</TBODY></table>

I also have an input TEXT field that is to pass a combination of 'mth/yr' to the struts Action class, so my input field is as followed:
<html:text property='mth_yr' name='mth_yr' id='mth_yr' />


I also have a JavaScript function 'getDate()' to dynamically update the above TEXT field when the month that is clicked from the above <Table>
var selectedMth = 1; // global varaible
function getDate()
{
var whichYr = document.getElementById('year')[document.getElementById('year').selectedIndex].text;
document.getElementByNme('mth_yr').value= selectedMth + "/" + whichYr;
}


When I clicked any of the month from the above month <Table>, I got the following error:
Error: Object doesn't support property or method getElementByName. [note: I also try document.getElemenByID('mth_yr'), same error]

I can see from JavaScript debugging that when I clicked (e.g. Mar). 'selectedMth' will be set to '3' (so the table/onclick works), but the <html:text> will not be updated and I got the above Error.

Now, if I change the above <html:text> to standard html <TEXT> field as followed:
<input type="text" name="mth_yr" id="mth_yr"/>
then the <TEXT> field will be updated to (e.g. 3) with no error. But the problem with this standard html <TEXT> field, I will not have the 'property' 'mth_yr' to be passed to the Struts Action form.

So bottom line: how do I make the above work such that when I select a 'month' from the above table, the INPUT Text field will be updated with the mth-yr value and at the same time, this field will be passed to the Action class as a property.

Can anyone help?

Thanks,
sportyNerd
9 years ago
Thanks for all the responses. The people who supply me with all the mal-formed XML files are customer. They want me to fix the issue instead of fixing the problem themselves so that's why I try to write a program to fix them.

I did try to update the xml file as a text file but it didn't work. It will update the '&' but I have to write the updated line into another file rather than the original file. In other words, the file is another copy of the original file.

OK, for some reason in my original post, it strips off the "<ampersand>amp;" from all my text.....The only place that it didn't strip off my '<ampersand>amp;' is in the "subject line" of my post. So just to clarify what I need help...how do I change my Java code so it will change all the '&' into '<ampersand>amp;' in all my XML files with Java and not getting the error that I am getting.

Thanks,
Venessa

I have written a piece of code in Java to update a bunch of XML file to replace the '&' with '&' in a XML tag, that is to convert the single ampersand to the literal ampersand with semicolon. When I run it in JDeveloper, it gave me an error. It does not like the '&' when it tries to retrieve the content from the 'Company_Name' tag.
Here is part of my XML file that I am trying to replace '&' with '&' so the XML files can be parsed by an XML editor.

<Company_Name> A & W </Company_Name>

I want to change it to:
<Company_Name> A & W </Company_Name>

Here is my part of my code:

for (final File fileEntry : folder.listFiles()) {
doc = dBuilder.parse(fileEntry);
nList = doc.getElementsByTagName("Company_Name");
str = nList.item(0).getTextContent();
str = str.replaceAll("&","&");
nList.item(o).setTextContent(str);

TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = TransformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(fileEntry);

}

Here is the error I got:

[Fatal Error] test.xml: 1:1661: The entity name must immediately follow the '&' in the entity
reference....org.xml.sax.SAXParseException; systemId: file:/C:/test.xml.......follow the '&' in the entity reference.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse (DOMParser.java:257)

Do you know how I can change my code so it will update all the XML for me from '&' to '&s;'?

Thanks for any help.....
Hi:
In my .jsp file I included a JS file 'abc.js'. This .js file has embedded java code to retrieve data value from a java class. For some reason Tomcat does not like the embedded java code. I was told that I have to change the Tomcat configuraiton to allow pasrsing Java inside the JSP .js file. Can someone tell me how do I configure Tomcat to do that?

abc.js -

function displaySession(){
document.getElementById("update_field" ).style.display = "<%=student.getUpdateField()%>";

Thanks.
12 years ago
Hi:
In my .jsp file I included a JS file 'abc.js'. This .js file has embedded java code to retrieve data value from a java class. For some reason Tomcat does not like the embedded java code. I was told that I have to change the Tomcat configuraiton to allow pasrsing Java inside the JSP .js file. Can someone tell me how do I configure Tomcat to do that?

abc.js -

function displaySession(){
document.getElementById("update_field" ).style.display = "<%=student.getUpdateField()%>";

Thanks.
Hi:
In my .jsp file I included a JS file 'abc.js'. This .js file has embedded java code to retrieve data value from a java class. For some reason Tomcat does not like the embedded java code. I was told that I have to change the Tomcat configuraiton to allow pasrsing Java inside the JSP .js file. Can someone tell me how do I configure Tomcat to do that?

abc.js -

function displaySession(){
document.getElementById("update_field" ).style.display = "<%=student.getUpdateField()%>";

Thanks.
12 years ago
Hi:
In my .jsp file I included a JS file 'abc.js'. This .js file has embedded java code to retrieve data value from a java class. For some reason Tomcat does not like the embedded java code. I was told that I have to change the Tomcat configuraiton to allow pasrsing Java inside the JSP .js file. Can someone tell me how do I configure Tomcat to do that?

abc.js -

function displaySession(){
document.getElementById("update_field" ).style.display = "<%=student.getUpdateField()%>";

Thanks.
12 years ago