我使用的是Primefaces 3.5。并尝试在<p:wizard/>
的onnext处理程序中调用js函数。
我想在验证结果ob current选项卡后的特定选项卡上的onnext返回选项卡上。我的验证功能
function validateManageOtherTournaments(wizard, validationTab, lang) {
var currentTabId = validationTab;
if (currentTabId != 'competitionId') {
return wizard.next();
}
var seasonVal = document.getElementById('manageTournament:name_season_input').value;
var dateFromVal = document.getElementById('manageTournament:dateFrom_input').value;
var dateToVal = document.getElementById('manageTournament:dateTo_input').value;
/*var compNameVal = document.getElementById('manageTournament:title_input').value;*/
var isValidName = validateFieldsInOtherTournament('manageTournament', ['title'], lang);
if (isValidName) {
if (validRuContentT) {
var filledBothDate = (dateFromVal != "" && dateToVal != "");
var isEmptySeason = ("" != String(seasonVal));
if ( filledBothDate || isEmptySeason) {
return wizard.next();
}
}
}
return "competitionId"; // currentTab
}
我使用代码js wizard。但它仍然无效。(
//修订版
I try to do something like this
function validateManageOtherTournaments(wizard, validationTab, lang) {
/*var wizardElement = document.getElementById('wiz');*/
var currentTabId = validationTab;
if (currentTabId != 'competitionId') {
var currentStepIndex = wizard.getStepIndex(wizard.getState().currentStep),
stepIndexToGo = currentStepIndex + 1;
var stepIdToGo = wizard.cfg.steps[stepIndexToGo];
return wizard.loadStep(stepIdToGo, stepIndexToGo, false); // next
}
var seasonVal = document.getElementById('manageTournament:name_season_input').value;
var dateFromVal = document.getElementById('manageTournament:dateFrom_input').value;
var dateToVal = document.getElementById('manageTournament:dateTo_input').value;
/*var compNameVal = document.getElementById('manageTournament:title_input').value;*/
var isValidName = validateFieldsInOtherTournament('manageTournament', ['title'], lang);
if (isValidName) {
if (validRuContentT) {
var filledBothDate = (dateFromVal != "" && dateToVal != "");
var isEmptySeason = ("" != String(seasonVal));
if ( filledBothDate || isEmptySeason) {
var currentStepIndex = wizard.getStepIndex(wizard.getState().currentStep),
stepIndexToGo = currentStepIndex + 1;
var stepIdToGo = wizard.cfg.steps[stepIndexToGo];
return wizard.loadStep(stepIdToGo, stepIndexToGo, false); // next
}
}
}
var currentStepIndex = wizard.getStepIndex(this.getState().currentStep),
stepIndexToGo = currentStepIndex;
var stepIdToGo = wizard.cfg.steps[stepIndexToGo];
return wizard.loadStep(stepIdToGo, stepIndexToGo, false); //competitionId
}
如何在向导的onnext功能选项卡中返回?
答案 0 :(得分:1)
我做了类似的事情:
public String onFlowProcess(FlowEvent event)
{
if (!event.getOldStep().equals("competitionId"))
{
return event.getNewStep();
}
if (validationPassed())
{
return event.getNewStep();
}
else
{
return event.getOldStep();
}
}
private boolean validationPassed()
{
// do your validation here.
// return true if validation passed
}
然后在我的向导中:flowListener="#{myBean.onFlowProcess}"