|
Re: cloning nodes vs. creating new() ones: msg#00074java.enhydra.xmlc
Very close. The standard XMLC way to deal with adding multiple dynamic elements to the dom goes like this... HTMLElement parentHook = xmlcObj.getElementParentHook(); HTMLElement templateRow = xmlcObj.getElementTemplateRow(); templateRow.removeAttribute("id"); Node clonedRow = null; while (businessObject.hasMoreElements()) { xmlcObj.setTextProductName(businessObject.getProductName()); clonedRow = templateRow.cloneNode(true); parentHook.appendChild(clonedRow); } parentHook.removeChild(templateRow); The above implies that the templateRow (whatever element it is, be it a <td>, <li>, <option>, etc...) contains something like <span id="ProductName">dummy data</span>. You keep on modifying data the XMLC-generated methods and clone the node. After all that, you get rid of the original template row, leaving only the nodes you inserted containing real data. Note that we remove the id attribute of the template row before doing any cloning since we don't want to have a bunch of cloned nodes with the same id. This would result in invalid HTML/XHTML. Hope that makes sense. Note how the methodology above makes heavy use of template hooks using id's. This makes the code more robust by have an absolute reference to particular elements which can be checked at compile time. Counting on getFirstChild() and such to get to nodes that you assume to be there can fail if the template designer neglects to structure things as you expect or leaves certain things out that you assumed would be there. Jake At 11:03 AM 9/15/2003 -0700, you wrote: In my HTML I have a dropdown list with one teacher option. I'm using cloneNode() to create another <option> element and calling cloneNode() on that teacher's <option> to create the text that goes <option>right here</option>. I'm using cloneNode() because I don't know how to go about creating a new object that implements HTMLOptionElement. Is the way I'm doing this how its supposed to be done, by using the w3c API, or is there a better way to instantiate new XMLC specific objects and add them to the HTMLSelectElement?
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: some bug fixes committed..., Petr Stehlik |
|---|---|
| Next by Date: | Backwards compatability, David Corbin |
| Previous by Thread: | cloning nodes vs. creating new() ones, Matthew Hixson |
| Next by Thread: | Re: cloning nodes vs. creating new() ones, Matthew Hixson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |