?
Solved

struts layout treeview

Posted on 2005-03-22
23
Medium Priority
?
1,749 Views
Last Modified: 2007-12-19
Hi,

I need help with struts layout treeview I could able to get the treeview on the screen, but when I click on the plus symbol , i get an javascript error. It says "object expected".

there is no javascript code at all in my jsp page! It is part of treeview tag i suppose.

please help..

thanks  a lot
0
Comment
Question by:johnson100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 6
  • 5
23 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13607847
If you are on a web page when you click then there is javascript because that is how all the event handlers are implemented.

What is th ecompletemessage you get and which browser are you using/

Cd&
0
 

Author Comment

by:johnson100
ID: 13611743
I am using IE 6.0.  

message is as folllows:

An error has occured in the script on this page

Line: 42
char: 1
code: 0
error: object expected



thanks a lot
0
 

Author Comment

by:johnson100
ID: 13612585
can some body help me out here

thanks
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13613201
Well we are going to see the code to find out what is on line 42 and see why it does not like what is being referenced in the event.

Please post the generated HTML  

*** IMPORTANT  we need to see the client side HTML.  The JSP code from the server is not going help find the error at this point

Cd&
0
 

Author Comment

by:johnson100
ID: 13613693
This is the line 42 of the source where it is pointing  and at the bottom I pasted my jsp code.


========================================================
Line 42

<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td valign="top" height="100%" style="background-image: url(/MediaCode/images/treeLine.gif); background-repeat: repeat-y; " width="16"><a href="javascript://" onclick="return changeTree('0*0','/MediaCode/images/treeNodeOpen.gif','/MediaCode/images/treeNodeClose.gif');" target="treeFrame"><img src="/MediaCode/images/treeNodeClose.gif" id="treeViewImage0*0" border="0" width="16" height="22" align="middle"></a></td><td valign="top" colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td width="1"></td><td class="treeview1">DIRECTMEDIA</td><td align="right" nowrap></td></tr><tr><td valign="top" colspan="2" id="treeView0*0" style="display:none;"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td valign="top" height="100%" style="background-image: url(/MediaCode/images/treeLine.gif); background-repeat: repeat-y; " width="16"><a href="javascript://" onclick="return changeTree('0*0*0','/MediaCode/images/treeNodeOpen.gif','/MediaCode/images/treeNodeClose.gif');" target="treeFrame"><img src="/MediaCode/images/treeNodeClose.gif" id="treeViewImage0*0*0" border="0" width="16" height="22" align="middle"></a></td><td valign="top" colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td width="1"></td><td class="treeview2">ACTIVE</td><td align="right" nowrap></td></tr><tr><td valign="top" colspan="2" id="treeView0*0*0" style="display:none;"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td valign="top" height="100%" style="background-image: url(/MediaCode/images/treeLine.gif); background-repeat: repeat-y; " width="16"><img src="/MediaCode/images/treeItem.gif" border="0" width="16" height="22"></td><td width="1"></td><td class="treeview3"><a href="http://www.infousa.com" class="treeview4">DIRECTMEDIA ACTIVE1</a></td><td align="right" nowrap></td></tr><tr><td valign="top" height="100%" width="16"><img src="/MediaCode/images/treeItemLast.gif" border="0" width="16" height="22"></td><td width="1"></td><td class="treeview3"><a href="http://www.infousa.com" class="treeview4">DIRECTMEDIA ACTIVE2</a></td><td align="right" nowrap></td></tr></table></td></tr></table></td></tr><tr><td valign="top" height="100%" width="16"><a href="javascript://" onclick="return changeTree('0*0*1','/MediaCode/images/treeNodeOpenLast.gif','/MediaCode/images/treeNodeCloseLast.gif');" target="treeFrame"><img src="/MediaCode/images/treeNodeCloseLast.gif" id="treeViewImage0*0*1" border="0" width="16" height="22" align="middle"></a></td><td valign="top" colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td width="1"></td><td class="treeview2">INACTIVE</td><td align="right" nowrap></td></tr><tr><td valign="top" colspan="2" id="treeView0*0*1" style="display:none;"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td valign="top" height="100%" style="background-image: url(/MediaCode/images/treeLine.gif); background-repeat: repeat-y; " width="16"><img src="/MediaCode/images/treeItem.gif" border="0" width="16" height="22"></td><td width="1"></td><td class="treeview3"><a href="http://www.infousa.com" class="treeview4">DIRECTMEDIA INACTIVE1</a></td><td align="right" nowrap></td></tr><tr><td valign="top" height="100%" width="16"><img src="/MediaCode/images/treeItemLast.gif" border="0" width="16" height="22"></td><td width="1"></td><td class="treeview3"><a href="http://www.infousa.com" class="treeview4">DIRECTMEDIA INACTIVE2</a></td><td align="right" nowrap></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr><tr><td valign="top" height="100%" width="16"><a href="javascript://" onclick="return changeTree('0*1','/MediaCode/images/treeNodeOpenLast.gif','/MediaCode/images/treeNodeCloseLast.gif');" target="treeFrame"><img src="/MediaCode/images/treeNodeCloseLast.gif" id="treeViewImage0*1" border="0" width="16" height="22" align="middle"></a></td><td valign="top" colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td width="1"></td><td class="treeview1">ONLINE</td><td align="right" nowrap></td></tr><tr><td valign="top" colspan="2" id="treeView0*1" style="display:none;"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td valign="top" height="100%" style="background-image: url(/MediaCode/images/treeLine.gif); background-repeat: repeat-y; " width="16"><a href="javascript://" onclick="return changeTree('0*1*0','/MediaCode/images/treeNodeOpen.gif','/MediaCode/images/treeNodeClose.gif');" target="treeFrame"><img src="/MediaCode/images/treeNodeClose.gif" id="treeViewImage0*1*0" border="0" width="16" height="22" align="middle"></a></td><td valign="top" colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td width="1"></td><td class="treeview2">ACTIVE</td><td align="right" nowrap></td></tr><tr><td valign="top" colspan="2" id="treeView0*1*0" style="display:none;"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td valign="top" height="100%" style="background-image: url(/MediaCode/images/treeLine.gif); background-repeat: repeat-y; " width="16"><img src="/MediaCode/images/treeItem.gif" border="0" width="16" height="22"></td><td width="1"></td><td class="treeview3"><a href="http://www.infousa.com" class="treeview4">ONLINE ACTIVE1</a></td><td align="right" nowrap></td></tr><tr><td valign="top" height="100%" width="16"><img src="/MediaCode/images/treeItemLast.gif" border="0" width="16" height="22"></td><td width="1"></td><td class="treeview3"><a href="http://www.infousa.com" class="treeview4">ONLINE ACTIVE2</a></td><td align="right" nowrap></td></tr></table></td></tr></table></td></tr><tr><td valign="top" height="100%" width="16"><a href="javascript://" onclick="return changeTree('0*1*1','/MediaCode/images/treeNodeOpenLast.gif','/MediaCode/images/treeNodeCloseLast.gif');" target="treeFrame"><img src="/MediaCode/images/treeNodeCloseLast.gif" id="treeViewImage0*1*1" border="0" width="16" height="22" align="middle"></a></td><td valign="top" colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td width="1"></td><td class="treeview2">INACTIVE</td><td align="right" nowrap></td></tr><tr><td valign="top" colspan="2" id="treeView0*1*1" style="display:none;"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td valign="top" height="100%" style="background-image: url(/MediaCode/images/treeLine.gif); background-repeat: repeat-y; " width="16"><img src="/MediaCode/images/treeItem.gif" border="0" width="16" height="22"></td><td width="1"></td><td class="treeview3"><a href="http://www.infousa.com" class="treeview4">ONLINE INACTIVE1</a></td><td align="right" nowrap></td></tr><tr><td valign="top" height="100%" width="16"><img src="/MediaCode/images/treeItemLast.gif" border="0" width="16" height="22"></td><td width="1"></td><td class="treeview3"><a href="http://www.infousa.com" class="treeview4">ONLINE INACTIVE2</a></td><td align="right" nowrap></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table><iframe id="treeFrame" name="treeFrame" style="width:0px; height:0px; border: 0px" src="about:blank"></iframe></td></tr></table></td></tr></table>




=========================================================


jsp code



<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/tags/struts-layout" prefix="layout" %>
<%@ page import="fr.improve.struts.taglib.layout.util.LayoutUtils" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<html>

<head>
<link rel="stylesheet" type="text/css" href="/MediaCode/css/stylesheet.css"/>
<title>Manage Media Code</title>

</head>

<html:base/>
<layout:skin/>

<body background="/MediaCode/images/PaperTexture.gif">

<div style="position:relative;width:700px;left:10px;background-color:#7171A5">
      <div style="position:relative;left:0px;top:1px;">
            <img src="/MediaCode/images/iusa.jpg" height="35"/>
      </div>
      <div style="position:absolute;left:150px;top:0px;" class="logo">
      Media Code - Add Category
      </div>
</div>


            
      <div style="position:relative;left:210px;top:30px;height:500px;width:600px;">
            <table>            
            <tr><td><font color="black">CATEGORY</font></td></tr>
            <tr>
            <td style="vertical-align:top;padding:15px;">
                        
            <font color="black"><layout:treeview align="left" name="category" styleClass="treeview"/></font>
                  </td>
            </tr>
            </table>            
      </div>
      </body>

</html>
======================================================


Thanks a lot
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13614936
It is looking for a javascript function named changeTree which I do not see any where in the code.


Cd&
0
 

Author Comment

by:johnson100
ID: 13615177
that is what I mentioned, I am using struts-layout so it comes with struts layout software. The changetree function is available in the javascript file at the configuration file as mentioned in the specification.


thanks
0
 

Author Comment

by:johnson100
ID: 13615384
this is the changeTree function in the struts-layout configuration file


function changeTree(tree, image1, image2) {
      var image = document.getElementById("treeViewImage" + tree);
      if (image.src.indexOf(image1)!=-1) {
            image.src = image2;
      } else {
            image.src = image1;
      }

      if (document.getElementById("treeView" + tree).innerHTML == "") {
            return true;
      } else {
            changeMenu("treeView" + tree);
            return false;
      }
}




thank a lot
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13615532
It has not been included in the html page. I do not see anything in the struts code that is putting it in the page.  There are no script tags anywhere.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13615540
It has not been included in the html page. I do not see anything in the struts code that is putting it in the page.  There are no script tags anywhere.

Cd&
0
 

Author Comment

by:johnson100
ID: 13616163
that will be done in the web deployment descriptor file


thanks
0
 

Author Comment

by:johnson100
ID: 13616280
these r   the required tags in the descriptor file

<context-param>
        <param-name>struts-layout-config</param-name>
        <param-value>config</param-value>
  </context-param>
  <context-param>
        <param-name>struts-layout-image</param-name>
        <param-value>images</param-value>
  </context-param>
  <context-param>
        <param-name>struts-layout-skin</param-name>
        <param-value>default</param-value>
  </context-param>



thanks
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13616483
I'm not a struts developer, and I only do a little java, so I don't know what those configuration files do.  All I know is that the function is not in the page, so there is something wrong on the jsp side of it and the page is not being generated correctly.

Cd&
0
 

Author Comment

by:johnson100
ID: 13616579
yes u r right it is not finding the required function, even though it is in the configuration file, that was the problem, thanks for ur time cd.

Any expert who can help me out here with struts-layout treeview problem.


thanks a lot
0
 

Author Comment

by:johnson100
ID: 13617176
thanks
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13619951
Hiya :-)

I'm no expert when it comes to the <Struts:layout> tags, but I *believe* after skimming the docs that the <layout:skin/> tag just inserts the specified CSS stylesheet, and does not import javascript...

When you view the page in the browser, and "View Source" is any javascript included in the page?

Specifically the

    function changeTree(tree, image1, image2) {

bit of javascript?

It should be visible in the source of the page you are viewing...  My guess is it isn't there...

Tim
0
 

Author Comment

by:johnson100
ID: 13622564
yes Tim, u r right it is not taking the javascript, but according to the specification it has to be in the config directory,I did that but it doesnt recognise that!!!

I tried putting  all the javascript  locally then it worked!

Where shud javascript file be put exactly ? in which directory?


thanks
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13622622
Try:

<layout:skin includeScript="true"/>

and put the script where you had it before...

As I said, I am no expert with this taglib though :-(
0
 
LVL 35

Accepted Solution

by:
TimYates earned 2000 total points
ID: 13622661
According to the API docs:

Attribute Name:  includeScript
Description:  If set to true, include the struts-layout javascript files

so (hopefully) that should fix it ;-)

let me know how you get on!
0
 

Author Comment

by:johnson100
ID: 13623074
hey Tim that was wonderfull :-). It worked.

Could u please let me know where did u find?

also send me some links if u have on this topic


thanks a lot all of u.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13623124
I found it here:

http://struts.application-servers.com/doc/index.html#skin

That is the only link I have on the topic ;-)  heehee, never seen struts:layout before...  

but I'm going to make some time next week to have a look at it :-)

Glad you got this sorted :-)

Good luck with it all :-)

Tim
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13623132
And thanks should go to COBOLdinosaur... it was his link in the JSP forums that led me here ;-)

*wanders off back to the JSP TA*

;-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question