jeremiah
jeremiah

Reputation: 21

Can you hide/render tabs in primefaces using wizard

Is it possible to render different tabs using the primeface's p:Wizard? I know you can skip tabs, but I need to have a tab rendered conditionally based on information entered in tab 1 (A). If the user enters in a specific set of check boxes, I need tab C to be rendered and part of the flow, and not shown otherwise.

the skeleton of my xhtml

<p:wizard id="FlowWiz" flowListener="#{myBean.handleFlow}"> 
    <p:tab id="A" title="A">
        stuff
    </p:tab>
    <p:tab id="B" title="B">
        stuff
    </p:tab>
    <p:tab id="C" title="C">
        <ccpath:extraDetailsxml isWizard = "true" />
    </p:tab>
    <p:tab id="D" title="D">
        stuff
    </p:tab>
</p:wizard>

The skeleton of my bean

public class myBean() { 
    private String step = "A";

    public String handleFlow(FlowEvent event){
        isAccepted = false;
    
        if(validatestuff()){
            if(event.getNewStep().equals("B") && showTab()) 
               primeFaces.ajax().update("pathTo:flowWiz");
        
            setStep(event.getNewStep());
        
            return event.getNewStep();
        }else{
            return event.getOldStep();
        }     
    }
}

The data to render tab C will be entered in A, so id like to have tab C rendered when "Next" is clicked. this is what my current xhtml and bean looked like (kinda). any help is appreciated

Upvotes: 2

Views: 417

Answers (1)

stefan-dan
stefan-dan

Reputation: 604

my.xhtml

<p:tab id="C" title="C" rendered="#{myBean.showTab}">

myBean

public boolean showTab() {
    boolean rendered = true;
    if (){
     //some logic
     rendered = false;
    }
    return rendered;
}

I haven't tested it with <p:wizard>, but I think it should work.

Upvotes: 1

Related Questions