Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Juana Fisher   on Aug 07 In Java Category.

  
Question Answered By: Miriam Green   on Aug 07

I thought I had this figured out, but maybe not. Might have been some
browser caching confusing me. Took it out of the package and it's
loading OK. I'll worry about the package later. Thanks for
everyone's advice. But now I have a new problem.

I can't access Java methods from my JavaScript. Relevant lines from
the HTML:

function lgoto(n){
var i;
for ( i=1 ; i<=guide_cols ; i++ ){
var hc=sel_row%2 ? 'rowh' : 'row';
getRef('TD'+sel_row+'.'+i).className=hc;
getRef('TD'+n+'.'+i).className='rows';
}
sel_row=n;
document.DataLink.refreshData(""+n); <-- bad line
}

...

<applet id="DataLink" name="DataLink" code="RowDataLink.class">
<param name="ModelName"
value="com.taylorlumberinc.bean.model.LumberInventory"/>
</applet>

The applet source is:

/*
* RowDataLink.java
*
* Created on October 7, 2004, 9:17 AM
*/

import HTTPClient.HTTPResponse;
import HTTPClient.HTTPConnection;
import HTTPClient.NVPair;
import java.util.HashMap;

/**
*
* @author dcouchotvore
*/
public class RowDataLink extends java.applet.Applet {

protected String model_name="";
protected HashMap Data=null;
protected HTTPConnection conn;

/** Initialization method that will be called after the applet is
loaded
* into the browser.
*/

public void init()
{

try {
Data=new HashMap(50);
conn=new HTTPConnection(getCodeBase());
model_name=getParameter("ModelName");
}
catch ( java.io.IOException E ){
}
}

/** Fetches the nth row of the ResultSet attached to the specified
data
* model, returning them in ColumnName=(String)value format,
sepearated
* by newlines. */

public void refreshData(String _n)
{
NVPair fdata[]={
new NVPair("modelname", model_name),
new NVPair("index", _n)
};
try {
HTTPResponse resp=conn.Post("FetchDataFields", fdata);
String rdata=new String(resp.getData());
String[] lines=rdata.split("\n");
Data.clear();
for ( int i=0 ; i<lines.length ; i++ ){
String[] pair=lines[i].split("=");
Data.put(pair[0], pair[1]);
}
}
catch ( java.io.IOException E ){
// @@@ to be continued...
}
catch ( HTTPClient.ModuleException E ){
// @@@ to be continued...
}
}

public String getField(String _name)
{
return (String)Data.get(_name);
}

public void putField(String _name, String _value)
{
Data.put(_name, _value);
}
}

Firefox says, "Error: document.DataLink.refreshData is not a function".
IE says something like "Object does not support this propery or method".

Any thoughts on this? What's really frustrating is that I did an
almost identical applet before and didn't run into all this trouble.
Maybe there's a curse...

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on That @#$%!% codebase Or get search suggestion and latest updates.


Tagged: