Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java script error help please

 
Makhana Jiggu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run the following jsp to automaticcally refresh every 10 seconds i'm geting javascript error that object is null on line document.refreshForm.submit(). can you please help on sloving the issue.
I double checked the stuts file and action and form path has been defined.

<%@ page import='java.util.*' %>

<%@ page import='presentation.action.RefreshTimer' %>

<%@page import='presentation.action.RefreshAction'%>

<%@page import='presentation.form.RefreshForm'%>

<script language="javascript" >

var temp = window.setInterval('submitPage()',10*1000);


function submitPage(){


alert("before count submit");

document.refreshForm.submit();

var xyz = <%=application.getAttribute("counter")%>

alert("New Request is " + xyz);

}

</script>




<html:form action="/refresh.do" method="post" onsubmit ="submitPage()">


</html:form>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the HTML/Javascript forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is refreshForm defined?
 
Makhana Jiggu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,
RefreshForm is deifned in the struts file of the action path(refresh.do) and form bean
<form bean name ="refreshForm" path="presentation.form.RefreshForm">
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is not in your above example.
 
bujji makani
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The form name is defined in sturts config file of that particluar action which is refresh.do

Even if i declare the form name as myform when i call the jsp page it gives me an error that document.myForm is not an object or is null. How can i resolve this.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order for the reference document.refreshForm to resolve to an actual element, there has to be a form element with that name defined on the page. Until there is, you are going to continue to get the error.

What are you trying to accomplish by submitting a form that does not exist on the page?
 
bujji makani
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

I defined on the form page as follows:
<html:form name ="refreshForm" action="/refresh.do" method="post" type ="presentation.form.RefreshForm">

This does not work so I created a hidden element but did not work either.
<input type="hidden" name="refreshForm" value="count" />

I want to submit the form to the server to get new values from database.
how can i submit this form from jsp page to the server without using submit buttons.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You already posted the code above to do it.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This does not work


This is not useful information that will help diagnose the problem. How does it not work?


This does not work so I created a hidden element but did not work either.


Stabbing in the dark is rarely effective.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
document.refreshForm.submit();


<input type="hidden" name="refreshForm" value="count" />


As Bear pointed out, refreshForm needs to be a form, you can't define it as an input element.
[ January 30, 2006: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic