eclipse-ee4j / mojarra-jsf-extensions

Other
1 stars 3 forks source link

fireAjaxTransaction : multi-DOM node components are replaced by only the first node (workaround available) #74

Open glassfishrobot opened 17 years ago

glassfishrobot commented 17 years ago

Components that render as multiple dom nodes (e.g. more that one element, leading spaces/text, etc.) do not get replaced properly.

For example, trying to replace the first link in a form replaces the link with "\n\n" (since the link rendered as "<script.../script>\n\n<a href=..." and the script element is stripped out).

Workaround/Patch (also contains workaround for issue 69):

DynaFaces.fireAjaxTransaction( component, { ... replaceElement: safeReplace } );

function safeReplace(id,markup) { var str = markup.stripScripts(); if( str.strip().length !== 0 ) { if (-1 === id.indexOf(DynaFaces.gViewRoot)) { var d = DynaFaces.$(id); if(!d)

{ alert('Could not find '+id); }

var parent = d.parentNode; var temp = document.createElement("div"); temp.id = d.id; temp.innerHTML = str;

// replace the element with all of temp's children // (might be extra text nodes or something) var last = parent.replaceChild(temp.lastChild, d); for(var i = 1; i < temp.childNodes.length; i++)

{ parent.insertBefore( temp.childNodes[i], last ); }

} else

{ DynaFaces.replace(id,str); }

} }

Environment

Operating System: All Platform: All

Affected Versions

[current]

glassfishrobot commented 5 years ago
glassfishrobot commented 17 years ago

@glassfishrobot Commented Reported by iamnoah

glassfishrobot commented 17 years ago

@glassfishrobot Commented Was assigned to jsf-extensions-issues

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JSF_EXTENSIONS-74