3 Replies Latest reply on Aug 25, 2008 5:52 PM by sarahkarvenz

    Ajax error when richFaces tabPanel includes a page fragment

    sarahkarvenz

      Our jsp page looks like this:

      <rich:tabPanel binding="#{allTabs.tbsMain}" id="tbsMain" switchType="client">
      <rich:tab binding="#{allTabs.tab1}" id="tab1" label="Tab 1">
      <c:import url="./common/tab1.jspf"/>
      </rich:tab>
      <rich:tab binding="#{allTabs.tab2}" id="tab2" label="Tab 2" >
      <c:import url="./common/tab2.jspf"/>
      </rich:tab>
      </rich:tabPanel>

      Our import pages for testing are completely blank and look like this:
      <div xmlns:f="http://java.sun.com/jsf/core" >

      <f:subview id="tab1">
      </f:subview>


      When I change the switchType to ajax, I get the following XML parsing error on the page:
      error[13:41:03,370]: Error parsing XML
      error[13:41:03,371]: Parse Error: XML Parsing Error: xml declaration not at start of external entity Location: http://localhost:8080/Main.jsf Line Number 40, Column 443: .....

      The same error occurs if we try to reRender the tabpanel from any other ajax request on the page (no error occurs if the entire page is submitted). If we change the c:import to a jsp:include, we also get the same error. If we remove the import statement altogether, we don't get an error.

      We are trying to do several things by using page fragments in the tab and so we can not just throw all the components inside of the tabpanel instead of including them using a page fragment.

      Any suggstions/solutions?

        • 1. Re: Ajax error when richFaces tabPanel includes a page fragm
          nbelaevski

          Hello,

          That may happen if output of jspf file starts with

          <?xml ...
          or
          <!DOCTYPE...
          Can you please post complete HTML page source (use "view source" in browser)?

          • 2. Re: Ajax error when richFaces tabPanel includes a page fragm
            sarahkarvenz

            It looks like an <?xml version="1.0" encoding="UTF-8"?> gets put in there on the c:import. However, that line (automatically puts it at the top of a newly created fragment) has been removed from my fragments to that they look like this:

            <div xmlns:f="http://java.sun.com/jsf/core" >
            <f:subview id="tab2">
            This is tab 2.
            </f:subview>


            No trailing or starting spaces or line breaks either.

            Any idea on how I can stop it from adding in that extra xml declaration?


            Thanks,
            Sarah


            Viewsource for page with imported fragments:

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wairole="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#" xmlns:waistate="http://www.w3.org/2005/07/aaa">

            var webui_suntheme4_2={"webuiJsfx":false,"webuiAll":false,"theme":{"locale":"en-us"},"ajax":{"isJsfx":true},"isDebug":false,"isStyleSheet":true,"parseOnLoad":true};

            <?xml version="1.0" encoding="UTF-8"?>
            RichFaces.tabPanel['form1:allTabs:tbsMain']={'id':'form1:allTabs:tbsMain','ontabchange':''} ;<!--table border="0" cellpadding="0" cellspacing="0" style="position:relative;top:1px"--><table border="0" cellpadding="0" cellspacing="0" id="form1:allTabs:firstTab_shifted" onclick="if (RichFaces.isTabActive('form1:allTabs:firstTab_lbl')) return false; if (!RichFaces.onTabChange(event, 'form1:allTabs:tbsMain','form1:allTabs:firstTab')) return false;A4J.AJAX.Submit('j_id_id2','form1',event,{'parameters':{'form1:allTabs:firstTab':'form1:allTabs:firstTab'} ,'actionUrl':'/Test/faces/Page2.jsp'} ); return false; this.onclick = null;" style="position:relative; top:1px;;height : 100%; ">Tab 1<table border="0" cellpadding="0" cellspacing="0" id="form1:allTabs:secondTab_shifted" onclick="if (RichFaces.isTabActive('form1:allTabs:secondTab_lbl')) return false; if (!RichFaces.onTabChange(event, 'form1:allTabs:tbsMain','form1:allTabs:secondTab')) return false;A4J.AJAX.Submit('j_id_id2','form1',event,{'parameters':{'form1:allTabs:secondTab':'form1:allTabs:secondTab'} ,'actionUrl':'/Test/faces/Page2.jsp'} ); return false; this.onclick = null;" style="position:relative;;height : 100%; ">Tab 2RichFaces.panelTabs['form1:allTabs:tbsMain']=[{'cellActiveClass':'dr-tbpnl-tbcell-act rich-tabhdr-cell-active','id':'form1:allTabs:firstTab','cellInactiveClass':'dr-tbpnl-tbcell-inact rich-tabhdr-cell-inactive','activeClass':'dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-act rich-tab-active ','ontabenter':'','inactiveClass':'dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-inact rich-tab-inactive ','name':'firstTab','ontableave':''} ,{'cellActiveClass':'dr-tbpnl-tbcell-act rich-tabhdr-cell-active','id':'form1:allTabs:secondTab','cellInactiveClass':'dr-tbpnl-tbcell-inact rich-tabhdr-cell-inactive','activeClass':'dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-act rich-tab-active ','ontabenter':'','inactiveClass':'dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-inact rich-tab-inactive ','name':'secondTab','ontableave':''} ] ;<?xml version="1.0" encoding="UTF-8"?>


            This is tab1




            webui.suntheme4_2.dojo.addOnLoad(function() {new webui.suntheme4_2.body('/Page2.jsp', '/Test/faces/Page2.jsp',null,null,'com_sun_webui_util_FocusManager_focusElementId',true);});


            Viewsource for page without including fragments (this one works):

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wairole="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#" xmlns:waistate="http://www.w3.org/2005/07/aaa">

            var webui_suntheme4_2={"webuiJsfx":false,"webuiAll":false,"theme":{"locale":"en-us"},"ajax":{"isJsfx":true},"isDebug":false,"isStyleSheet":true,"parseOnLoad":true};

            <?xml version="1.0" encoding="UTF-8"?>
            RichFaces.tabPanel['form1:allTabs:tbsMain']={'ontabchange':'','id':'form1:allTabs:tbsMain'} ;<!--table border="0" cellpadding="0" cellspacing="0" style="position:relative;top:1px"--><table border="0" cellpadding="0" cellspacing="0" id="form1:allTabs:firstTab_shifted" onclick="if (RichFaces.isTabActive('form1:allTabs:firstTab_lbl')) return false; if (!RichFaces.onTabChange(event, 'form1:allTabs:tbsMain','form1:allTabs:firstTab')) return false;A4J.AJAX.Submit('j_id_id2','form1',event,{'parameters':{'form1:allTabs:firstTab':'form1:allTabs:firstTab'} ,'actionUrl':'/Test/faces/Page2.jsp'} ); return false; this.onclick = null;" style="position:relative; top:1px;;height : 100%; ">Tab 1<table border="0" cellpadding="0" cellspacing="0" id="form1:allTabs:secondTab_shifted" onclick="if (RichFaces.isTabActive('form1:allTabs:secondTab_lbl')) return false; if (!RichFaces.onTabChange(event, 'form1:allTabs:tbsMain','form1:allTabs:secondTab')) return false;A4J.AJAX.Submit('j_id_id2','form1',event,{'parameters':{'form1:allTabs:secondTab':'form1:allTabs:secondTab'} ,'actionUrl':'/Test/faces/Page2.jsp'} ); return false; this.onclick = null;" style="position:relative;;height : 100%; ">Tab 2RichFaces.panelTabs['form1:allTabs:tbsMain']=[{'name':'firstTab','id':'form1:allTabs:firstTab','ontabenter':'','activeClass':'dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-act rich-tab-active ','cellActiveClass':'dr-tbpnl-tbcell-act rich-tabhdr-cell-active','inactiveClass':'dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-inact rich-tab-inactive ','ontableave':'','cellInactiveClass':'dr-tbpnl-tbcell-inact rich-tabhdr-cell-inactive'} ,{'name':'secondTab','id':'form1:allTabs:secondTab','ontabenter':'','activeClass':'dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-act rich-tab-active ','cellActiveClass':'dr-tbpnl-tbcell-act rich-tabhdr-cell-active','inactiveClass':'dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-inact rich-tab-inactive ','ontableave':'','cellInactiveClass':'dr-tbpnl-tbcell-inact rich-tabhdr-cell-inactive'} ] ;

            THIS IS THE FIRST TAB




            webui.suntheme4_2.dojo.addOnLoad(function() {new webui.suntheme4_2.body('/Page2.jsp', '/Test/faces/Page2.jsp',null,null,'com_sun_webui_util_FocusManager_focusElementId',true);});


            • 3. Re: Ajax error when richFaces tabPanel includes a page fragm
              sarahkarvenz

              Solved it!!
              Problem was that an <?xml version="1.0" encoding="UTF-8"?> was getting inserted at the beginning of the page fragment on a c:import even though that line (automatically puts it at the top of a newly created fragment) had been removed from my fragments. This xml declaration was causing the xml parsing error that I was getting on the ajax request when I was trying to switch tabs.

              By putting the following jsp declaration on the page fragment, I no longer got the <?xml... declaration:
              <jsp:output omit-xml-declaration="true"/>

              So my page fragment now looks like this:
              <div xmlns:f="http://java.sun.com/jsf/core" xmlns:jsp="http://java.sun.com/JSP/Page">
              <jsp:output omit-xml-declaration="true"/>
              <f:subview id="tab2">
              This is tab2.
              </f:subview>