If you're hand-coding the Javascript, you may also be able to write
something like
document.addressForm['address.street']
or
document.addressForm.elements['address.street']
L.
Jeromy Evans wrote:
> Interesting problem...
> Using textfield as an example, the template (eg. text.ftl) takes the
> literal name attribute from and writes it straight to the
> html. You could create your own theme that replaces the '.' with a
> different character in the html. You could then write your own
> interceptor that converts the name attributes back to the syntax
> expected by the parameters interceptors before it's executed. This would
> let you use OGNL in the JSP, but give you your javascript friendly names.
>
> You'd have to check that none of the S2/dojo javascript uses names
> instead of Ids though. And this will confuse IDE syntax highlighting. Yuk...
>
> I guess it would be nicer if you could write a javascript function
> getElementByName('document.addressForm.address.street') that knows
> 'address.street' is the name of an input because document.addressForm is
> a form element. That seems do-able.
>
> Fowler, Perryn wrote:
>> Hi People,
>>
>> I usually like to access form elements using their names ( rather than ids)
>> as I find it more readable.
>> So, if I had a field named 'street' on a form named 'addressForm' I can
>> access it using something like document.addressForm.street
>>
>> Now, I am using struts 2 and its OGNL support to inject parameters directly
>> into objects contained exposed by my actions.
>>
>> So, I might have a form with a field named 'address.street'.
>> When this form is submitted the fields value is set by the parameters
>> interceptor using something like action.getAddress().setStreet()
>>
>> Unfortunately, this means that my method of accessing form fields in
>> javascript no longer works because the last period
>> in document.addressForm.address.street is not interpreted by javascript as
>> part of the name, but as the javascript de-reference operator.
>>
>>
>> does anyone know of a solution to this? Can I escape that . in javascript
>> somehow? Can I change what character OGNL uses?
>>
>> I realize I could place ids on my fields and use getElementById, but as I
>> said I would rather be able to use this syntax for readability's sake.
>>
>> cheers
>> Perryn
>>
>> "This e-mail and any attachments to it (the "Communication") is, unless
>> otherwise stated, confidential, may contain copyright material and is for
>> the use only of the intended recipient. If you receive the Communication in
>> error, please notify the sender immediately by return e-mail, delete the
>> Communication and the return e-mail, and do not read, copy, retransmit or
>> otherwise deal with it. Any views expressed in the Communication are those
>> of the individual sender only, unless expressly stated to be those of
>> Australia and New Zealand Banking Group Limited ABN 11 005 357 522, or any
>> of its related entities including ANZ National Bank Limited (together
>> "ANZ"). ANZ does not accept liability in connection with the integrity of or
>> errors in the Communication, computer virus, data corruption, interference
>> or delay arising from or in respect of the Communication."
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>>
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]