Example usage for org.apache.wicket.markup.html.list ListView removeAll

List of usage examples for org.apache.wicket.markup.html.list ListView removeAll

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list ListView removeAll.

Prototype

public MarkupContainer removeAll() 

Source Link

Document

Removes all children from this container.

Usage

From source file:au.org.theark.study.web.component.manageuser.form.SearchForm.java

License:Open Source License

@Override
protected void onNew(AjaxRequestTarget target) {
    containerForm.getModelObject().setMode(Constants.MODE_NEW);
    prePopulateArkUserRoleList();/* w  w  w .  j  av  a2  s.c om*/
    arkCrudContainerVO.getWmcForarkUserAccountPanel().setVisible(true);
    // This should re-render the list again
    ListView listView = (ListView) arkCrudContainerVO.getWmcForarkUserAccountPanel().get("arkUserRoleList");
    listView.removeAll();
    preProcessDetailPanel(target);
    target.add(arkCrudContainerVO.getEditButtonContainer());
    target.add(arkCrudContainerVO.getWmcForarkUserAccountPanel());
}

From source file:au.org.theark.study.web.component.manageuser.SearchResultListPanel.java

License:Open Source License

private AjaxLink buildLink(final ArkUserVO arkUserVo, final WebMarkupContainer searchResultsContainer) {

    AjaxLink link = new AjaxLink("userName") {

        private static final long serialVersionUID = 1L;

        @Override//from w  w w .j  a va2s .co m
        public void onClick(AjaxRequestTarget target) {
            try {
                // Fetch the user and related details from backend
                Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession()
                        .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
                Study study = iArkCommonService.getStudy(sessionStudyId);

                ArkUserVO arkUserVOFromBackend = iUserService.lookupArkUser(arkUserVo.getUserName(), study);
                if (!arkUserVOFromBackend.isArkUserPresentInDatabase()) {
                    containerForm
                            .info(new StringResourceModel("user.not.linked.to.study", this, null).getString());
                    target.add(feedbackPanel);
                    arkUserVOFromBackend.setChangePassword(true);
                    arkUserVOFromBackend.getArkUserEntity().setLdapUserName(arkUserVo.getUserName());
                    arkUserVOFromBackend.setStudy(new Study());
                    prePopulateForNewUser(arkUserVOFromBackend);
                } else {
                    arkUserVOFromBackend.setStudy(study);
                    prePopulateArkUserRoleList(arkUserVOFromBackend);
                }

                containerForm.getModelObject().setArkUserRoleList(arkUserVOFromBackend.getArkUserRoleList());

                containerForm.setModelObject(arkUserVOFromBackend);

                // This triggers the call to populateItem() of the ListView
                ListView listView = (ListView) arkCrudContainerVO.getWmcForarkUserAccountPanel()
                        .get("arkUserRoleList");
                if (listView != null) {
                    listView.removeAll();
                }

                arkCrudContainerVO.getWmcForarkUserAccountPanel().setVisible(true);
                ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO);
                target.add(feedbackPanel);
                // Set the MODE here.Since the User Details are from LDAP we don't have a entity that we can use to check for a mode
                containerForm.getModelObject().setMode(Constants.MODE_EDIT);

                // Available/assigned child studies
                List<Study> availableChildStudies = new ArrayList<Study>(0);
                List<Study> selectedChildStudies = new ArrayList<Study>(0);

                if (study.getParentStudy() != null && study.getParentStudy() == study) {
                    availableChildStudies = iStudyService.getChildStudyListOfParent(study);

                    // Only assign selected child studies if/when user actually assigned study in context
                    if (arkUserVOFromBackend.getStudy().getId() != null) {
                        selectedChildStudies = iArkCommonService
                                .getAssignedChildStudyListForUser(arkUserVOFromBackend);
                    }
                }

                containerForm.getModelObject().setAvailableChildStudies(availableChildStudies);
                containerForm.getModelObject().setSelectedChildStudies(selectedChildStudies);
            } catch (ArkSystemException e) {
                containerForm.error(new StringResourceModel("ark.system.error", this, null).getString());
                target.add(feedbackPanel);
            }
        }
    };
    // Add the label for the link
    Label userNameLinkLabel = new Label("userNameLink", arkUserVo.getUserName());
    link.add(userNameLinkLabel);
    return link;
}

From source file:ontopoly.components.FieldsEditor.java

License:Apache License

private ListView<FieldDefinitionModel> createListView(final List<FieldDefinitionModel> fieldDefinitionModels) {
    ListView<FieldDefinitionModel> listView = new ListView<FieldDefinitionModel>("addFields",
            fieldDefinitionModels) {//from   w  ww. j ava2 s . c o m
        public void populateItem(final ListItem<FieldDefinitionModel> item) {

            FieldDefinitionModel fieldDefinitionModel = item.getModelObject();
            //item.setRenderBodyOnly(true);

            Component component = new FieldsEditorAddPanel("field", topicTypeModel, fieldDefinitionModel) {
                @Override
                protected void onAddField(TopicTypeModel topicTypeModel,
                        FieldDefinitionModel fieldDefinitionModel, AjaxRequestTarget target) {
                    // add field to topic type
                    topicTypeModel.getTopicType().addField(fieldDefinitionModel.getFieldDefinition());

                    // remove field definition from available list
                    fieldDefinitionModels.remove(fieldDefinitionModel);
                    @SuppressWarnings("rawtypes")
                    ListView pListView = (ListView) item.getParent();
                    pListView.removeAll();
                    onUpdate(target);
                }
            };
            //component.setRenderBodyOnly(true);
            item.add(component);
        }
    };
    listView.setOutputMarkupId(true);
    listView.setReuseItems(true);
    return listView;
}