aspose file tools
The moose likes Struts and the fly likes how to use javascript in struts jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to use javascript in struts jsp" Watch "how to use javascript in struts jsp" New topic

how to use javascript in struts jsp

Nilesh Shekokar

Joined: May 02, 2006
Posts: 17
hi all,
i am using struts tags for jsp
like<html:text property="name">
i want to use the javascript for this form
in general we are using name ir id for getting the elements
but in these tags there is no name field
i found somewhere that i have to use the property for that
so can someone explain how can i use that

SCJP 5<br />SCWCD 1.4
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
When using JavaScript in a Struts application it is important to bear in mind the following:

1-Struts tags such as <html:text> are evaluated on the server-side and converted to regular HTML tags before the response is sent back to the browser.

2-A "property" attribute in an <html:xxx> tag is translated to "name" in the HTML tag that it is converted to. Also, specifying a "styleId" attribute will translate to an "id" attribute in regular HTML. For example:

<html:text property="foo" styleId="bar" />

translates to:

<input type="text" name="foo" id="bar">

3-JavaScript operates on the regular HTML tags, not on the struts tags. It's therefore important to know what the rendered HTML tags look like. To do this, use your browser's "view source" function. This will show you the actual HTML that was rendered by your struts tags.

Consultant, Sima Solutions
Consider Paul's rocket mass heater.
subject: how to use javascript in struts jsp