aspose file tools*
The moose likes Applets and the fly likes using Applet to speed up hiding of elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "using Applet to speed up hiding of elements" Watch "using Applet to speed up hiding of elements" New topic
Author

using Applet to speed up hiding of elements

Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Good day!

I have a table inside a table. Each sub-table is inside a <td>.
I have put an ID in each of those <td>'s so that whenever I
want to hide other sub-tables, I'll just access the <td> ID
through javaScript and hide it. It was supposed to be a breeze.
And it did for most cases. But my problem now is that I have a
sub-table which contains thousands of data and it loads so slow.

I have an idea which is to use my applet class code and "declare"
the hiding in there. Can I put code like this in there?

<CODE>
document.getElementById(tdID).style.display = 'none';
</CODE>

here's a snippet of my applet code:

<CODE>
win = JSObject.getWindow(this);
doc = (JSObject)win.getMember("document");

genForm = getParameter("genForm");
form = (JSObject)doc.getMember(genForm);

genField = getParameter("genField");
field = (JSObject)form.getMember(genField);

txtSendMsg.setText((String) field.getMember("value"));
</CODE>

Can I apply similar style to the javaScript code that I mentioned earlier?
can it speed up my hiding?

Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

I don't know if you can do that, but it really isn't obvious to me why you think the Javascript would run faster if you called from an applet instead of calling it directly. Or have I misunderstood your idea?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
I, too, have no idea if it will be faster, but using the Common DOM API you can manipulate the page's DOM tree directly from within an applet. That should at least be more straightforward than using LiveConnect.


Ping & DNS - my free Android networking tools app
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Thanks for your replies. Actually, my applet code is composed of
this:



I have tried using javaScript directly and it is really slow when it
comes to large tables. If the applet thing will not work, can you please
give me some advice or suggestions?

Thanks a lot.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
if (keyText == "Enter")

You should never use "==" to compare strings; it tests object equality, not string equality. Use the String.equals method instead.
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Okay, thanks for correcting me.
How about some advice on how to speed up the hiding thing?

Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
So you've tried the Common DOM approach, and it isn't fast enough either?

There are ways to change the stylesheet directly, so that all elements that are part of a particular class are changed all at once. That would be a question for the HTML/JavaScript forum, though.
[ June 27, 2008: Message edited by: Ulf Dittmer ]
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Thanks for your suggestion.
Ok, I'll post my inquiry in the HTML/JavaScript Forum.

God bless.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: using Applet to speed up hiding of elements