myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "l.penet@senat.fr" <l.pe...@senat.fr>
Subject Re: java.lang.IllegalStateException: Must be called before the start element is closed (attribute 'id')
Date Tue, 17 Nov 2015 12:11:18 GMT
On 17/11/2015 01:21, Howard W. Smith, Jr. wrote:
> On Mon, Nov 16, 2015 at 2:59 PM, l.penet@senat.fr <l.penet@senat.fr> wrote:
>
>>   java.lang.IllegalStateException: Must be called before the start element
>> is closed (attribute 'id')
>>          at
>> org.apache.myfaces.shared.renderkit.html.HtmlResponseWriterImpl.writeAttribute(HtmlResponseWriterImpl.java:816)
>>
> Searched google and found the following:
>
> http://myfaces.apache.org/shared11/myfaces-shared-core/xref/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.html#318
>
> Maybe, you can start there. Seems as though you id="..." on one of your
> components may need to be fixed.
Thanks for the suggestion, but it is alas not that simple.

As far as I understand...
In response to an AJAX request, 
PartialViewContextImpl#processPartialRendering is called.

Lines 468 and following is :

             String currentEncoding = writer.getCharacterEncoding();
             writer.writePreamble("<?xml version=\"1.0\" encoding=\""+
                 (currentEncoding == null ? "UTF-8" : currentEncoding) 
+"\"?>");
             writer.startDocument();

             writer.writeAttribute("id", 
viewRoot.getContainerClientId(_facesContext),"id");

The exception is triggered when the attribute is set. An element is 
opened (and, as far as I understand, not closed) by writer.startDocument();

If ones goes up in the stack, and take a look at 
org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1891)

https://myfaces.apache.org/core22/myfaces-impl/xref/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.html#1891

, one can read
lots of comments which makes me think that things are not simple and 
that there might be side effects in some complex cases.


I see that I forgot to indicate the versions I am using...

PrimeFaces 5.3.1
MyFaces 2.2.8
OpenWebBeans 1.6.2

All this running on Tomcat 8.0.22 (in dev) or 8.0.28 (in prod).

Ludovic

|
| AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
|


Mime
View raw message