向导,单击选项卡并重定向到它

Wizard, click in tab and redirect to it

我在 primefaces 中使用向导,行为是常规的,几个选项卡,单击下一步下一步,单击返回返回,onflowproces 等。问题是在某些情况下你可以进入只读模式的页面,这样就不用一步一步来了,我想找到点击标签重定向的方法。

向导包含 8 个选项卡,可以访问每个选项卡,在 url 参数中添加选项卡的 ID,我唯一要做的就是找到一种方法来单击选项卡并重定向到选项卡的url。

有办法实现吗?谢谢!

为了使向导的名称作为 link 到他们的选项卡,我重写了 WizardRenderer,如下所示:

    package myImportantPackage;  
 
    import java.io.IOException;

    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;

    import org.primefaces.component.tabview.Tab;
    import org.primefaces.component.wizard.Wizard;
 
  
    public class WizardRenderer extends org.primefaces.component.wizard.WizardRenderer {
             
            @Override
            protected void encodeStepStatus(FacesContext context, Wizard wizard) throws IOException {
                ResponseWriter writer = context.getResponseWriter();
                String currentStep = wizard.getStep();
                boolean currentFound = false;
         
                writer.startElement("ul", null);
                writer.writeAttribute("class", Wizard.STEP_STATUS_CLASS + " wizard-panels", null);
                int i = 0;
                for(UIComponent child : wizard.getChildren()) {
                    if(child instanceof Tab && child.isRendered()) {
                        Tab tab = (Tab) child;
                        boolean active = (!currentFound) && (currentStep == null || tab.getId().equals(currentStep));
                        String titleStyleClass = active ? Wizard.ACTIVE_STEP_CLASS : Wizard.STEP_CLASS;
                        if(tab.getTitleStyleClass() != null) {
                            titleStyleClass = titleStyleClass + " " + tab.getTitleStyleClass();
                        }
                         
                        if(active) {
                            currentFound = true;
                        }
         
                        writer.startElement("li", null);
                        writer.writeAttribute("class", titleStyleClass, null);
                        if(tab.getTitleStyle() != null) writer.writeAttribute("style", tab.getTitleStyle(), null);
                         
                        writer.startElement("a", null);
                        final String wiz = wizard.resolveWidgetVar();
                        writer.writeAttribute("href", "javascript:PF('"+wiz+"').loadStep(PF('"+wiz+"').cfg.steps["+i+"], false)", null);
                        if (tab.getTitletip() != null) writer.writeAttribute("title", tab.getTitletip(), null);
                        writer.write(tab.getTitle());
                        writer.endElement("a");
                         
                        writer.endElement("li");
                        i++;
                    }
                }
         
                writer.endElement("ul");
            }    
        }

并在faces-config.xml中注册,像这样

<renderer>
    <component-family>org.primefaces.component</component-family>
    <renderer-type>org.primefaces.component.WizardRenderer</renderer-type>
    <renderer-class>myImportantPackage.WizardRenderer</renderer-class>
</renderer>