File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes can javascript and Struts work together ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "can javascript and Struts work together ?" Watch "can javascript and Struts work together ?" New topic
Author

can javascript and Struts work together ?

alfred jones
Ranch Hand

Joined: Apr 19, 2005
Posts: 279
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
alfred jones
Ranch Hand

Joined: Apr 19, 2005
Posts: 279
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

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

Joined: Oct 27, 2003
Posts: 258
Maybe you should look at some basic struts tutorials. google gives many options on a search struts search
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can javascript and Struts work together ?