Reputation: 1828
I decided to use wizard component.link on this component
I have condition that instead of checkbox "Skip to last" I should use button. If I press on this button it's ok, but when I go to penult tab I want generate content of confirmation tab,
public void generatePreview() {
for (CompetitionTypeBean competitionType : competitionTypeList) {
if (competitionType.getId().equals(competitionTypeId)) {
tournamentBean.setCompetitionTypeBean(competitionType);
}
}
if (teamList != null && !teamList.isEmpty()) {
List<TeamBean> teams = new ArrayList<TeamBean>();
for (TeamBean team : teamList) {
for (Long teamId : teamListSelected)
if (team.getId().equals(teamId)) {
teams.add(team);
break;
}
}
tournamentBean.setTeams(teams);
}
}
it means that I should set skip in true
for that I decide to write js function which will work on onnext event of wizard
<script type="text/javascript">
function setHiddenValue(formId, componentId, new_value) {
var tabId = 'competitionId';
if (tabId != 'predLast') {
document.getElementsByName('wiz').next();
} else {
var fullComponentId = formId + ":" + componentId;
document.getElementById(fullComponentId).value = new_value;
}
}
</script>
And there I find new problem
First I don't know as I can get current Tab Id. And second I don't how with help js make next event for wizard document.getElementsByName('wiz').next();
. I try to see generated html code. Every tab is <li>
and when this tab is selected in css style that li add 'ui-state-hightlight'
Maybe I try to develop cycle. But I can't find other solution.
Upvotes: 1
Views: 356
Reputation: 1828
I just add next rows in handler
public String onFlowProcess(FlowEvent event) throws Exception {
if ((skip == true)) {
skip = false; //reset in case user goes back
generatePreview();
return CONFIRM_TAB_ID;
} else {
String newTab = event.getNewStep();
if (CONFIRM_TAB_ID.equals(newTab)) {
generatePreview();
}
return newTab;
}
}
I think that using constant CONFIRM_TAB_ID it's normal, because I never decide to change this tabId.
Upvotes: 0
Reputation: 20691
To get the index of the current step in javascript, use the getStepIndex()
function. To get name of the current step in the backing bean, you need to obtain a reference to the Wizard in your view and either call getStep()
(returns the id
property of the next tab) or getStepToProcess()
(returns the actual next Tab
object, from which you can get the name of the current tab).
<p:wizard/>
has onnext
and onback
event callbacks that you can hook into to process javascript (or backing bean code with <p:remoteCommand/>
)
Upvotes: 1