Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Element is undefined in a Java object of type class 1

Status
Not open for further replies.

bobkendall

Programmer
Sep 20, 2005
11
US
I am trying to debug a form that is basically a popup where the user enters a date and then two more dates are generated based off of date and the user can then edit those dates. When the user tries to save the second set of dates the "Element is undefined in a Java object of type class [Ljava.lang.String; referenced as" error is generated I am thinking this could just be a simple syntax error if that is the case here is the code for the page that has the error:

<cfif isdefined("form.txtFFFirstDate")> <!--- used clicked save---> <cfset SESSION.Order.FrequentFlyer.Use = "Y"> <cfset SESSION.Order.FrequentFlyer.UsedAtLeastOnce = "Y"> <cfset SESSION.Order.FrequentFlyer.TargetDate = ArrayNew(1)> <cfset SESSION.Order.FrequentFlyer.TargetDate[1] = #DateFormat(form.txtFFFirstDate,"MM/DD/YYYY")#> <cfloop index="i" from="2" to="#SESSION.Order.FrequentFlyer.Count#"> <cfset SESSION.Order.FrequentFlyer.TargetDate = #DateFormat(form.txtFFDateSet,"MM/DD/YYYY")#> </cfloop> </cfif>


my other idea is that the values are never being passed to this page.

<cfloop index="i" from="2" to="#SESSION.Order.FrequentFlyer.Count#"> <tr> <td> Date <cfoutput>#i#</cfoutput>: <input type="text" name="txtFFDateSetMonth[<cfoutput>#i#</cfoutput>]" class="txtboxdt" maxlength="2" value="<cfoutput>#Mid(DateFormat(dtTargetDate,"MM/DD/YYYY"),1,2)#</cfoutput>"> / <input type="text" name="txtFFDateSetDay[<cfoutput>#i#</cfoutput>]" class="txtboxdt" maxlength="2" value="<cfoutput>#Mid(DateFormat(dtTargetDate,"MM/DD/YYYY"),4,2)#</cfoutput>"> / <input type="text" name="txtFFDateSetYear[<cfoutput>#i#</cfoutput>]" class="txtboxdt" maxlength="2" value="<cfoutput>#Mid(DateFormat(dtTargetDate,"MM/DD/YYYY"),9,2)#</cfoutput>"> <input type="hidden" name="txtFFDateSet[<cfoutput>#i#</cfoutput>]"> </td> </tr> </cfloop> <input type="hidden" name="txtFFFirstDate" value="<cfoutput>#form.txtFFDateSet#</cfoutput>">

anyway any help at all would be great
 
the referring page has a loop that generate the value for the page that is getting the error and I am thinking that the value is not being passed to that page.


Code:
   <cfloop index="i" from="2" to="#SESSION.Order.FrequentFlyer.Count#">
   <tr>
      <td>
         Date <cfoutput>#i#</cfoutput>:
         <input type="text" name="txtFFDateSetMonth[<cfoutput>#i#</cfoutput>]" class="txtboxdt" maxlength="2"
            value="<cfoutput>#Mid(DateFormat(dtTargetDate[i],"MM/DD/YYYY"),1,2)#</cfoutput>"> /
         <input type="text" name="txtFFDateSetDay[<cfoutput>#i#</cfoutput>]" class="txtboxdt" maxlength="2"
            value="<cfoutput>#Mid(DateFormat(dtTargetDate[i],"MM/DD/YYYY"),4,2)#</cfoutput>"> /
         <input type="text" name="txtFFDateSetYear[<cfoutput>#i#</cfoutput>]" class="txtboxdt" maxlength="2"
            value="<cfoutput>#Mid(DateFormat(dtTargetDate[i],"MM/DD/YYYY"),9,2)#</cfoutput>">
         <input type="hidden" name="txtFFDateSet[<cfoutput>#i#</cfoutput>]">
      </td>
   </tr>         
   </cfloop>
   <input type="hidden" name="txtFFFirstDate" value="<cfoutput>#form.txtFFDateSet#</cfoutput>">

this hidden field
Code:
<input type="hidden" name="txtFFDateSet[<cfoutput>#i#</cfoutput>]">
contains the undefined value. does it need a value (name="" value="") on the referring page and if so what should it be?

Forgive me in advance if I am not being clear, I have looked at this issue all day with no revelations.
 
You didn't post your form tag but is it method = "post"? if not the browser may default to "get" which means you've got URL variables. The exact error and line it points to would be helpful.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
sorry about that I posted this on a few boards so lost track of what I posted where as far as the error. Anyway here is the form tag:

Code:
<cfform name="frmFF" action="FFAddSet.cfm" method="post" onsubmit="return validateform();">

and here is the error:

Code:
Error Occurred While Processing Request  
Element TXTFFDATESET is undefined in a Java object of type class [Ljava.lang.String; referenced as  
 
  
The error occurred in C:\HCDInetpub\hcimail.haines.com\Main\FFAddset.cfm: line 9
 
7 : 	<cfset SESSION.Order.FrequentFlyer.TargetDate[1] = #DateFormat(form.txtFFFirstDate,"MM/DD/YYYY")#>
8 : 	<cfloop index="i" from="2" to="#SESSION.Order.FrequentFlyer.Count#">
9 : 		<cfset SESSION.Order.FrequentFlyer.TargetDate[i] = #DateFormat(form.txtFFDateSet[i],"MM/DD/YYYY")#>
10 : 	</cfloop>
11 : </cfif>

 
I did this

Code:
<form action = "badPound.cfm" method = "post">
<input type = "hidden" name = "test[1]" value = "7/7/77">
<input type = "submit" value = "submit" name = "submit">
</form>
<cfif isdefined("form.submit")>
	<cfdump var = "#form#">
	<cfset i = 1>
	<cfoutput>#test[i]#</cfoutput>
</cfif>
The dump shows a value for "test[1]" however using <cfoutput>#test#</cfoutput> causes a "test is undefined" error.

Why? because CF doesn't see form variables like PHP does. PHP, which i'm sure you're trying to emulate uses arrays for form variable names when dealing with things such as radio buttons.

what I would do is change the names to not include the []'s

varName1, varName2, etc...
to get the value:
<cfset session.mySessionVar = evaluate("varName"&i)>


We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
ok I changed the first loop to:

Code:
<cfloop index="i" from="2" to="#SESSION.Order.FrequentFlyer.Count#">
	<tr>
		<td>
			Date <cfoutput>#i#</cfoutput>:
			<input type="text" name="txtFFDateSetMonth[<cfoutput>#form.txtFFDateSetMonth#</cfoutput>]" class="txtboxdt" maxlength="2" 
				value="<cfoutput>#Mid(DateFormat(dtTargetDate[i],"MM/DD/YYYY"),1,2)#</cfoutput>"> /
			<input type="text" name="txtFFDateSetDay[<cfoutput>#form.txtFFDateSetDay#</cfoutput>]" class="txtboxdt" maxlength="2"
				value="<cfoutput>#Mid(DateFormat(dtTargetDate[i],"MM/DD/YYYY"),4,2)#</cfoutput>"> /
			<input type="text" name="txtFFDateSetYear[<cfoutput>#form.txtFFDateSetYear#</cfoutput>]" class="txtboxdt" maxlength="2"
				value="<cfoutput>#Mid(DateFormat(dtTargetDate[i],"MM/DD/YYYY"),9,2)#</cfoutput>">
			<input type="hidden" name="txtFFDateSet[<cfoutput>#form.txtFFDateSet#</cfoutput>]">
		</td>
	</tr>			
	</cfloop>
	<input type="hidden" name="txtFFFirstDate" value="<cfoutput>#form.txtFFDateSet#</cfoutput>">

and the second loop to:

Code:
	<cfset SESSION.Order.FrequentFlyer.Use = "Y">
	<cfset SESSION.Order.FrequentFlyer.UsedAtLeastOnce = "Y">
	<cfset SESSION.Order.FrequentFlyer.TargetDate = evaluate("form.txtFFDateSet")>
	
	
	<cfset SESSION.Order.FrequentFlyer.TargetDate[1] = #DateFormat(form.txtFFFirstDate,"MM/DD/YYYY")#>
	<cfloop index="i" from="2" to="#SESSION.Order.FrequentFlyer.Count#">
		<cfset SESSION.Order.FrequentFlyer.TargetDate[i] = #DateFormat(form.txtFFDateSet,"MM/DD/YYYY")#>
	</cfloop>
</cfif>

and now I am getting:

Code:
Error Occurred While Processing Request  
Variable form.txtFFDateSet is undefined.  
 
  
The error occurred in C:\HCDInetpub\hcimail.haines.com\Main\FFAddset.cfm: line 5
 
3 : 	<cfset SESSION.Order.FrequentFlyer.Use = "Y">
4 : 	<cfset SESSION.Order.FrequentFlyer.UsedAtLeastOnce = "Y">
5 : 	<cfset SESSION.Order.FrequentFlyer.TargetDate = evaluate("form.txtFFDateSet")>

I think there still something I am not understanding about your example but at the moment it is esacping me
 
also I changed the var names to dtTargetDate1 instead of tTargetDate but this throws an undefined error as well:

Code:
Error Occurred While Processing Request  
Variable DTTARGETDATE1 is undefined.  
 
  
The error occurred in C:\HCDInetpub\hcimail.haines.com\Main\FFEditSet.cfm: line 131
 
129 : 			Date <cfoutput>#i#</cfoutput>:
130 : 			<input type="text" name="txtFFDateSetMonth[<cfoutput>#form.txtFFDateSetMonth#</cfoutput>]" class="txtboxdt" maxlength="2" 
131 : 				value="<cfoutput>#Mid(DateFormat(dtTargetDate1,"MM/DD/YYYY"),1,2)#</cfoutput>"> /
132 : 			<input type="text" name="txtFFDateSetDay[<cfoutput>#form.txtFFDateSetDay#</cfoutput>]" class="txtboxdt" maxlength="2"
133 : 				value="<cfoutput>#Mid(DateFormat(dtTargetDate2,"MM/DD/YYYY"),4,2)#</cfoutput>"> /



 
what did you change in the first loop? all the names still have "varName[#i#]"? the idea is to take out the brackets varName#i#

In your first loop where the value comes from(?) you didn't change anything
Code:
<input type="hidden" name="txtFFDateSet[<cfoutput>#form.txtFFDateSet#</cfoutput>]">
should be
Code:
<input type="hidden" name="txtFFDateSet<cfoutput>#form.txtFFDateSet#</cfoutput>">
You also have no value for this form field. why set it to begin with?

Your second loop says
Code:
<cfset SESSION.Order.FrequentFlyer.TargetDate[i] = #DateFormat(form.txtFFDateSet,"MM/DD/YYYY")#>
it should say
Code:
<cfset SESSION.Order.FrequentFlyer.TargetDate[i] = #DateFormat(evaluate("form.txtFFDateSet"&i),"MM/DD/YYYY")#>

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Here is a very simple example of this theory:
Code:
<cfif isdefined("form.submit")>
	<cfoutput>
		<cfloop from = "1" to = "10" index = "i">
			text box: #i# = #evaluate("form.txtBox" & i)#<br>
		</cfloop>
		<br>
	</cfoutput>
</cfif>
<form name = "loopForm" method = "post">
	<cfoutput>
		<cfloop from = "1" to = "10" index = "i">
			#i#: <input type = "text" name = "txtBox#i#"><br>
		</cfloop>
	</cfoutput>
	<input type = "submit" name = "submit" value = "submit">
</form>

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
ok I made the two changes that you suggested above.

I changed the first loop to:

<input type="hidden" name="txtFFDateSet<cfoutput>#form.txtFFDateSet#</cfoutput>">

and the second loop to:

<cfloop index="i" from="2" to="#SESSION.Order.FrequentFlyer.Count#">
<cfset SESSION.Order.FrequentFlyer.TargetDate = #DateFormat(evaluate("form.txtFFDateSet"&i),"MM/DD/YYYY")#>
</cfloop>

and I am getting the following error:

Error Occurred While Processing Request
Variable I is undefined.


The error occurred in C:\HCDInetpub\hcimail.haines.com\Main\FFAddset.cfm: line 13

11 : </cfif>
12 : <script type="text/javascript">
13 : alert("<cfoutput>#DateFormat(evaluate("form.txtFFDateSet"&i),"MM/DD/YYYY")#</cfoutput>");
14 : window.close();
15 : </script>



Is it just a syntax issue at this point or am I still missing something?
 
I was the index in your loop. if it isn't in a loop with an index of I, then I will not exist

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
ok I removed the I and wrote the line like this:

<script type="text/javascript">
alert("<cfoutput>#DateFormat(form.txtFFDateSet,"MM/DD/YYYY")#</cfoutput>");
window.close();
</script>

and now I am getting:

Element TXTFFDATESET is undefined in FORM.

the page before this one (the first loop)
has:
<input type="hidden" name="txtFFDateSet<cfoutput>#form.txtFFDateSet#</cfoutput>">

I did not give it a value because the value is done with javascript at the top of that page do I need to declare a value anyway?

Sorry to be such a pain but I am really lost with this and thank you for being patient with me I am sure I am frustrating.
 
no you don't need a value.

in your first page You have a loop. lets say it goes from 1 to 10.

when you submit the page you're going to have 10 form elements
form.txtFFDateSet1
form.txtFFDateSet2
form.txtFFDateSet3
form.txtFFDateSet4
form.txtFFDateSet5
form.txtFFDateSet6
form.txtFFDateSet7
form.txtFFDateSet8
form.txtFFDateSet9
form.txtFFDateSet10

You get an error on this line:
alert("<cfoutput>#DateFormat(form.txtFFDateSet,"MM/DD/YYYY")#</cfoutput>");
because there is no such thing as form.txtFFDateSet your choices are form.textFFDateSet1 - form.textFFDateSet10

here is an faq i wrote a while back to help understand error messages. it sounds like you don't understand what "Element TXTFFDATESET is undefined in FORM. " is telling you.

faq232-5932

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
no I understand that you can't use elements that have not been created. I was assuming that they were created by the loop. t anyrate I am now getting an error message consistent with what you said above

Variable form.txtFFDateSet2 is undefined.


The error occurred in FFAddset.cfm: line 9

7 : <cfset SESSION.Order.FrequentFlyer.TargetDate[1] = #DateFormat(form.txtFFFirstDate,"MM/DD/YYYY")#>
8 : <cfloop index="i" from="2" to="#SESSION.Order.FrequentFlyer.Count#">
9 : <cfset SESSION.Order.FrequentFlyer.TargetDate = #DateFormat(evaluate("form.txtFFDateSet"&i),"MM/DD/YYYY")#>
10 : </cfloop>
11 : </cfif>

and here is the changes I made to the page:

<cfif isdefined("form.txtFFFirstDate")>

<cfset SESSION.Order.FrequentFlyer.Use = "Y">
<cfset SESSION.Order.FrequentFlyer.UsedAtLeastOnce = "Y">
<cfset SESSION.Order.FrequentFlyer.TargetDate = ArrayNew(1)>

<cfset SESSION.Order.FrequentFlyer.TargetDate[1] = #DateFormat(form.txtFFFirstDate,"MM/DD/YYYY")#>
<cfloop index="i" from="2" to="#SESSION.Order.FrequentFlyer.Count#">
<cfset SESSION.Order.FrequentFlyer.TargetDate = #DateFormat(evaluate("form.txtFFDateSet"&i),"MM/DD/YYYY")#>
</cfloop>
</cfif>
<script type="text/javascript">
alert("<cfoutput>#DateFormat(form.txtFFFirstDate,"MM/DD/YYYY")#</cfoutput>");
window.close();
</script>
 
what is the value of SESSION.Order.FrequentFlyer.Count?

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
this value is pulled from the data base and at the moment it would be a total of three dates. It basically takes the original date that the users inputs and calulates two dates from that so we have:
form.txtFFFirstDate
form.txtFFDateSet2
form.txtFFDateSet3

this original app works the modification that I was making was allowing the user to modify dates two and three
 
The evaluate statement is what I needed and after I adjusted some some syntax errors everthing worked thanks for all your help on this!
 
glad you got it working.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top