File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can javascript and Struts work together ?

 
alfred jones
Ranch Hand
Posts: 279
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can javascript and Struts work together ?

in html

<input type=text size=20 name=address>

javascript works this way..

document.personal.address="someValue";




Now, how do i use javascript in Struts ?

<html:text property="firstname"/>

How do i set the value of first name using javascript now ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33671
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alfred,
Yes, Javascript and Struts work together well.

document.personal.address="someValue";

If you know the value at the time you paint the page, you can do:
<html:text property="firstname" value="someValue" />

If not, you can do:
document.formName.firstname="someValue";

The form name is whatever you defined in the Struts config. You can also find this by looking at the rendered HTML page.
 
alfred jones
Ranch Hand
Posts: 279
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ummm...i am confused.

in html we have

<input type=text size=20 name=address> ... "name" field, so javascript works fine.


but in Struts there is no "name" fields rather there is "property" field! , so how javascript will work now ? because javascript works when there is "name" field only.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33671
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alfred,
Struts converts the property field into an HTML name field. You can verify this by doing a "view source" in your browser on a page created by Struts.
 
Pranav Sharma
Ranch Hand
Posts: 258
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you should look at some basic struts tutorials. google gives many options on a search struts search
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic