[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

struts bean tag with javascript.

Posted on 2005-05-03
14
Medium Priority
?
1,393 Views
Last Modified: 2008-03-17
Hi ,

 I am using html:button onclick="javascript:editCitizen('<bean:write name="issueVO" property="citizen.id"/>')" value="Edit Citizen"

 to pass the value of id variable in citizen object (which is a variable in issueVO).

 The compiler complains that it is expecting an "equal symbol" !!!

 Where does it require that ???

  And When i use

             <a href="javascript:editCitizen('<bean:write name="issueVO" property="citizen.id"/>')">Edit Citizen</a>

It works....

explanation please !!

javascript function is as follows :

function editCitizen(id)
      {
      
            var theForm = document.citizenForm;
            theForm.id.value = id;
            theForm.submit();
      
      }
0
Comment
Question by:letsbedecent
  • 6
  • 3
  • 3
  • +1
14 Comments
 
LVL 92

Expert Comment

by:objects
ID: 13922615
try:

<a href="javascript:editCitizen('<bean:write name=\"issueVO\" property=\"citizen.id\"/>')">Edit Citizen</a>
0
 

Author Comment

by:letsbedecent
ID: 13922981
you got it wrong..... the  
<a href="javascript:editCitizen('<bean:write name="issueVO" property="citizen.id"/>')">Edit Citizen</a>
WORKS FINE.

Its the button part thats not working !!
0
 
LVL 92

Expert Comment

by:objects
ID: 13923002
sorry, misread your q
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:suprapto45
ID: 13923138
Hi,

Can you post your entire <html:button .... /> ?

Regards
Dave
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13923147
Hi,

As it is compiler problem, it means that your JavaScript is okay. The only problem is on your JSP.

Regards
Dave
0
 

Author Comment

by:letsbedecent
ID: 13923151
<html:button onclick="javascript:editCitizen('<bean:write name="issueVO" property="citizen.id"/>')" value="Edit Citizen"\>
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13923162
Hi,

<html:button onclick="javascript:editCitizen('<bean:write name="issueVO" property="citizen.id"/>')" value="Edit Citizen"\>

should be

<html:button onclick="javascript:editCitizen('<bean:write name="issueVO" property="citizen.id"/>')" value="Edit Citizen" />

is it a typo or not :) ?

Regards
Dave
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13923166
Did you try:
<html:button onclick="javascript:editCitizen('<bean:write name=\"issueVO\" property=\"citizen.id\"/>')"  ..
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13923203
Mmm...aozarov,

Just curious, what is the difference between
<bean:write name=\"issueVO\" property=\"citizen.id\"/>
and
<bean:write name="issueVO" property="citizen.id"/>

I just never use it before and I hope you don't mind to answer :).

Regards
Dave
0
 
LVL 92

Expert Comment

by:objects
ID: 13923221
> The compiler complains that it is expecting an "equal symbol" !!!

Can u post the complete error details
0
 
LVL 15

Assisted Solution

by:aozarov
aozarov earned 1000 total points
ID: 13923226
The problem might be (I am not sure about that) because this entry <bean:write name="issueVO" property="citizen.id"/>
is inside another JSP tag attribute html:button onclick="... " (it is not plain html attribute).
0
 
LVL 16

Accepted Solution

by:
suprapto45 earned 1000 total points
ID: 13923237
Hi,

aozarov might be true. I was having a problem too when I was dealing with checkbox. I have to use plain HTML to integrate with Struts tag.

Just try aozarov's suggestion to use plain HTML.

<input type="button" onClick="<bean:write name="issueVO" property="citizen.id"/>" >

Right?

Regards
Dave
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13923242
>>Just try aozarov's suggestion to use plain HTML.
That should work, but it wasn't my suggestion :-)
I suggested to escape the inners quotes.
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13923268
Then...

>>"That should work, but it wasn't my suggestion :-)"
Please try my suggestion hahaha :). This forum is fun :).

Regards
Dave
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month20 days, 11 hours left to enroll

865 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