You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Je...@nlgroup.ca on 2002/03/25 23:24:29 UTC

Struts and Client Side JavaScript Design Question


Greetings.
     We are in the early planning stages of a rather large Java/jsp application
that if I have my way will use struts.  There will be a requirement for some
"convenience"  features that will need to be in javascript.   I understand the
pros's and con's of javascript and this will for the most part be for internal
users.

Where possible, I look forward to using the validator  and  I like the way that
it 'manages' the validation library.
There will be many other functions such as auto population of controls from
other events and some simple column math and so on.

In the past I read several articles on managing javascript from the server side.
Other than storing all of it in a bunch of *.js files, can anyone share any
experience they have had where they have been forced to maintain a large amount
of javascript in a Struts application.

Thanks everyone



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts and Client Side JavaScript Design Question

Posted by Ted Husted <hu...@apache.org>.
Managing JavaScripts in a Struts application is not much different than
managing it any Java application, so everything you've already read
should apply. 

One trick is to use the html:rewrite tag to resolve the address to
JavaScripts and other HTML assets, so that the path does not have to be
embedded in the markup. You can also use it to set the base hyperlink
for passing values to a script

<SCRIPT>
<!--
function doScript(aScript) {
  aBase = '<html:rewrite forward="itemPreview"/>';
  HC_doOpenRemote(aBase + '?item=' +
aScript,'preview','*','600','scrollbars','form');
}
// -->
</SCRIPT>

and of course bean:write can help you buld runtime referneces 

<a href='javascript:doScript(<bean:write name="row"
property="item"/>)'><bean:write name="row" property="item"/></a>

I believe you can also use actions to create dynamic JavaScripts. So
instead of storing the *.js file on the server, you could have it
returned by an Action. 

Of course, JSP tags can also write dynamic scripts into the file, as the
Struts Validator does. 

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


Jeff_Mychasiw@nlgroup.ca wrote:
> 
> Greetings.
>      We are in the early planning stages of a rather large Java/jsp application
> that if I have my way will use struts.  There will be a requirement for some
> "convenience"  features that will need to be in javascript.   I understand the
> pros's and con's of javascript and this will for the most part be for internal
> users.
> 
> Where possible, I look forward to using the validator  and  I like the way that
> it 'manages' the validation library.
> There will be many other functions such as auto population of controls from
> other events and some simple column math and so on.
> 
> In the past I read several articles on managing javascript from the server side.
> Other than storing all of it in a bunch of *.js files, can anyone share any
> experience they have had where they have been forced to maintain a large amount
> of javascript in a Struts application.
> 
> Thanks everyone
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>