richfacesjboss-seam

Using richfaces's tabPanel - tab's ontableave


Using Seam 2.2.2.Final and Richfaces 3.3.3.Final.

I need to perform an action when user leaves a tab, and this action can only take place after all the page is loaded, there are some bean init taking place on each tab content. So I went and read about .

Problem is, with 3 tabs, for example, as each tab is rendered and render passes for the next one, the command is fired. No good, bean not initialized and I get nullpointer pointed at me!

Anyway to prevent this behavior on this tag? As I am doing an improvement on a very large app, I am trying to mess around the deployed code as little as possible.

Thankx in advance for taking a look. Here is an example code for my page:

<?xml version="1.0" encoding="ISO-8859-1"?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:a="http://richfaces.org/a4j" 
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:rich="http://richfaces.ajax4jsf.org/rich"
                template="/WEB-INF/xhtml/templates/frameTemplate.xhtml">


    <ui:param name="pageTitle" value="Elaborar relatório, voto e ementa" />
    <ui:define name="title">#{pageTitle}</ui:define>
    <ui:param name="home" value="#{sessionProcess}" />

    <ui:define name="frameBody">
        <rich:jQuery query="hide()" selector="#update" timing="onload"/>

    <s:div id="allTabs">
        <rich:tabPanel title="Tab1" switchType="ajax" style="width: 100%;">
            <rich:tab label="Report"
                rendered="#{!sessionProcess.hideReport}" 
                title="Report" style="width: 100%;"
                action="#{sessionProcess.setReport()}" immediate="true" ontableave="#{sessionProcess.writeDraftReport()}">
                .
                .
                .
        <rich:tabPanel title="Tab2" switchType="ajax" style="width: 100%;">
            <rich:tab label="Vote"
                rendered="#{!sessionProcess.hideVote}" 
                title="Report" style="width: 100%;"
                action="#{sessionProcess.setVote()}" immediate="true" ontableave="#{sessionProcess.writeDraftVote()}">
                .
                .
                .

Solution

  • The @ontableave is for client-side code, i.e. JavaScript, not for bean methods. If you need to execute something on the server in response to a client-side event, use <a4j:support>:

    <rich:tab label="Report" … >
        <a4j:support event="ontableave" 
                     action="#{sessionProcess.writeDraftReport()}" />
    </rich:tab>