Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9268929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:58:54+00:00 2026-06-18T14:58:54+00:00

<p:tabView widgetVar=addSystemWizard style=width:980px;height:400px; dynamic=true activeIndex=#{testBean.messagesTab.activeIndex} > <p:ajax event=tabChange listener=#{testBean.onTabChange} update=:tabview:sysMsg/> <p:tab id=generalInfo title=1. General

  • 0
    <p:tabView widgetVar="addSystemWizard" style="width:980px;height:400px;" dynamic="true"  activeIndex="#{testBean.messagesTab.activeIndex}" >  

          <p:ajax event="tabChange" listener="#{testBean.onTabChange}" update=":tabview:sysMsg"/>  

            <p:tab id="generalInfo" title="1. General Information">  `enter code here`



private TabView messagesTab;

    public TabView getMessagesTab () {
        if(messagesTab==null){
            messagesTab= new TabView();
        }
        return messagesTab;
    }

    public void setMessagesTab(TabView messagesTab ) {
        this.messagesTab = messagesTab;
    }


    public void onTabChange(TabChangeEvent event){
        if(test.getName()==null || test.getName().equals("")){

            FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, event.getTab().getId() ,"please enter all required fields");  

            FacesContext.getCurrentInstance().addMessage(null, msg);  
            int idx=0;
            messagesTab= (TabView) event.getComponent();
            messagesTab.setActiveIndex(idx);
        }

    }

I am calling a tabchange event on tabview, I have name attribute im my page,if that attribute is blank or null I have to stay on same tab, otherwise I ahve to go next tab, basically performing validation.. I have posted the above code to do that, but its not working!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:58:55+00:00Added an answer on June 18, 2026 at 2:58 pm

    I found this blog post that describes how to use a p:remoteCommand and javascript to accomplish this.

    Trying various approaches to the question above (with p:ajax event=”tabChange” and so on), I came up with a clean and well working solution. The code below turns on the PrimeFaces TabView into a “wizard mode”. That means, the user stays on the same tab when he / she is trying to switch tabs and has validation errors within the current tab. The main idea is to use p:remoteCommand for a deferred decision about tab switching. If no validation errors were present, the switching occurs by the TabView widget’s method select.

    XHTML:

    <p:tabView ... widgetVar="tv_widget" styleClass="tv_selector">
        ...
    </p:tabView>
    
    <p:remoteCommand name="tv_remoteCommand" process="@(.tv_selector)" update="@(.tv_selector)" global="false"
            oncomplete="handleTabChangeTV(xhr, status, args, tv_widget)"/>
    
    <h:panelGroup id="tv_script" styleClass="tv_selector">
        <script type="text/javascript">
              $(function(){
                  bindOnClickTV(tv_remoteCommand, tv_widget);
              });
        </script>
    </h:panelGroup>
    

    Javascript:

    function bindOnClickTV(rc, widget) {
        // unbind PrimeFaces click handler and bind our own
        widget.jq.find('.ui-tabs-nav > li').unbind('click.tabview').
            off('click.custom-tabview').on('click.custom-tabview', function (e) {
                var element = $(this);
    
                if ($(e.target).is(':not(.ui-icon-close)')) {
                    var index = element.index();
    
                    if (!element.hasClass('ui-state-disabled') && index != widget.cfg.selected) {
                        // buffer clicked tab
                        widget.clickedTab = element.index();
    
                        // call remote command
                        rc();
                    }
                }
    
                e.preventDefault();
            });
    }
    
    function handleTabChangeTV(xhr, status, args, widget) {
        if (!args.validationFailed) {
            widget.select(widget.clickedTab);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here a snippet of my JSF: <p:tabView id=tabView var=tab value=#{data.tabs} widgetVar=tabViewWidget activeIndex=#{data.newActiveTabIndex}> <p:ajax event=tabClose
Primefaces tabView activeIndex property is always getting null. My view.jsf: <h:form> <p:growl id=growl showDetail=true
I'm using primefaces 3.1 Tabview with dynamic = true is not working with viewscope.
I am having a serious issue with the p:tabView component. I have set dynamic=true
Does anyone know how to style YUI Tabview component [1] so it will look
I have a app, where I've a tabview controller. All the data is dynamic,
I have one tabview which contain two different tab(subject and chapter) and i need
I want to get the tabView name programatically. What is the property to do
I have a flash app embedded in a yui TabView tab div, the problem
I have a UITableView that I am placing inside a TabView. I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.