Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public WizardPanel(String id) {
- super(id, false);
- // false deactivates the default style.
- setDefaultModel(new CompoundPropertyModel<WizardPanel>(this));
- WizardModel model = new WizardModel();
- model.add(new FirstStep());
- model.add(new SecondStep());
- model.add(new ThirdStep());
- model.add(new ConfirmationStep());
- Iterator<IWizardStep> iterator = model.stepIterator();
- for(int i = 1; iterator.hasNext(); i ++){
- System.out.println(String.valueOf(i));
- }
- init(model);
- }
- public class OverviewComponent extends Panel{
- private static final long serialVersionUID = 1L;
- private List<WizardStep> steps;
- private WizardModel model;
- public OverviewComponent(String id, WizardModel model) {
- super(id);
- this.model = model;
- steps = fillList();
- this.add(new ListView<WizardStep>("steps", steps) {
- private static final long serialVersionUID = 1L;
- /**
- * Wrap a markup container around the item append a css attribute to every item
- */
- @Override
- protected void populateItem(ListItem<WizardStep> item) {
- WebMarkupContainer stepOverviewItem;
- item.add(stepOverviewItem = new WebMarkupContainer("stepOverviewItem"));
- stepOverviewItem.add(new Label("index", Model.of(item.getIndex()+1)));
- stepOverviewItem.add(new AttributeModifier("class", getCSSProperty(item.getModelObject())));
- stepOverviewItem.setOutputMarkupId(true);
- stepOverviewItem.setOutputMarkupPlaceholderTag(true);
- }
- });
- }
- public String getCSSProperty(WizardStep step) {
- if (step.equals(model.getActiveStep())) {
- return "active";
- } else if (!step.isComplete()) {
- return "pending";
- } else if (step.isComplete()) {
- return "completed";
- }
- return "";
- }
- public List<WizardStep> fillList() {
- List<WizardStep> iSteps = new ArrayList<WizardStep>();
- Iterator<IWizardStep> iterator = model.stepIterator();
- while (iterator.hasNext()) {
- iSteps.add((WizardStep)iterator.next());
- }
- return iSteps;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement