[OGo-Developer] OWFormElementName

Stéphane Corthésy developer@opengroupware.org
Tue, 12 Dec 2006 18:42:28 +0100


Hi,

I dug that problem deeper.
The error, committed in v1101, is in WOWrapperTemplateBuilder.m. In - 
dynamicElementWithName:attributes:contentElements:, there is a call  
[self addAttributes:_attributes toAssociations:assoc]. _attributes  
contains the element's 'name' (or 'NAME') that is in the <WEBOBJECT  
NAME=...> element, and that name is added to the associations,  
whereas it shouldn't. By commenting that line out, problem is solved.  
If there could be more key-value pairs than the 'name' one (why/how?  
Not in a .wo template, AFAIK, but probably in .wox ones), then we  
should simply remove those (name/NAME) ones from the dictionary  
passed to addAttributes:toAssociations:.

Though it is annoying to have to add an explicit 'name' attribute to  
WOElements when you need to refer to that element in javascript, for  
example, it is definitely not possible to use the
<WEBOBJECT NAME=...> value; you will have invalid HTML as soon as  
your <WEBOBJECT NAME=...> is used more than once in your page, for  
example wrapped in a WORepetition, or coming from another component.


Stéphane


On Nov 2, 2006, at 15:59, Helge Hess wrote:

> On Nov 2, 2006, at 15:42, Stéphane Corthésy wrote:
>> In our opinion the cause of the problem is that the default name  
>> returned for element names is not a unique ID anymore, but uses  
>> the element's wod given name (see code below, from WOInput.m in  
>> NGObjWeb). This should not be the case, even if it helps  
>> Javascripting.
>
> You are absolutely correct, it shouldn't be that way and it AFAIK  
> isn't ;-)
>
>> Am I missing something? Is there a way to force a unique ID  
>> without changing the code below?
>
> ---snip---
> NSString *OWFormElementName(WOInput *self, WOContext *_ctx) {
>   NSString *name;
>
>   if (self->name == nil)
>     return [_ctx elementID];
>
>   if ((name = [self->name stringValueInComponent:[_ctx  
> component]]) != nil)
>     return name;
> ---snap---
>
> This 'self->name' is/should be the 'name' binding of the form, not  
> the ID of the .wod element (which is stored in 'NAME').
>
> Eg:
> MyField: WOTextField {
>   name = "myfield";
> }
>
> self->name will be 'myfield' (WOValueAssociation), not 'MyField'.
>
>
> In fact I just tried samples/HelloForm and it outputs this:
> ---snip---
>     <form action="/WOxExtTest.woa/wo/ 
> 0147014701454A0932/001454a093208117f44.1" method="post">
>       Text: <input type="text" name="001454a093208117f44.1.1"  
> value="" /><br />
>       <input type="submit" name="001454a093208117f44.1.3"  
> value="OK" />
>     </form>
> ---snap---
>
> for this:
> ---snip---
> Form: WOForm {
>   action = self;
> }
>
> TextField: WOTextField {
>   value = item;
> }
>
> Submit: WOSubmitButton {
>   value = "OK";
> }
> ---snap---
>
> Which looks just fine?
>
>
>> P.-S.
>> This question has been posted on macosx@opengroupware.org list a  
>> few weeks ago by Marco Scheurer, but got no response. I hope I'll  
>> have more luck here.
>
> Yes, sorry. Was lost in my inbox.
>
> Greets,
>   Helge
> -- 
> Helge Hess
> http://docs.opengroupware.org/Members/helge/
>
>
> --
> OpenGroupware.org Developer
> developer@opengroupware.org
> http://mail.opengroupware.org/mailman/listinfo/developer