[
https://issues.jboss.org/browse/RF-12789?page=com.atlassian.jira.plugin.s...
]
Lutz Ulrich commented on RF-12789:
----------------------------------
I am using Firefox 18, Chrome 24, IE 9.
There are no script errors. The problem is not related to script errors or certain
browsers but to JSF partial/ajax page updates.
I think I have to get more specific about the error.
The problem is that switching (!) between tabs via mouse-click does not work with a
dynamically added tab or tabPanel. The problem is NOT that the new tab or tabPanel
won't show up - they do.
Unfortunately my first version of dynamicTab.xhtml and DynamicTabBean.java did not work in
RichFaces 4.2.3 either. But I just provided new versions of both files which work in
RichFaces 4.2.3 but not with RichFaces 4.3.0 . The main difference is using
switchType='client' instead of 'ajax' for the tabPanels.
(Nevertheless, my exmaple probably doesn't work with switchType='ajax' because
there is no value-expression for the active tab. But even with switchType='ajax'
one can detect that click-events are handled, because requests are submitted in case of
click-events.
By the way: is there a way to remove obsolete attachments from an issue?)
In my web application, which is much more complex than the simple example, switching tabs
in dynamically tabPanels and with dynamically added tabs worked with RichFaces 4.2.3.
In order for tab-switching to work, script event-handlers have to be set for the HTML
elements which represent a tab header. The event-handlers are probably set up via 'new
RichFaces.ui.TabPanel()' and/or 'new RichFaces.ui.Tab()'.
If the HTML page is rendered initially with RichFaces 4.3.0, its <body> contains a
<script> element with such statements for each rich:tabPanel and rich:tab.
If one submits a partial (!) Ajax request which dynamically adds a new UITab to an
existing UITabPanel or which adds a new UITabPanel, only part of the page is re-rendered.
Which parts are re-rendered depends on the value of the attribute 'render' in
<f:ajax render="..."/> of a h:commandButton or on similar
re-render-configurations, see javax.faces.context.PartialViewContext.getRenderIds().
Unless the whole page is supposed to be updated, the XML-response for the partial Ajax
request will NOT (!) contain the <script> element (which RichFaces places at the end
of <body> in case the whole page is rendered). As a result, there is no script code
to setup new tabs or tabPanels for onclick-handling. Thus, switching tabs cannot work
because there are no click-event handlers for the HTML elements which represent new tabs
or tabPanels.
In my updated version of dynamicTab.xhtml I added non-Ajax command buttons for adding a
tab and tabPanel.
If you run the example, you will detect that tab-switching does NOT work after tabs or
tabPanels are added dynamically via partial Ajax. But it does work with non-Ajax, because
without partial Ajax, the whole page is rendered anew, including the <script> at the
end of <body>.
In contrast, if you use RichFaces 4.2.3 instead of 4.3.0, tab-switching works after adding
tabs/tabPanels in partial Ajax requests.
If you cannot reproduce the effect with my new example files, what JSF implementation are
you using?
Maybe the problem only shows up with Mojarra but not with MyFaces.
I could even provide fixed versions of TabRenderer and TabPanelRenderer which render the
script inline, instead of in the extra <script> element at the end of <body>.
If the script is rendered inline, everything works fine in RichFaces 4.3.0, because the
scripts will be contained in partial page responses, too.
TabPanel error after partial update with new tab
------------------------------------------------
Key: RF-12789
URL:
https://issues.jboss.org/browse/RF-12789
Project: RichFaces
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: component-panels-layout-themes
Affects Versions: 4.3.0.CR2
Environment: Mojarra 2.1.17, Tomcat 7.0.22, Java 1.7, Windows 7
Reporter: Lutz Ulrich
Assignee: Lukáš Fryč
Labels: Tab, TabPanel, dynamical-add
Fix For: 4.3.1
Attachments: dynamicTab.xhtml, dynamicTab.xhtml, DynamicTabBean.java,
DynamicTabBean.java
Original Estimate: 2 hours
Remaining Estimate: 2 hours
Adding tabs dynamically (programatically) in partial requests results in errors.
The JavaScript code for all TabPanels and their child Tabs is added to HTML <body>
using JavaScriptService.addScript(FacesContext, S), see
DivPanelRenderer.writeJavaScript(), TabRenderer.doEncodeItemEnd() and
TabRenderer.doEncodeEnd().
The top-level <script> element in <body> won't be updated if a new Tab is
added dynamically in a partial request. Thus, the script, new RichFaces.ui.Tab(...), for
the new Tab is missing.
Similar problems arise if a TabPanel is added in a partial request.
All scripts, RichFaces.ui.Tab(...) and RichFaces.ui.TabPanel(...) should be rendered
inline for partial update to work with new TabPanels and new Tabs.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira