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

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

Introduction

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

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

From source file:org.sakaiproject.profile2.tool.pages.panels.WallItemPanel.java

License:Educational Community License

/**
 * Creates a new instance of <code>WallItemPanel</code>.
 * /*from   w w w.  ja  va2s.  c om*/
 * @param id
 * @param userUuid the id of the user whose wall this item panel is on.
 * @param wallItem
 * @param myWallPanel a reference to my wall panel for repainting.
 */
public WallItemPanel(String id, final String userUuid, final WallItem wallItem, final MyWallPanel myWallPanel) {
    super(id);

    setOutputMarkupId(true);

    // image wrapper, links to profile
    Link<String> wallItemPhoto = new Link<String>("wallItemPhotoWrap",
            new Model<String>(wallItem.getCreatorUuid())) {

        private static final long serialVersionUID = 1L;

        public void onClick() {
            setResponsePage(new ViewProfile(getModelObject()));
        }
    };

    // image
    ProfileImage photo = new ProfileImage("wallItemPhoto", new Model<String>(wallItem.getCreatorUuid()));
    photo.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
    wallItemPhoto.add(photo);

    add(wallItemPhoto);

    // name and link to profile
    Link<String> wallItemProfileLink = new Link<String>("wallItemProfileLink",
            new Model<String>(wallItem.getCreatorUuid())) {

        private static final long serialVersionUID = 1L;

        public void onClick() {
            setResponsePage(new ViewProfile(getModelObject()));
        }

    };
    wallItemProfileLink
            .add(new Label("wallItemName", sakaiProxy.getUserDisplayName(wallItem.getCreatorUuid())));
    add(wallItemProfileLink);

    add(new Label("wallItemDate",
            ProfileUtils.convertDateToString(wallItem.getDate(), ProfileConstants.WALL_DISPLAY_DATE_FORMAT)));

    // ACTIONS

    final ModalWindow wallItemActionWindow = new ModalWindow("wallItemActionWindow");
    add(wallItemActionWindow);

    final WallAction wallAction = new WallAction();
    // delete link
    final AjaxLink<WallItem> removeItemLink = new AjaxLink<WallItem>("removeWallItemLink",
            new Model<WallItem>(wallItem)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            wallItemActionWindow.setContent(new RemoveWallItem(wallItemActionWindow.getContentId(),
                    wallItemActionWindow, wallAction, userUuid, this.getModelObject()));

            wallItemActionWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClose(AjaxRequestTarget target) {
                    if (wallAction.isItemRemoved()) {
                        myWallPanel.replaceSelf(target, userUuid);
                    }
                }
            });

            wallItemActionWindow.show(target);
            target.appendJavaScript("fixWindowVertical();");
        }
    };

    removeItemLink.add(new Label("removeWallItemLabel", new ResourceModel("link.wall.item.remove")));
    removeItemLink.add(new AttributeModifier("title", true, new ResourceModel("link.title.wall.remove")));

    // not visible when viewing another user's wall
    if (false == sakaiProxy.getCurrentUserId().equals(userUuid)) {
        removeItemLink.setVisible(false);
    }

    add(removeItemLink);

    // panel for posting a comment that slides up/down
    final WallItemPostCommentPanel postCommentPanel = new WallItemPostCommentPanel("wallItemPostCommentPanel",
            userUuid, wallItem, this, myWallPanel);
    postCommentPanel.setOutputMarkupPlaceholderTag(true);
    postCommentPanel.setVisible(false);
    add(postCommentPanel);

    final AjaxLink<WallItem> commentItemLink = new AjaxLink<WallItem>("commentWallItemLink",
            new Model<WallItem>(wallItem)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            postCommentPanel.setVisible(true);
            target.add(postCommentPanel);
            target.appendJavaScript("$('#" + postCommentPanel.getMarkupId() + "').slideDown();");
        }
    };

    commentItemLink.add(new Label("commentWallItemLabel", new ResourceModel("link.wall.item.comment")));
    commentItemLink.add(new AttributeModifier("title", true, new StringResourceModel("link.title.wall.comment",
            null, new Object[] { sakaiProxy.getUserDisplayName(wallItem.getCreatorUuid()) })));

    add(commentItemLink);

    if (ProfileConstants.WALL_ITEM_TYPE_EVENT == wallItem.getType()) {
        add(new Label("wallItemText", new ResourceModel(wallItem.getText())));

    } else if (ProfileConstants.WALL_ITEM_TYPE_POST == wallItem.getType()) {
        add(new Label("wallItemText", ProfileUtils.processHtml(wallItem.getText()))
                .setEscapeModelStrings(false));

    } else if (ProfileConstants.WALL_ITEM_TYPE_STATUS == wallItem.getType()) {
        add(new Label("wallItemText", wallItem.getText()));

    }

    // COMMENTS

    ListView<WallItemComment> wallItemCommentsListView = new ListView<WallItemComment>("wallItemComments",
            wallItem.getComments()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<WallItemComment> item) {

            WallItemComment comment = (WallItemComment) item.getDefaultModelObject();

            item.add(new WallItemCommentPanel("wallItemCommentPanel", comment));
        }

    };
    wallItemCommentsListView.setOutputMarkupId(true);
    add(wallItemCommentsListView);

}

From source file:ro.nextreports.server.web.dashboard.DashboardNavigationPanel.java

License:Apache License

public DashboardNavigationPanel(String id) {
    super(id);//from  w w  w  . j av a  2s  .  c  o  m

    setOutputMarkupPlaceholderTag(true);

    addToolbar();

    WebMarkupContainer container = new WebMarkupContainer("navigation");
    ListView<Object> listView = new ListView<Object>("dashboardList", new DashboardsAndLinksModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<Object> item) {
            Tab tab = new Tab("dashboard", item.getModel(), item.getIndex());
            item.add(tab);

            //                item.add(new WiQueryEventBehavior(new Event(MouseEvent.MOUSEOVER) {
            //
            //                    private static final long serialVersionUID = 1L;
            //
            //                    @Override
            //                    public JsScope callback() {
            //                        return JsScope.quickScope("$(this).find('.actions-col').show()");
            //                    }
            //
            //                }));
            //                item.add(new WiQueryEventBehavior(new Event(MouseEvent.MOUSEOUT) {
            //
            //                    private static final long serialVersionUID = 1L;
            //
            //                    @Override
            //                    public JsScope callback() {
            //                        return JsScope.quickScope("$(this).find('.actions-col').hide()");
            //                    }
            //
            //                }));

            item.add(new DashboardActionPanel("actions", item.getModel()));

            // TODO getId, setId -> Identifiable
            Object object = item.getModelObject();
            String dashboardId = getDashboardId(object);
            if (getSelectedDashboardId().equals(dashboardId)) {
                item.add(AttributeModifier.append("class", "selected"));
            }
            item.setOutputMarkupId(true);
        }

    };
    listView.setOutputMarkupId(true);

    container.add(listView);
    add(container);

    // we select default dashboard only at first login, then we may select other dashboard
    // and we want that dashboard to remain selected when we move between UI tabs
    SectionContext sectionContext = NextServerSession.get().getSectionContext(DashboardSection.ID);
    boolean found = false;
    if (sectionContext.getData().get(SectionContextConstants.SELECTED_DASHBOARD_ID) == null) {

        String dashboardId = "";
        try {
            dashboardId = dashboardService.getDefaultDashboardId();
        } catch (Exception ex) {
            // at first startup (no data folder) and getDefaultDashboardId() is called before 'My' dashboard is created
            // see getMyDashboards() from default dashboard service
            LOG.error("Get default dashboard : " + ex.getMessage(), ex);
        }
        if (!"".equals(dashboardId)) {
            for (Object obj : listView.getModelObject()) {
                if (obj instanceof Dashboard) {
                    if (dashboardId.equals(((Dashboard) obj).getId())) {
                        found = true;
                    }
                } else {
                    if (dashboardId.equals(((Link) obj).getReference())) {
                        found = true;
                    }
                }
                if (found) {
                    sectionContext.getData().put(SectionContextConstants.SELECTED_DASHBOARD_ID, dashboardId);
                    break;
                }
            }
            if (!found) {
                sectionContext.getData().put(SectionContextConstants.SELECTED_DASHBOARD_ID,
                        dashboardService.getMyDashboards().get(0).getId());
            }
        }

    }
}

From source file:se.inera.axel.shs.broker.webconsole.product.ProductFormPanel.java

License:Open Source License

@SuppressWarnings("rawtypes")
protected ListView getReplyDataListView(final IModel<ShsProduct> product) {
    ListView lvReply = new PropertyListView("replyData") {
        @Override//from   w ww.j a  va  2 s . c  om
        protected void populateItem(final ListItem item) {
            item.add(new TextField("datapartType"));
            item.add(new TextField("dataType"));
            item.add(new TextField("description"));
            item.add(new TextField("maxOccurs"));
            item.add(new TextField("minOccurs"));
            item.add(new TextField("mime.type"));
            item.add(new TextField("mime.subtype"));
            item.add(new TextField("mime.textCharset"));
            item.add(new TextField("mime.transferEncoding"));
            item.add(new Link<Void>("delete") {
                @Override
                public void onClick() {
                    product.getObject().getReplyData().remove(item.getIndex());
                }

                private static final long serialVersionUID = 1L;
            }.setOutputMarkupId(true));
        }

        private static final long serialVersionUID = 1L;
    };
    lvReply.setReuseItems(true);
    lvReply.setOutputMarkupId(true);
    return lvReply;
}

From source file:se.inera.axel.shs.broker.webconsole.product.ProductFormPanel.java

License:Open Source License

@SuppressWarnings("rawtypes")
protected ListView getDataListView(final IModel<ShsProduct> product) {
    ListView lv = new PropertyListView("data") {
        @Override/* w w w. ja  v a  2  s .  c o m*/
        protected void populateItem(final ListItem item) {
            item.add(new TextField("datapartType"));
            item.add(new TextField("dataType"));
            item.add(new TextField("description"));
            item.add(new TextField("maxOccurs"));
            item.add(new TextField("minOccurs"));
            item.add(new TextField("mime.type"));
            item.add(new TextField("mime.subtype"));
            item.add(new TextField("mime.textCharset"));
            item.add(new TextField("mime.transferEncoding"));
            item.add(new Link<Void>("delete") {
                @Override
                public void onClick() {
                    product.getObject().getData().remove(item.getIndex());
                }

                private static final long serialVersionUID = 1L;
            }.setOutputMarkupId(true));
        }

        private static final long serialVersionUID = 1L;
    };
    lv.setReuseItems(true);
    lv.setOutputMarkupId(true);
    return lv;
}