Search in sources :

Example 16 with IHeaderResponse

use of org.apache.wicket.markup.head.IHeaderResponse in project wicket by apache.

the class DecoratingHeaderResponseTest method decoratedStringPrepend.

/**
 * Basic IHeaderResponseDecorator, just prepending the DECORATED string to resource name.
 *
 * @throws IOException
 * @throws ResourceStreamNotFoundException
 * @throws ParseException
 */
@Test
public void decoratedStringPrepend() throws IOException, ResourceStreamNotFoundException, ParseException {
    tester.getApplication().setHeaderResponseDecorator(new IHeaderResponseDecorator() {

        @Override
        public IHeaderResponse decorate(IHeaderResponse response) {
            return new ResourceAggregator(new DecoratingHeaderResponse(response) {

                @Override
                public void render(HeaderItem item) {
                    if (item instanceof JavaScriptReferenceHeaderItem) {
                        JavaScriptReferenceHeaderItem original = (JavaScriptReferenceHeaderItem) item;
                        item = JavaScriptHeaderItem.forReference(new PackageResourceReference("DECORATED-" + original.getReference().getName()), original.getId());
                    }
                    super.render(item);
                }
            });
        }
    });
    tester.startPage(TestPage.class);
    XmlPullParser parser = new XmlPullParser();
    parser.parse(tester.getLastResponseAsString());
    XmlTag tag = parser.nextTag();
    boolean isDecorated = false;
    do {
        if (tag.isOpen() && "script".equals(tag.getName())) {
            isDecorated = tag.getAttribute("src").toString().contains("DECORATED");
            if (!isDecorated) {
                fail();
            }
            break;
        }
    } while ((tag = parser.nextTag()) != null);
    assertTrue(isDecorated);
}
Also used : JavaScriptReferenceHeaderItem(org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) XmlPullParser(org.apache.wicket.markup.parser.XmlPullParser) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) ResourceAggregator(org.apache.wicket.markup.head.ResourceAggregator) HeaderItem(org.apache.wicket.markup.head.HeaderItem) JavaScriptHeaderItem(org.apache.wicket.markup.head.JavaScriptHeaderItem) JavaScriptReferenceHeaderItem(org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem) XmlTag(org.apache.wicket.markup.parser.XmlTag) Test(org.junit.Test)

Example 17 with IHeaderResponse

use of org.apache.wicket.markup.head.IHeaderResponse in project openmeetings by apache.

the class MainPanel method onInitialize.

@Override
protected void onInitialize() {
    menu = new MenuPanel("menu", getMainMenu());
    add(topControls.setOutputMarkupPlaceholderTag(true).setMarkupId("topControls"));
    add(contents.add(getClient() == null || panel == null ? EMPTY : panel).setOutputMarkupId(true).setMarkupId("contents"));
    topControls.add(menu.setVisible(false), topLinks.setVisible(false).setOutputMarkupPlaceholderTag(true).setMarkupId("topLinks"));
    topLinks.add(new AjaxLink<Void>("messages") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            updateContents(PROFILE_MESSAGES, target);
        }
    });
    topLinks.add(new AjaxLink<Void>("profile") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            updateContents(PROFILE_EDIT, target);
        }
    });
    final AboutDialog about = new AboutDialog("aboutDialog");
    topLinks.add(new AjaxLink<Void>("about") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            about.open(target);
        }
    });
    if (getApplication().getDebugSettings().isDevelopmentUtilitiesEnabled()) {
        add(new DebugBar("dev").setOutputMarkupId(true));
    } else {
        add(new EmptyPanel("dev").setVisible(false));
    }
    add(new OmAjaxClientInfoBehavior());
    add(about, chat = new ChatPanel("chatPanel"));
    add(newMessage = new MessageDialog("newMessageDialog", new CompoundPropertyModel<>(new PrivateMessage())) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
            BasePanel bp = getCurrentPanel();
            if (send.equals(button) && bp != null) {
                bp.onNewMessageClose(handler);
            }
        }
    });
    add(userInfo = new UserInfoDialog("userInfoDialog", newMessage));
    add(new AbstractDefaultAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void respond(AjaxRequestTarget target) {
            userInfo.open(target, getParam(getComponent(), PARAM_USER_ID).toLong());
        }

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            super.renderHead(component, response);
            response.render(new PriorityHeaderItem(getNamedFunction("showUserInfo", this, explicit(PARAM_USER_ID))));
        }
    });
    add(new AbstractDefaultAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void respond(AjaxRequestTarget target) {
            ContactsHelper.addUserToContactList(getParam(getComponent(), PARAM_USER_ID).toLong());
        }

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            super.renderHead(component, response);
            response.render(new PriorityHeaderItem(getNamedFunction("addContact", this, explicit(PARAM_USER_ID))));
        }
    });
    add(new AbstractDefaultAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void respond(AjaxRequestTarget target) {
            newMessage.reset(true).open(target, getParam(getComponent(), PARAM_USER_ID).toOptionalLong());
        }

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            super.renderHead(component, response);
            response.render(new PriorityHeaderItem(getNamedFunction("privateMessage", this, explicit(PARAM_USER_ID))));
        }
    });
    add(inviteUser = new InviteUserToRoomDialog("invite-to-room"));
    add(new AbstractDefaultAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void respond(AjaxRequestTarget target) {
            inviteUser.open(target, getParam(getComponent(), PARAM_USER_ID).toLong());
        }

        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            super.renderHead(component, response);
            response.render(new PriorityHeaderItem(getNamedFunction("inviteUser", this, explicit(PARAM_USER_ID))));
        }
    });
    topLinks.add(new ConfirmableAjaxBorder("logout", getString("310"), getString("634")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            getSession().invalidate();
            setResponsePage(Application.get().getSignInPageClass());
        }
    });
    super.onInitialize();
}
Also used : DebugBar(org.apache.wicket.devutils.debugbar.DebugBar) DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) AboutDialog(org.apache.openmeetings.web.user.AboutDialog) EmptyPanel(org.apache.wicket.markup.html.panel.EmptyPanel) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) ChatPanel(org.apache.openmeetings.web.user.chat.ChatPanel) InviteUserToRoomDialog(org.apache.openmeetings.web.user.InviteUserToRoomDialog) MenuPanel(org.apache.openmeetings.web.common.menu.MenuPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserInfoDialog(org.apache.openmeetings.web.user.UserInfoDialog) PriorityHeaderItem(org.apache.wicket.markup.head.PriorityHeaderItem) AbstractDefaultAjaxBehavior(org.apache.wicket.ajax.AbstractDefaultAjaxBehavior) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) MessageDialog(org.apache.openmeetings.web.user.MessageDialog) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage) Component(org.apache.wicket.Component)

Aggregations

IHeaderResponse (org.apache.wicket.markup.head.IHeaderResponse)17 Component (org.apache.wicket.Component)9 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 Behavior (org.apache.wicket.behavior.Behavior)5 StringResponse (org.apache.wicket.response.StringResponse)5 Response (org.apache.wicket.request.Response)4 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)2 OrgTreeProvider (com.evolveum.midpoint.web.page.admin.users.component.OrgTreeProvider)2 TreeStateSet (com.evolveum.midpoint.web.page.admin.users.dto.TreeStateSet)2 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)2 ArrayList (java.util.ArrayList)2 MarkupContainer (org.apache.wicket.MarkupContainer)2 AbstractDefaultAjaxBehavior (org.apache.wicket.ajax.AbstractDefaultAjaxBehavior)2 ISortableTreeProvider (org.apache.wicket.extensions.markup.html.repeater.tree.ISortableTreeProvider)2 WindowsTheme (org.apache.wicket.extensions.markup.html.repeater.tree.theme.WindowsTheme)2 HeaderItem (org.apache.wicket.markup.head.HeaderItem)2 HeaderResponse (org.apache.wicket.markup.head.internal.HeaderResponse)2 Label (org.apache.wicket.markup.html.basic.Label)2 ReuseIfModelsEqualStrategy (org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy)2