Example usage for org.apache.wicket.markup.repeater RepeatingView RepeatingView

List of usage examples for org.apache.wicket.markup.repeater RepeatingView RepeatingView

Introduction

In this page you can find the example usage for org.apache.wicket.markup.repeater RepeatingView RepeatingView.

Prototype

public RepeatingView(String id, IModel<?> model) 

Source Link

Usage

From source file:com.przemo.projectmanagementweb.controls.TasksListPanel.java

public TasksListPanel(String id, IModel<List<Task>> model) {
    super(id, model);
    RepeatingView tasksView = new RepeatingView("tasksList", model);
    for (Task t : model.getObject()) {
        tasksView.add(new TasksListItem(tasksView.newChildId(), new CompoundPropertyModel<>(t)));
    }/*from  w  w  w  .ja v  a  2 s.co  m*/

    add(tasksView);

    add(new Label("tasksCount", Model.of("Number of tasks: " + model.getObject().size())));
}

From source file:com.userweave.module.methoden.questionnaire.page.survey.dimensions.DimensionsQuestionSurveyPanel.java

License:Open Source License

public DimensionsQuestionSurveyPanel(String id, DimensionsQuestion question, QuestionnaireSurveyContext context,
        Locale locale) {//from   www.j  a  va 2 s  .c o  m
    super(id, question, context, locale);

    final int numberOfRatingSteps = question.getNumberOfRatingSteps();

    showNoAnswerOption = question.getShowNoAnswerOption();
    if (showNoAnswerOption == null) {
        showNoAnswerOption = false;
    }

    add(new WebMarkupContainer("notStatedHeaderLeft").setVisible(showNoAnswerOption));

    IModel model = new PropertyModel(getDefaultModel(), "antipodePairs") {
        private boolean sorted = false;

        @Override
        public Object getObject() {
            List objects = (List) super.getObject();
            if (!sorted) {
                sortPossibleAnswers(objects);
                sorted = true;
            }
            return objects;
        }
    };

    RepeatingView view = new RepeatingView("antipodePairs", model);

    add(view);

    for (final AntipodePair antipodePair : (List<AntipodePair>) view.getDefaultModelObject()) {
        WebMarkupContainer container = new WebMarkupContainer(view.newChildId());

        view.add(container);

        container.add(
                new DimensionsSingleRatingPanel("singleRatingPanel", numberOfRatingSteps, showNoAnswerOption,
                        question.getRandomizeAntipodePosition(), new Model(antipodePair), new Model<Integer>() {
                            @Override
                            public Integer getObject() {
                                return getRating(antipodePair);
                            }

                            @Override
                            public void setObject(Integer rating) {
                                setRating(antipodePair, rating);
                            }
                        }, DimensionsQuestionSurveyPanel.this.getLocale()));
    }

    //      add(
    //         new PropertyListView("antipodePairs", model) {
    //            
    //             @Override
    //            protected void populateItem(ListItem item) {
    //                final AntipodePair antipodePair = (AntipodePair) item.getModelObject();
    //                               
    //                item.add(
    //                   new DimensionsSingleRatingPanel(
    //                     "singleRatingPanel", 
    //                     numberOfRatingSteps, 
    //                     showNoAnswerOption, 
    //                     item.getModel(),
    //                     new Model() {
    //                         @Override
    //                         public Object getObject() {
    //                            return getRating(antipodePair);
    //                         }
    //
    //                         @Override
    //                        public void setObject(Object rating) {                           
    //                           setRating(antipodePair, (Integer) rating);
    //                        }
    //                     },
    //                     DimensionsQuestionSurveyPanel.this.getLocale()
    //                  )
    //               );         
    //             }                   
    //         }
    //      );            

    add(new WebMarkupContainer("notStatedFooterLeft").setVisible(showNoAnswerOption));
}

From source file:com.userweave.module.methoden.questionnaire.page.survey.multiplerating.MultRatingSurveyPanel.java

License:Open Source License

public MultRatingSurveyPanel(String id, MultipleRatingQuestion question, QuestionnaireSurveyContext console,
        Locale locale) {// w ww  . j a v a2s.  c o m
    super(id, question, console, locale);

    add(new Label("antipode1",
            new LocalizedPropertyModel(getDefaultModel(), "antipodePair.antipode1", getLocale())));
    add(new Label("antipode2",
            new LocalizedPropertyModel(getDefaultModel(), "antipodePair.antipode2", getLocale())));

    numberOfRatingSteps = question.getNumberOfRatingSteps();

    showNoAnswerOption = question.getShowNoAnswerOption();
    if (showNoAnswerOption == null) {
        showNoAnswerOption = false;
    }

    add(new WebMarkupContainer("notStatedHeaderLeft").setVisible(showNoAnswerOption));

    IModel model = new PropertyModel(getDefaultModel(), "ratingTerms") {
        private boolean sorted = false;

        @Override
        public Object getObject() {
            List objects = (List) super.getObject();
            if (!sorted) {
                sortPossibleAnswers(objects);
                sorted = true;
            }
            return objects;
        }
    };

    RepeatingView ratingTermsView = new RepeatingView("ratingTerms", model);

    add(ratingTermsView);

    for (final RatingTerm ratingTerm : (List<RatingTerm>) ratingTermsView.getDefaultModelObject()) {
        WebMarkupContainer container = new WebMarkupContainer(ratingTermsView.newChildId());

        ratingTermsView.add(container);

        container.add(
                new MultiRatingSingleRatingPanel("singleRatingPanel", numberOfRatingSteps, showNoAnswerOption,
                        LocalizationUtils.getValue(ratingTerm.getText(), getLocale()), new Model<Integer>() {
                            @Override
                            public Integer getObject() {
                                return getRating(ratingTerm);
                            }

                            @Override
                            public void setObject(Integer rating) {
                                setRating(ratingTerm, rating);
                            }
                        }));
    }

    //      add(
    //         new ListView("ratingTerms", model) {
    //            
    //             private boolean notApplicable;
    //             
    //             @Override
    //            protected void populateItem(ListItem item) {
    //                final RatingTerm ratingTerm = (RatingTerm) item.getModelObject();
    //                
    //                item.add(
    //                   new MultiRatingSingleRatingPanel(
    //                         "singleRatingPanel", 
    //                         numberOfRatingSteps, 
    //                         showNoAnswerOption, 
    //                         LocalizationUtils.getValue(ratingTerm.getText(), getLocale()),
    //                     new Model() {
    //                         @Override
    //                         public Object getObject() {
    //                            return getRating(ratingTerm);
    //                         }
    //                         
    //                        @Override
    //                        public void setObject(Object rating) {                           
    //                           setRating(ratingTerm, (Integer) rating);
    //                        }
    //                     } 
    //                  ) 
    //               );                     
    //             }
    //         }
    //      );

    add(new WebMarkupContainer("notStatedFooterLeft").setVisible(showNoAnswerOption));
}