|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Myfaces 2.0 javascript javax.faces.viewRoot response need some feedback from othersOk after digging around for hours regarding something within the
javascript part of the specification I want to discuss things. Following problem: we have within the limits of the specification following things: javax.faces.ViewRoot should replace an entire content tree javax.faces.Head should replace the head javax.faces.Body should replace the body how this is done is thankfully up to the implementation. so far for the ViewRoot case we used document.documentElement.innerHTML = "markup" problem with this approach is simply it does not work out satisfying, in fact it only works on mozilla sufficiently. Webkit is very nitpicky regarding several things. Here is the problem. do it with <head><meta ...> and it will fail do it with <body> and it will fail generally document.documentElement.innerHTML = "<head></head><body style='font-weight: bold; font-size: 20px;'>aaa </body>"; will result in following document on webkits side: <html ...> aaa </html> The head and body tags dissapear. Further investigations revealed. Generally Webkit under xhtml and transitional does not allow to replace the head contents, it neither does allow to replace the body tag, only the body contents can be replaced and should be via range and createContextualFragment mechanisms, also etc... is not allowed anymore (seems like an enforced strict here) innerHTML is alos mostly forbidden or it should not be used anymore and it definitely fails at the datatype xhtml+xml (which is supposed to work that way according to the spec) Anyway what does this mean, we cannot support head replacement and full body replacement on some browsers unless someone knows a workaround to all this. All we can do is safely support what the browsers allow or go for the least common denominator which is replace the body tags contents! No matter what comes in! I have yet to test all this on IE but I assme we run here into similar problems! |
|
|
Re: Myfaces 2.0 javascript javax.faces.viewRoot response need some feedback from othersWerner Punz schrieb:
> I have yet to test all this on IE but I assme we run here into similar > problems! > > Jepp similar picture on IE... As it seems for now we can only replace the body contents safely in xhtml environments, not the tags and not the heads, however replacing the heads is pointless anyway! Werner |
|
|
Re: Myfaces 2.0 javascript javax.faces.viewRoot response need some feedback from othersOn Thu, Jun 25, 2009 at 9:35 AM, Werner Punz<werner.punz@...> wrote:
> Werner Punz schrieb: > >> I have yet to test all this on IE but I assme we run here into similar >> problems! >> >> > Jepp similar picture on IE... > > As it seems for now we can only replace the body contents safely > in xhtml environments, not the tags and not the heads, however > replacing the heads is pointless anyway! > > Werner > > Werner, Forgive me if I'm missing some important details, but why even use innerHTML in the first place? It should be possible to parse the incoming text into a DOM node (there's some JS function for it, I can't remember which), then import that node as a sibling of the <body> element (for example) and delete the first <body> element. Wouldn't that work? Curtiss Howard |
|
|
Re: Myfaces 2.0 javascript javax.faces.viewRoot response need some feedback from othersCurtiss Howard schrieb:
> Forgive me if I'm missing some important details, but why even use > innerHTML in the first place? It should be possible to parse the > incoming text into a DOM node (there's some JS function for it, I > can't remember which), then import that node as a sibling of the > <body> element (for example) and delete the first <body> element. > Wouldn't that work? It was one of my testcases to do that since I shun innerHTML (we dont do it anyway normally) Does not work either on safari... You can do dom manipulation on the contents of the body element but you cannot delete the body element in most browsers under xhtml conditions as it seems! |
|
|
Re: Myfaces 2.0 javascript javax.faces.viewRoot response need some feedback from othersWerner Punz schrieb:
> Curtiss Howard schrieb: > >> Forgive me if I'm missing some important details, but why even use >> innerHTML in the first place? It should be possible to parse the >> incoming text into a DOM node (there's some JS function for it, I >> can't remember which), then import that node as a sibling of the >> <body> element (for example) and delete the first <body> element. >> Wouldn't that work? > It was one of my testcases to do that since I shun innerHTML (we dont do > it anyway normally) > Does not work either on safari... > You can do dom manipulation on the contents of the body element but you > cannot delete the body element in most browsers under xhtml conditions > as it seems! > > the body element, after all, which means I only have to parse that one and replace it in case of getting a viewRoot. The problem still persists that we cannot properly deal with the head. As it seems we have to change our code simply to replace only the body in any case... Werner |
|
|
Re: Myfaces 2.0 javascript javax.faces.viewRoot response need some feedback from othersWerner Punz schrieb:
> Curtiss Howard schrieb: > >> Forgive me if I'm missing some important details, but why even use >> innerHTML in the first place? It should be possible to parse the >> incoming text into a DOM node (there's some JS function for it, I >> can't remember which), then import that node as a sibling of the >> <body> element (for example) and delete the first <body> element. >> Wouldn't that work? > It was one of my testcases to do that since I shun innerHTML (we dont do > it anyway normally) > Does not work either on safari... > You can do dom manipulation on the contents of the body element but you > cannot delete the body element in most browsers under xhtml conditions > as it seems! > > What does work is document createElement("body") and then set that one one way or the other. What is problematic as it seems is to use the range functionality to achieve the same by a contextual fragment which should replace the body, this does not work in some cases, but would be the cleaner solution for non ie cases! (having the browser parse the entire tag including its attributes) I will do some final testing regarding this, but as it seems, I have to parse the body tag attributes from the string coming from the server and have it assigned programatically in any case. It was probably a little bit to early to send first mail regarding this problem ;-) Anyway one way or the other I want to have embedded body tag attributes assigned if they come from the server! Btw. the last time which has been months ago mojarra had in this part absolutely broken code. They used regular expressions which failed in many cases (like tags embedded into comments etc...) and they simply ignored any tag attributes, they just created a body tag and then pushed the content in via innerHTML also ignoring embedded scripts (which they seem to ignore entirely) not sure if they have changed that! Hazem pointed them I think towards not doing anything about embedded scripts I am not sure if they have fixed it already. This might become a problem for ajax libraries unless they add the script parsing needed via listeners! Werner |
|
|
Re: Myfaces 2.0 javascript javax.faces.viewRoot response need some feedback from othersWerner Punz schrieb:
> Werner Punz schrieb: >> Curtiss Howard schrieb: >> >>> Forgive me if I'm missing some important details, but why even use >>> innerHTML in the first place? It should be possible to parse the >>> incoming text into a DOM node (there's some JS function for it, I >>> can't remember which), then import that node as a sibling of the >>> <body> element (for example) and delete the first <body> element. >>> Wouldn't that work? >> It was one of my testcases to do that since I shun innerHTML (we dont >> do it anyway normally) >> Does not work either on safari... >> You can do dom manipulation on the contents of the body element but >> you cannot delete the body element in most browsers under xhtml >> conditions as it seems! >> >> > Ah ok mea culpa, again a message. > What does work is document createElement("body") and then set that one > one way or the other. > > What is problematic as it seems is to use the range functionality to > achieve the same by a contextual fragment which should replace the body, > this does not work in some cases, but would be the cleaner solution for > non ie cases! > (having the browser parse the entire tag including its attributes) > > > I will do some final testing regarding this, but as it seems, I have to > parse the body tag attributes from the string coming from the server and > have it assigned programatically in any case. > > It was probably a little bit to early to send first mail regarding this > problem ;-) > > Anyway one way or the other I want to have embedded body tag attributes > assigned if they come from the server! > > Btw. the last time which has been months ago mojarra had in this part > absolutely broken code. They used regular expressions which failed in > many cases (like tags embedded into comments etc...) > and they simply ignored any tag attributes, they just created a body tag > and then pushed the content in via innerHTML also ignoring embedded > scripts (which they seem to ignore entirely) > > not sure if they have changed that! Hazem pointed them I think towards > not doing anything about embedded scripts I am not sure if they have > fixed it already. This might become a problem for ajax libraries unless > they add the script parsing needed via listeners! > > head element does not work out on some browsers, it probably is better to skip this entirely, body replacement this works out somewhat differently we cannot use our replacement code directly on the body, this does not work in any browser (firefox drops the body element directly while others fail with an error in this case), instead we have to work around that by a) creating a body element via document.createElement b) adding a placeHolder div as dummy child c) assign the defakto empty body via replaceElement d) then use our replacement code as is on the dummy child and the new body content e) then assign all pending attributes from the old body to our new one to preserver styleClasses and styles! I have this one now working via a new parsing code which also parses the attributes from the tag which has to be parsed and will commit it the next days! I am not sure if we have to deal in similar manners with the special cases of head and body being sent as own entities in javax.faces.head and javax.faces.body,I have to what data we get in those cases from the server, but I assume the head or body tags... Werner |
| Free embeddable forum powered by Nabble | Forum Help |