0

I have a composite control as below;

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:h="http://java.sun.com/jsf/html">

<composite:interface>
    <composite:attribute name="validatorId"/>
    <composite:attribute name="message"/>        
</composite:interface>

<composite:implementation>
    <div>                   
        <script type="text/javascript">
             function #{cc.attrs.validatorId}(){alert('why is it not working :(');};
        </script>                                
        <div style="background-color: #F2DEDE;color: #b94a48;border-style: solid;border-color: #FAC3CB;border-width: 1.8px;font-family: Arial;
              font-size: 12px;height:17px;vertical-align: middle;padding-left: 8px;padding-right: 8px;padding-top: 2px;display: none;"
              id="#{cc.attrs.validatorId}">
            #{cc.attrs.message}
            <img src="images/close-mini.png" style="cursor: pointer;padding-left: 5px;"/>            
        </div>
    </div>
</composite:implementation> </html>

This control is placed in a xhtml file.The javascript and composite controls are rendering as the expected way. But when a request is made to xhtml following exception occurs at Glassfish Server :

java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been committed.

What can be the reason? When I remove the javascript function exception doesn't occurs.

Lee Daniel Crocker
  • 12,927
  • 3
  • 29
  • 55
Vivek Mohan
  • 8,078
  • 8
  • 31
  • 49
  • Can you include whole stacktrace? – Bhesh Gurung Jun 11 '13 at 18:27
  • 1
    Duplicate of http://stackoverflow.com/search?q=Cannot+create+a+session+after+the+response+has+been+committed. That it happened when you added JS code is pure coincidence. It would also happen when you add the same amount of bytes of plain HTML or even plain text. – BalusC Jun 11 '13 at 19:00

1 Answers1

0

The following prerender listener is added at composite control,

<f:event type="preRenderView" listener="#{fieldValidatorBean.PreRenderValidator}"/>

and inside the listener function,

 public void PreRenderValidator(){
     FacesContext.getCurrentInstance().getExternalContext().getSession(true);
     System.out.println("prerender being called");
}

to reenable session. Thanks @BalusC.

Vivek Mohan
  • 8,078
  • 8
  • 31
  • 49