Set current displayed tab programmatically in p:wizard

前端 未结 2 1039
执笔经年
执笔经年 2021-01-23 03:43

Is it possible to set current displayed tab programmatically in ?

For example, I want that for two different request to the same page which con

相关标签:
2条回答
  • 2021-01-23 04:17

    My answer would most probably not meet your complete requirements, but, nonetheless, it may point you towards solution to your problem.

    As far as I know, the PrimeFaces Wizard UIComponent is designed for a workflow of one page. That effectively means that inputs will be handled by a backing beans that is in a view scope.

    This way, making a redirection on a certain step will clear all data inputs, because your view changes and the old one is destroyed.

    Anyway, a means of setting a current tab for display is step attribute of Wizard component. So,

    <p:wizard step="#{wizardBean.currentStep}" >...</p:wizard>
    

    will force the wizard to show you step which you specified in your bean. You may be able to get it by using, for example, a view parameter, like in

    <f:viewParam name="step" value="#{wizardBean.currentStep}" />
    

    But it will make sense if lifetime of your bean is more that for a view, for example, the bean could be put in session scope.

    That said, maybe it is a better idea to do login beforehand. Or, if it is absolutely necessary to do it in step 2 of your wizard, provide for a built-in login functionality in a page itself, or in a popular window?

    Also, programmatically the setting you speak of can be achieved via a binding of component to your backing bean and setting the step value in the backing bean, for example, in a preRenderView event.

    0 讨论(0)
  • 2021-01-23 04:42

    According to primefaces documentation there's a step attribute for p:wizard tag, which specifies the step of the wizard you're currently in.

    attribute: step
    default value: 0
    type: String
    description: Id of the current step in flow

    You must bind this attribute to a value of your backing bean and maintain it during redirection and coming back. If your wizard's bean is @ViewScoped you'll loose that info during redirection step, so you have to pass it using a view param or flash scope.

    0 讨论(0)
提交回复
热议问题