我想隐藏向导中最后一个标签页的BACK按钮。 我正在使用primefaces。它的解决方案是什么?
谢谢
答案 0 :(得分:4)
你可以使用jQuery在客户端做到这一点:
假设您在展示中使用向导:http://www.primefaces.org/showcase/ui/wizard.jsf:
<p:wizard widgetVar="wiz"
flowListener="#{userWizard.onFlowProcess}"
onNext="hideBackOnLastTab()">
的javascript:
function hideBackOnLastTab() {
if($("ul.ui-wizard-step-titles>li").last()
.is("ul.ui-wizard-step-titles>li.ui-state-highlight")) {
$("div.ui-wizard-navbar>button.ui-wizard-nav-back").css("display", "none");
}
}
此外,您可以注意到向导中的下一个按钮(在PF客户端)以相同的方式隐藏在最后一个面板中。
答案 1 :(得分:3)
我很长一段时间都有同样的问题,最后解决了。 也许我的解决方案对未来的其他人有帮助:
网页:
<p:wizard id="dataLoadSetWizard" widgetVar="wiz" onnext="hideBackOnLastTab()" ...
使用Javascript:
function hideBackOnLastTab() {
if(PF('wiz').getStepIndex(PF('wiz').currentStep) > 0) {
PF('wiz').backNav.css("visibility", "hidden")
}
}
答案 2 :(得分:0)
我想使用PrimeFaces 6.2分享我的解决方案。视图侧没有自定义JavaScript。
<p:importConstants
type="com.example.WizardController"
var="WizardController"
></p:importConstants>
<p:wizard
flowListener="#{wizardController.onFlow}"
widgetVar="wizard"
>
<p:tab id="#{WizardController.STEP_LAST}">
</p:tab>
</p:wizard>
在流监听器中,我只是隐藏导航按钮,并在最后一步禁用导航栏。隐藏导航栏是必要的。否则,向导的PrimeFaces内部JavaScript会再次淡入。
@ViewScoped
@Named
public class WizardController {
public static final String STEP_LAST = "last";
public String onFlow(FlowEvent flowEvent) {
if (flowEvent.getNewStep().equals(STEP_LAST)) {
PrimeFaces.current().executeScript("PF('wizard').backNav.hide(); PF('wizard').nextNav.hide(); PF('wizard').cfg.showNavBar = false;");
}
}
}
答案 3 :(得分:0)
从托管bean中,您可以尝试以下操作:
@ManagedBean(name = "testWizardBean")
@ViewScoped
public class TestWizardBean implements Serializable {
private RequestContext requestContext;
@PostConstruct
public void init() {
requestContext = RequestContext.getCurrentInstance();
if (testWizardDto.getDirection().isEmpty()) {
requestContext.execute("PF('signwzd').nextNav.hide();");
}
}
}