473,656 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript inside struts

Hello,

I've been trying to figure something out for the past few days and I
can't seem to pinpoint what I'm doing wrong.

I've been trying to call javascript from inside a <logic:equal> , but
it doesn't seem to work like I want.

I've tried calling an alert('hello'); to test out if my call worked
correctly, and it does, but when I call my own javascript functions
that I create in the html/head, they don't seem to get executed. Any
idea why (except disbaleCif() which I call through onload)?

Here's a snippet of code:

<html>
<head>
<link REL="stylesheet " HREF="css/bear.css" TYPE="text/
css">
<script type="text/javascript">
function disableCif()
{

document.Manage KQADocumentForm .cifType1.disab led="true";

document.Manage KQADocumentForm .cifType2.disab led="true";

document.Manage KQADocumentForm .cifType3.disab led="true";
}

function enableCifType1( )
{

document.Manage KQADocumentForm .cifType1.disab led="false";
}

function enableCifType2( )
{

document.Manage KQADocumentForm .cifType2.disab led="false";
}

function enableCifType3( )
{

document.Manage KQADocumentForm .cifType3.disab led="false";
}
</script>
</head>
<body class="MainBody " onload="javascr ipt:disableCif( );">
<logic:iterat e id="cifType"
property="check ItemFormTypes"
name="manageKQA DocumentTO">
<logic:equal value="1" name="cifType">
<scriptalert('h ello'); </script>
</logic:equal>
<logic:equal value="2" name="cifType">
<scriptenableCi fType2(); </script>
</logic:equal>
<logic:equal value="3" name="cifType">
<scriptenableCi fType3(); </script>
</logic:equal>
</logic:iterate>

Regards
Jean-Francois Michaud

Jan 29 '07 #1
5 19997
VK
On Jan 29, 7:30 pm, "Jean-François Michaud" <come...@comcas t.net
wrote:
I've tried calling an alert('hello'); to test out if my call worked
correctly, and it does, but when I call my own javascript functions
that I create in the html/head, they don't seem to get executed. Any
idea why (except disbaleCif() which I call through onload)?
Firefox reports "document.Manag eKQADocumentFor m has no properties"
which is correct because neither HTML nor XHTML have element
ManageKQADocume ntForm so UA doesn't have any DOM interface for it.

I am not clear what markup is that? It is not HTML nor XHTML for sure,
at the max it is a malformed invalid XML fragment - if served as text/
html then treated as broken HTML tag soup. In either case
ManageKQADocume ntForm element doesn't appear by some magic.

It would help to understand what do you mean by "struts" in
application to (X)HTML then a workable solution could be suggested.

Jan 29 '07 #2
"VK" <sc**********@y ahoo.comwrote:
>I am not clear what markup is that? It is not HTML nor XHTML for sure,
at the max it is a malformed invalid XML fragment - if served as text/
html then treated as broken HTML tag soup. In either case
ManageKQADocum entForm element doesn't appear by some magic.
As he said, it's Struts (http://struts.apache.org), a Java-based web
application framework. The <logictags enable the page to be put
together conditionally on the server side. The javascript is all
client side, and I'd say your diagnosis is correct: the element he's
trying to enabled doesn't exist, at least not in the code he showed
us. And, even in Struts, that element won't appear by magic.

--
Tim Slattery
Sl********@bls. gov
http://members.cox.net/slatteryt
Jan 29 '07 #3
I'm sorry, I should have written down a complete section of code.

Here goes. ManageKQADocume ntForm is a Form I have set up for the
current jsp page (ManageKQADocum entForm.java). The Form logic work. I
can transfer data around without problems to and from the Form and a
Transfer Object is used to communicate with a Database (DAO object).
My problem is not with the underlying strut logic. It's with the call
to a javascript function inside a <logic:equal(th e functions are in
the <headtags). If I call an "alert('hel lo world');" inside the
<logic:equal> , it works, If I call my own function, it doesnt.

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"% >
<bean:define id="manageKQADo cumentTO" name="ManageKQA DocumentTO"></
bean:define>
<jsp:include page="/jsp/common/header.jsp" flush="true" />
<jsp:include page="/jsp/common/menu.jsp" flush="true" />
<jsp:include page="/jsp/common/errorpage.jsp" flush="true" />

<html>
<head>
<link REL="stylesheet " HREF="css/bear.css" TYPE="text/css">
<script type="text/javascript">
function disableCif()
{
document.Manage KQADocumentForm .cifType1.disab led="true";
document.Manage KQADocumentForm .cifType2.disab led="true";
document.Manage KQADocumentForm .cifType3.disab led="true";
}

function enableCifType1( )
{
document.Manage KQADocumentForm .cifType1.disab led="false";
}

function enableCifType2( )
{
document.Manage KQADocumentForm .cifType2.disab led="false";
}

function enableCifType3( )
{
document.Manage KQADocumentForm .cifType3.disab led="false";
}
</script>
</head>
<body class="MainBody " onload="javascr ipt:disableCif( );">
<logic:iterat e id="cifType" property="check ItemFormTypes"
name="manageKQA DocumentTO">
<logic:equal value="1" name="cifType">
<scriptalert('h ello'); </script>
</logic:equal>
<logic:equal value="2" name="cifType">
<scriptenableCi fType2(); </script>
</logic:equal>
<logic:equal value="3" name="cifType">
<scriptenableCi fType3(); </script>
</logic:equal>
</logic:iterate>
<form name="ManageKQA DocumentForm">
<table border="0" width="100%" class="TableBod y" cellspacing="0"
cellpadding="0" >
<tr>
<td WIDTH="100%" CLASS="PageHead ing">KQA Edit Management</td>
</tr>
</table>
<br>
<table border="0" width="100%" class="TableBod y" cellspacing="0"
cellpadding="0" >
<tr>
<td>
<input type="text" name="sbnumber" size="20"/
>&nbsp;&nbsp;&n bsp;&nbsp;Enter a Service Bulletin
number.&nbsp;&n bsp;&nbsp;&nbsp ;<input type="button"
name="sbnumbers ubmit" value="Submit"
onclick="javasc ript:sbnumberCh eck()"/>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0" >
<tr>
<td valign="middle" align="left">
<input type="radio" name="cifType1" setGroup="group 1"
value="1"/>&nbsp;&nbsp;&n bsp;&nbsp;
<% int count = 0; %>
<logic:iterat e id="cifTypeLook up"
property="check ItemFormTypesLo okup" name="manageKQA DocumentTO">
<% if(count==0){ %>
<bean:write name="cifTypeLo okup"/>
<% } count++; %>
</logic:iterate>
</td>
</tr>
<tr>
<td valign="middle" align="left">
<input type="radio" name="cifType2" setGroup="group 1"
value="2"/>&nbsp;&nbsp;&n bsp;&nbsp;
<% count = 0; %>
<logic:iterat e id="cifTypeLook up"
property="check ItemFormTypesLo okup" name="manageKQA DocumentTO">
<% if(count==1){ %>
<bean:write name="cifTypeLo okup"/>
<% } count++; %>
</logic:iterate>
</td>
</tr>
<tr>
<td valign="middle" align="left">
<input type="radio" name="cifType3" setGroup="group 1"
value="3"/>&nbsp;&nbsp;&n bsp;&nbsp;
<% count = 0; %>
<logic:iterat e id="cifTypeLook up"
property="check ItemFormTypesLo okup" name="manageKQA DocumentTO">
<% if(count==2){ %>
<bean:write name="cifTypeLo okup"/>
<% } count++; %>
</logic:iterate>
</td>
</tr>
</table>
</form>
</body>
<script language="javas cript">
function sbnumberCheck()
{
if(document.Man ageKQADocumentF orm.sbnumber.va lue=="")
{
alert('Please enter valid Service Bulletin number.');
}
else
{
document.Manage KQADocumentForm .action="Update KQAViewPage.do" ;
document.body.s tyle.cursor = "wait";
document.Manage KQADocumentForm .submit();
}
}
</script>
</html>

Regards
Jean-Francois Michaud

Jan 29 '07 #4
Jean-François Michaud wrote:
function disableCif()
{
document.Manage KQADocumentForm .cifType1.disab led="true";
document.Manage KQADocumentForm .cifType2.disab led="true";
document.Manage KQADocumentForm .cifType3.disab led="true";
JavaScript has boolean values true and false while "true" is a string
and not a boolean value. You should assign true and not "true"
therefore. The same for the other functions.
<body class="MainBody " onload="javascr ipt:disableCif( );">
This should work as it is called after the page has been loaded.
<scriptenableCi fType2(); </script>
This can't work as the form you are trying to script has not yet been
parsed.

<scriptenableCi fType3(); </script>
Same here.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 29 '07 #5


On Jan 29, 10:03 am, Martin Honnen <mahotr...@yaho o.dewrote:
Jean-François Michaud wrote:
function disableCif()
{
document.Manage KQADocumentForm .cifType1.disab led="true";
document.Manage KQADocumentForm .cifType2.disab led="true";
document.Manage KQADocumentForm .cifType3.disab led="true";Java Script has boolean values true and false while "true" is a string
and not a boolean value. You should assign true and not "true"
therefore. The same for the other functions.
<body class="MainBody " onload="javascr ipt:disableCif( );">This should work as it is called after the page has been loaded.
<scriptenableCi fType2(); </script>This can't work as the form you are trying to script has not yet been
parsed.
<scriptenableCi fType3(); </script>Same here.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Ahhhh!! Thats the problem then. The form hasn't been parsed yet!
Alright, I'll have to find another way of doing this then. Thanks ;-).

Regards
Jean-Francois Michaud

Jan 29 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
9719
by: Alex M | last post by:
I'm trying to use the jakarta struts client side javascript validators and the validators are working, but they are not showing the popup messages. I have the message keys defined in the ApplicationResources.properties file, the propertise file is in the right location, it is referenced from the struts-config.xml, but still no messages. For example, submitting a form that violates the required field validator, just causes it to do...
3
10263
by: sancha | last post by:
Hi, i am in a bit of a delima here. I need to submit an action through javascript so i used document.forms.action='/search.do?&submitaction=Add Minus' document.forms.submit(); since i am working on struts then submitaction maps to through the
3
5713
by: PromoteDirect | last post by:
Newsgroups: comp.lang.javascript Subject: access denied when trying to pass data between jsps Date: Thu, 09 Mar 2006 10:42:01 -0800 I have two jsp applications. One written with struts and one without. My struts based application uses window.open to open the first page of my non-struts application, the user goes through a number of screens and I then need to copy info from my non struts ap to fields of a form on my struts ap.
1
1977
by: JumpingOffPlace | last post by:
Hi, I'm hoping that the wealth of knowledge here can stop me from spinning my wheels on this syntax error for hours. :) Below is the code, and the error I am recieving.... Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="/WEB-INF/tag-lib/struts-html-el.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/tag-lib/struts-bean.tld" prefix="bean" %>
1
2786
by: nithiya sri | last post by:
i am new to struts.I try running struts application in Eclipse with the tomcat plug in .. it shows the following error:; please help me in this... SEVERE: Error loading WebappClassLoader delegate: false repositories:
1
14049
by: shrik | last post by:
hi everybody. I have following problem. There are two pages. index.jsp and main.jsp in my application Index.jsp contains logging interface in . It submits password and userid to loginform bean. following are entries in struts-config.xml file <action input="index.jsp" name="loginform" path="/login" scope="session" type="com.myapp.struts.loginaction"> <forward name="success" path="/main.jsp"/>
0
2909
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form action="/login"> <html:text property="userName" value="Bunty"/> <html:submit/>
1
11525
by: NamelessNumberheadMan | last post by:
I can't seem to get Struts 2 validations to work. I have been converting from Strust 1 to Struts 2. So far I've refactored all the code (for this particular module) on the back end, rewrote the jsp using Struts 2 notations, and wired up the xml (aside from the abc-validation.xml). Everything runs just fine. If there is an error not generated by user input (i.e. file format problem) I can get that message to come out, so I know my error messages...
12
77985
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please give me some idea where I am going wrong ?? I just want to retrieve data from my emp_mstr table and display it using my JSP file... The table emp_mstr is as follows :- CREATE TABLE EMP_MSTR( EMP_NO VARCHAR(10) PRIMARY KEY, PASSWORD...
0
8382
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8717
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.