struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff_Mycha...@nlgroup.ca
Subject Re: is there a way to get struts to interact well w/ scriptlets
Date Sat, 08 Feb 2003 16:27:03 GMT

In agreement with Kris, I will elaborate.

In short I was able to avoid hard coding element names by passing in
control names.

The <nested:writeNesting/> tag will generate a string that describe the
levels without the control name and
the <nested:writeNesting property="XXX"/> will give you the full name with
control.

so in lists I found my self doing stuff like this.

//at any particular nesting level..
<td>
        <bean:define id="selectedTx" >
             selectedTx('<nested:writeNesting property="onAccountAmt" />','<nested:writeNesting
property="../amountCreditString" />')
       </bean:define>

       <nested:checkbox property="meshFlg"  onclick="<%= selectedTx %>" />
</td>

 //JS function
      function selectedTx(thisCtrl){
        var cbBox = document.customerMeshingForm.elements[thisCtrl];
        ......
      }


//it generates code kinda like this.
<input type="checkbox"
            name="meshListWrapper.meshList[0].invoiceList[4].invoiceVo.meshFlg" value="true"
           onclick="selectedTx('meshListWrapper.meshList[0].invoiceList[4].invoiceVo.meshFlg'>

This was how I got this working, but I would sure love to know others do it.


**** Since I am on the topic of merging struts with javascript....
To avoid harcoding javascript form name that is generated from the form name in the config
file
I fooled around with this..

<bean:struts mapping="/crApplicationRouter"  id="mapping" />

 function setDataChanged(){
        document.<bean:write name="mapping" property="name"/>.dataChanged.value = '<%=
WebConstants.TRUE %>';
      }

To be fair I don;t actually do this because my form names do really change all that often.

hope some of this helps...




Sundar Narasimhan <sundar@ascent.com> on 02/08/2003 09:45:23 AM

Please respond to "Struts Users Mailing List"
       <struts-user@jakarta.apache.org>

To:    struts-user@jakarta.apache.org
cc:

Subject:    is there a way to get struts to interact well w/ scriptlets



I notice that if I use <nest:> I end up getting input fields whose
name looks like so
     <input name="foo.bar">

This really doesn't play well with all the java script code we have
that rely on "eval'ing" target names such as
"window.document.someform.somelement".
If someelement is in dotted notation, eval on the java script side
tries to traverse it and throws errors.

Obviously I like the serverside traversals that nest gives you, but
I'm wondering how I can solve this problem.

Any ideas will be much appreciated. And please, no suggestions for
"avoid java script" because I have to use user interface elements like
calendars and spin controls etc. that I need on the client side :)

Basically I'm looking for what the struts sanctioned way of doing this
is..

Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org








---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message