rich:tabPanel execute/immediate-attribute on rich:tab
dageisz Jun 19, 2013 4:27 AMHello,
i have a question regarding the rich:tabPanel.
On a project i have the situation that i am using switchType="ajax" on one hand to speed up the render time on the other hand to validate the input per tab (on switch).
Now there are different standards per tab.
On one tab the input fields shall be validated ontabswitch on another they should not.
- So i thought i could use the execute attribute from the rich:tab component, but did not effect anything.
- My second attempt was to use the immediate attribute of the rich:tab, that did not work either.
- At last i tried the immediate attribute of the rich:tabPanel, wich was working as expected.
Now i digged into the code a bit deeper and found a strange behavior.
When i set immediate="true" to the rich:tab i switch to, i can do this without validation of the rich:tab i came from, but changing immediate="true" on the tab i dont want to get validated, does not work.
Is this a bug or do i understand the mechanics the wrong way?
<rich:tabPanel id="tabPanelSpezialtransporte" switchType="ajax"> <!-- execute has no effect, even @none, input will be validated --> <rich:tab header="tab1 (execute)" execute="@this"> <h:inputText value="#{myBean.value}" required="true" /> </rich:tab> <!-- this tabs content should always be validated on tabswitch, but it is NOT when i switch to tab3, cause tab3 hast immediate true. --> <rich:tab header="tab2 (default validation,execution)"> <h:inputText value="#{myBean.value}" required="true" /> </rich:tab> <!-- this tab should never be validated on tabswitch, but in this example it is always, cause there are no ther immediate tabs.--> <rich:tab header="tab3 (immediate)" immediate="true"> <h:inputText value="#{myBean.value}" required="true" /> </rich:tab> </rich:tabPanel>
I hope i could make myself clear, cause i havent found any example on this.
While debugging i found the following code that seems to be responsible for the situation:
AbstractTogglePanel#setEventPhase
protected void setEventPhase(ItemChangeEvent event) { if (isImmediate() || (event.getNewItem() != null && RendererUtils.getInstance().isBooleanAttribute(event.getNewItem(), "immediate"))) { event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES); } else { event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES); } }
To decide what to do next the newItem is taken, while it seems to me that the oldItem should be the one asked for the immediate-attribute, cause this is the one beeing processed.
Just in case it helps here is the stack trace when the method is called:
Daemon Thread [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] (Suspended (breakpoint at line 526 in AbstractTogglePanel)) UITabPanel(AbstractTogglePanel).setEventPhase(ItemChangeEvent) line: 526 UITabPanel(AbstractTogglePanel).queueEvent(FacesEvent) line: 520 ItemChangeEvent(FacesEvent).queue() line: 130 UITabPanel(AbstractTogglePanel).processDecodes(FacesContext) line: 310 PartialViewExecuteVisitCallback.visit(VisitContext, UIComponent) line: 53 ExecuteExtendedVisitContext(BaseExtendedVisitContext).invokeVisitCallback(UIComponent, VisitCallback) line: 321 UITabPanel(AbstractTogglePanel).visitTree(VisitContext, VisitCallback) line: 900 HtmlForm(UIComponent).visitTree(VisitContext, VisitCallback) line: 1623 HtmlForm(UIForm).visitTree(VisitContext, VisitCallback) line: 371 UIOutput(UIComponent).visitTree(VisitContext, VisitCallback) line: 1623 UIViewRoot(UIComponent).visitTree(VisitContext, VisitCallback) line: 1623 ExtendedPartialViewContextImpl.executeComponents(PhaseId, Collection) line: 278 ExtendedPartialViewContextImpl.processPartialExecutePhase(PhaseId) line: 258 ExtendedPartialViewContextImpl.processPartial(PhaseId) line: 215 UIViewRoot.processDecodes(FacesContext) line: 923 ApplyRequestValuesPhase.execute(FacesContext) line: 78 ApplyRequestValuesPhase(Phase).doPhase(FacesContext, Lifecycle, ListIterator) line: 101 LifecycleImpl.execute(FacesContext) line: 118 FacesServlet.service(ServletRequest, ServletResponse) line: 593 ...
Thanks in advance