Chaitanya Jeerage wrote: > Thanks Andy. > > Adding the "ensureUniqueNamesInLoops" parameter to the AjaxForm would > be a nice solution, though IMHO the default should be "true". > i just don't want to break other people's stuff - assuming someone is using or hardcoding the generated name :)
Perhaps a global configuration point is better. It could apply to all AjaxForms so you'll only need to set it to true once. > is there any other way to ensure the names are unique, other than > using the IdPath ? (to avoid the huge names) > Actually, one of my ideas has always been to implement a compressing IdAllocator http://svn.apache.org/viewvc/tapestry/tapestry4/branches/4.0/framework/src/java/org/apache/tapestry/util/IdAllocator.java?view=markup Generated ids and names originate from a call to IdAllocator.allocateId If anyone has the time and can come up with a nice implementation, i'd be happy to have tacos use it. BTW, tacos trunk has a nice ajax url encoder which compresses url to half of their normal size. > -Chaitanya > > On 9/18/06, andyhot <[EMAIL PROTECTED]> wrote: > >> Ok, here's some code... First, the custom component: >> https://svn.sourceforge.net/svnroot/tacos/tacos-4.0/trunk/demo/docroot/WEB-INF/bugs/components/CustomTextField.html >> notice that you *have* to use id="ognl:components.ctf.idPath" to make it >> unique. >> >> Next, the page that uses it: >> https://svn.sourceforge.net/svnroot/tacos/tacos-4.0/trunk/demo/docroot/WEB-INF/bugs/BugTry004.html >> https://svn.sourceforge.net/svnroot/tacos/tacos-4.0/trunk/demo/src/net/sf/tacos/demo/pages/bugs/BugTry004.java >> >> It's a full working example, doing exactly what you describe. >> >> Well, running it produces the issue with the names that you describe. >> Names are ctf, ctf_0 (for the phones) and ctf_1, ctf_2 (for the emails) >> and when a new phone is added they become ctf, ctf_0,ctf_1(for the >> phones) while emails are left untouched (ctf_1, ctf_2) >> >> There are workarounds (like refreshing the complete form, or other parts >> that we know are affected by the current change) but if we could >> have really unique names (as we do for ids, using the idPath) it would >> be even better. >> >> The answer is in AjaxForm's getElementId(IFormComponent) >> https://svn.sourceforge.net/svnroot/tacos/tacos-4.0/trunk/src/java/net/sf/tacos/ajax/components/AjaxForm.java >> Making it >> return formSupport.getElementId(component, component.getIdPath()); >> instead of >> return formSupport.getElementId(component, component.getId()); does the >> trick. >> >> Names are now: bugs_components_CustomTextField.ctf, >> bugs_components_CustomTextField.ctf_0 and >> bugs_components_CustomTextField_0.ctf, >> bugs_components_CustomTextField_0.ctf_0 >> >> Ofcourse, I don't like the huge names, so I'm considering adding a >> parameter to AjaxForm for this, >> something like ensureUniqueNamesInLoops, defaulting to false. >> >> Any thoughts? >> >> >> Chaitanya Jeerage wrote: >> >>> Let me try to rephrase, we have two instances of the same custom >>> component in the page, Initially when the page is rendered we have one >>> TextField in each instance of the component (Telephone and email) . >>> Tapestry assigns a name for each of the TextField, say TextField_0 and >>> TextField_1. >>> >>> Now on addition of new telephone (through ajaxEventSubmit) only the >>> telephone component is updated (as required), we have two TextFields >>> in telephone and one in email (Note email component was not updated). >>> >>> For the newly added TextField Tapestry assigns the name "TextField_1" >>> , the name is same as the TextField in email. >>> >>> On form submission, because of two fields having the same name >>> "TextField_1" the data is getting mixed up. >>> >>> -Chaitanya >>> >>> On 9/14/06, andyhot <[EMAIL PROTECTED]> wrote: >>> >>> >>>> B.S.Navin wrote: >>>> >>>> >>>>> Looking at the original post, it looks like the person wants a unique >>>>> "name" attribute. >>>>> >>>>> >>>>> >>>> errr... i thought he couldn't refresh the specific part... my mistake >>>> >>>> >>>>> But Andy's solution will provide a unique "id" attribute. (As "name" >>>>> is a reserved parameter in TextField, and is calculated using the >>>>> components original ID - not the bound id). >>>>> >>>>> So I feel that, even though the ID is unique, the name still can >>>>> conflict and result in the the data being clobbered - as HTML form >>>>> submission uses the "name" attribute, rather than the "id" attribute. >>>>> >>>>> >>>>> >>>> Even if that's the case, why is it problematic to have controls with the >>>> same name? >>>> I believe Tapestry handles them correctly >>>> >>>> >>>>> On 14-Sep-06, at 11:48 AM, andyhot wrote: >>>>> >>>>> >>>>> >>>>> >>>>>> Here's a trick that some tacos components use to get past this issue. >>>>>> >>>>>> in your CustomField.jwc >>>>>> >>>>>> <component id="myTextField" type="TextField" inherit-informal- >>>>>> parameters="yes"> >>>>>> <binding name="id" value="components.myTextField.idPath"/> >>>>>> <binding name="name" value="name"/> >>>>>> </component> >>>>>> >>>>>> >>>>>> ognl:components.tableSection.idPath >>>>>> >>>>>> Chaitanya Jeerage wrote: >>>>>> >>>>>> >>>>>> >>>>>>> Issue: Data *wrongly* getting updated due to Tapestry/Tacos handling >>>>>>> of Textfield Name convention when it is embedded within a custom >>>>>>> component. >>>>>>> >>>>>>> When we use a Custom component which has a Text Field in it, we can >>>>>>> end up with two TextFields with the **SAME NAME** after an >>>>>>> AjaxEventSubmit call. >>>>>>> >>>>>>> So let's say we have: >>>>>>> >>>>>>> <span jwcid="[EMAIL PROTECTED]" source="ognl:telephones" >>>>>>> value="ognl:currentTelephone"> >>>>>>> <input jwcid="[EMAIL PROTECTED]:customField" >>>>>>> value="ognl:currentTelephone.number"/> >>>>>>> </span> >>>>>>> >>>>>>> <span jwcid="[EMAIL PROTECTED]" source="ognl:emails" >>>>>>> value="ognl:currentTelephone"> >>>>>>> <input jwcid="[EMAIL PROTECTED]:customField" >>>>>>> value="ognl:currentEmail.email"/> >>>>>>> </span> >>>>>>> >>>>>>> The "customField" component has a embedded "TextField" >>>>>>> >>>>>>> The custom component looks like this: >>>>>>> >>>>>>> CustomField.jwc partial code >>>>>>> >>>>>>> <component id="TextField" type="TextField" >>>>>>> inherit-informal-parameters="yes"> >>>>>>> <binding name="id" value="id"/> >>>>>>> <binding name="name" value="name"/> >>>>>>> </component> >>>>>>> >>>>>>> >>>>>>> So when the Page is initially rendered, the TextFields come with >>>>>>> Names >>>>>>> as "TextField_0", "TextField_1" etc. NOTE however that there is no >>>>>>> distinguishing by naming convention which TextField "belongs" to >>>>>>> which >>>>>>> component, via naming convention. The reason for TextField_0 seems >>>>>>> to be because of the JWCID in the CustomField.jwc >>>>>>> >>>>>>> Now when we have an Ajax call to add a Telephone number to the >>>>>>> Telephone List the clash occurs! Since add to the Telephone list >>>>>>> creates a new TextField_xx, it clashes with the Emails because we're >>>>>>> doing a partial refresh of the Telephone List portion using Ajax. >>>>>>> >>>>>>> On form submit we can get some Telephone data into Email fields!! >>>>>>> >>>>>>> However, in the same scenario, if we directly use a "TextField" >>>>>>> instead of the custom component, for ex >>>>>>> >>>>>>> <span jwcid="[EMAIL PROTECTED]" source="ognl:telephones" >>>>>>> value="ognl:currentTelephone"> >>>>>>> <input jwcid="[EMAIL PROTECTED]" >>>>>>> value="ognl:currentTelephone.number"/> >>>>>>> </span> >>>>>>> >>>>>>> on addition of rows to the "telephones" list, new input text fields >>>>>>> are added to the screen and the name generated are like "tele", >>>>>>> "tele_0", "tele_1" , Note, here it is using the jwcid value and so >>>>>>> works fine!! >>>>>>> >>>>>>> If TextField could "inherit" it's name from its enclosing component, >>>>>>> we would not have any issues!! >>>>>>> >>>>>>> Any pointers please?! >>>>>>> >>>>>>> thanks >>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>>> ---- >>>>>>> Using Tomcat but need to do more? Need to support web services, >>>>>>> security? >>>>>>> Get stuff done quickly with pre-integrated technology to make your >>>>>>> job easier >>>>>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache >>>>>>> Geronimo >>>>>>> http://sel.as-us.falkag.net/sel? >>>>>>> cmd=lnk&kid=120709&bid=263057&dat=121642 >>>>>>> _______________________________________________ >>>>>>> Tacos-devel mailing list >>>>>>> [email protected] >>>>>>> https://lists.sourceforge.net/lists/listinfo/tacos-devel >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> -- >>>>>> Andreas Andreou - [EMAIL PROTECTED] - http://andyhot.di.uoa.gr >>>>>> Tapestry / Tacos developer >>>>>> Open Source / J2EE Consulting >>>>>> >>>>>> >>>>>> ---------------------------------------------------------------------- >>>>>> --- >>>>>> Using Tomcat but need to do more? Need to support web services, >>>>>> security? >>>>>> Get stuff done quickly with pre-integrated technology to make your >>>>>> job easier >>>>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache >>>>>> Geronimo >>>>>> http://sel.as-us.falkag.net/sel? >>>>>> cmd=lnk&kid=120709&bid=263057&dat=121642 >>>>>> _______________________________________________ >>>>>> Tacos-devel mailing list >>>>>> [email protected] >>>>>> https://lists.sourceforge.net/lists/listinfo/tacos-devel >>>>>> >>>>>> >>>>>> >>>>>> >>>>> ------------------------------------------------------------------------- >>>>> Using Tomcat but need to do more? Need to support web services, security? >>>>> Get stuff done quickly with pre-integrated technology to make your job >>>>> easier >>>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>>>> _______________________________________________ >>>>> Tacos-devel mailing list >>>>> [email protected] >>>>> https://lists.sourceforge.net/lists/listinfo/tacos-devel >>>>> >>>>> >>>>> >>>>> >>>> -- >>>> Andreas Andreou - [EMAIL PROTECTED] - http://andyhot.di.uoa.gr >>>> Tapestry / Tacos developer >>>> Open Source / J2EE Consulting >>>> >>>> >>>> ------------------------------------------------------------------------- >>>> Using Tomcat but need to do more? Need to support web services, security? >>>> Get stuff done quickly with pre-integrated technology to make your job >>>> easier >>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>>> _______________________________________________ >>>> Tacos-devel mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/tacos-devel >>>> >>>> >>>> >>> ------------------------------------------------------------------------- >>> Using Tomcat but need to do more? Need to support web services, security? >>> Get stuff done quickly with pre-integrated technology to make your job >>> easier >>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>> _______________________________________________ >>> Tacos-devel mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/tacos-devel >>> >>> >>> >> -- >> Andreas Andreou - [EMAIL PROTECTED] - http://andyhot.di.uoa.gr >> Tapestry / Tacos developer >> Open Source / J2EE Consulting >> >> >> ------------------------------------------------------------------------- >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Tacos-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/tacos-devel >> >> > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Tacos-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/tacos-devel > > -- Andreas Andreou - [EMAIL PROTECTED] - http://andyhot.di.uoa.gr Tapestry / Tacos developer Open Source / J2EE Consulting ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Tacos-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tacos-devel
