Search in sources :

Example 51 with Page

use of org.apache.wicket.Page in project ocvn by devgateway.

the class BasePage method newLanguageMenu.

public NavbarDropDownButton newLanguageMenu() {
    final NavbarDropDownButton languageDropDown = new NavbarDropDownButton(new StringResourceModel("navbar.lang", this, null)) {

        private static final long serialVersionUID = 319842753824102674L;

        @Override
        protected List<AbstractLink> newSubMenuButtons(final String buttonMarkupId) {
            final List<AbstractLink> list = new ArrayList<>();
            for (final Locale l : WebConstants.AVAILABLE_LOCALES) {
                final PageParameters params = new PageParameters(BasePage.this.getPageParameters());
                params.set(WebConstants.LANGUAGE_PARAM, l.getLanguage());
                list.add(new MenuBookmarkablePageLink<Page>(BasePage.this.getPageClass(), params, Model.of(l.getDisplayName())));
            }
            return list;
        }
    };
    languageDropDown.setIconType(GlyphIconType.flag);
    return languageDropDown;
}
Also used : NavbarDropDownButton(de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarDropDownButton) Locale(java.util.Locale) ArrayList(java.util.ArrayList) Page(org.apache.wicket.Page) EditUserPage(org.devgateway.toolkit.forms.wicket.page.user.EditUserPage) VietnamImportPage(org.devgateway.ocvn.forms.wicket.page.VietnamImportPage) ListGroupPage(org.devgateway.toolkit.forms.wicket.page.lists.ListGroupPage) RedirectPage(org.apache.wicket.markup.html.pages.RedirectPage) GenericWebPage(org.apache.wicket.markup.html.GenericWebPage) ListAllDashboardsPage(org.devgateway.ocds.forms.wicket.page.list.ListAllDashboardsPage) LogoutPage(org.devgateway.toolkit.forms.wicket.page.user.LogoutPage) ListMyDashboardsPage(org.devgateway.ocds.forms.wicket.page.list.ListMyDashboardsPage) ListUserPage(org.devgateway.toolkit.forms.wicket.page.lists.ListUserPage) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 52 with Page

use of org.apache.wicket.Page in project wicket by apache.

the class ConversationPropagator method onRequestHandlerResolved.

@Override
public void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler) {
    String cid = cycle.getRequest().getRequestParameters().getParameterValue(CID).toString();
    Page page = getPage(handler);
    if (cid == null && page != null) {
        cid = page.getMetaData(CID_KEY);
    }
    Conversation current = getConversation(cycle);
    if (current != null && !Objects.isEqual(current.getId(), cid)) {
        logger.info("Conversation {} has expired for {}", cid, page);
        throw new ConversationExpiredException(null, cid, page, handler);
    }
    activateConversationIfNeeded(cycle, handler, cid);
}
Also used : Page(org.apache.wicket.Page) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) Conversation(javax.enterprise.context.Conversation)

Example 53 with Page

use of org.apache.wicket.Page in project wicket by apache.

the class ConversationPropagator method onRequestHandlerExecuted.

@Override
public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler) {
    Conversation conversation = getConversation(cycle);
    if (conversation == null) {
        return;
    }
    Page page = getPage(handler);
    if (page == null) {
        return;
    }
    // apply auto semantics
    autoEndIfNecessary(page, handler, conversation);
    autoBeginIfNecessary(page, handler, conversation);
    if (propagation.propagatesViaPage(page, handler)) {
        // propagate a conversation across non-bookmarkable page instances
        setConversationOnPage(conversation, page);
    }
}
Also used : Conversation(javax.enterprise.context.Conversation) Page(org.apache.wicket.Page) IRequestablePage(org.apache.wicket.request.component.IRequestablePage)

Example 54 with Page

use of org.apache.wicket.Page in project wicket by apache.

the class Form method getRootFormRelativeId.

/**
 * Utility method to assemble an id to distinct form components from different nesting levels.
 * Useful to generate input names attributes.
 *
 * @param component
 * @return form relative identification string
 */
public static String getRootFormRelativeId(Component component) {
    String id = component.getId();
    final PrependingStringBuffer inputName = new PrependingStringBuffer(id.length());
    Component c = component;
    while (true) {
        inputName.prepend(id);
        c = c.getParent();
        if (c == null || (c instanceof Form<?> && ((Form<?>) c).isRootForm()) || c instanceof Page) {
            break;
        }
        inputName.prepend(Component.PATH_SEPARATOR);
        id = c.getId();
    }
    /*
		 * Certain input names causes problems with JavaScript. If the input name would cause a
		 * problem, we create a replacement unique name by prefixing the name with a path that would
		 * otherwise never be used (blank id in path).
		 * 
		 * Input names must start with [A-Za-z] according to HTML 4.01 spec. HTML 5 allows almost
		 * anything.
		 */
    if (JavaScriptReservedNames.isNameReserved(inputName.toString())) {
        inputName.prepend(Component.PATH_SEPARATOR);
        inputName.prepend(Component.PATH_SEPARATOR);
        inputName.prepend("p");
    }
    return inputName.toString();
}
Also used : Page(org.apache.wicket.Page) Component(org.apache.wicket.Component) IGenericComponent(org.apache.wicket.IGenericComponent) PrependingStringBuffer(org.apache.wicket.util.string.PrependingStringBuffer)

Example 55 with Page

use of org.apache.wicket.Page in project wicket by apache.

the class CheckBoxMultipleChoice method setSuffix.

/**
 * @param suffix
 *            Separator to use between radio options
 * @return this
 */
public final CheckBoxMultipleChoice<T> setSuffix(final String suffix) {
    // Tell the page that this component's suffix was changed
    final Page page = findPage();
    if (page != null) {
        addStateChange();
    }
    this.suffix = suffix;
    return this;
}
Also used : Page(org.apache.wicket.Page)

Aggregations

Page (org.apache.wicket.Page)94 Test (org.junit.Test)50 WebPage (org.apache.wicket.markup.html.WebPage)22 Component (org.apache.wicket.Component)11 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)7 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)7 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)6 IRequestHandler (org.apache.wicket.request.IRequestHandler)6 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)6 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 PageProvider (org.apache.wicket.core.request.handler.PageProvider)5 IMarkupFragment (org.apache.wicket.markup.IMarkupFragment)5 DummyPage (org.apache.wicket.resource.DummyPage)5 ArrayList (java.util.ArrayList)4 AbstractAjaxBehavior (org.apache.wicket.behavior.AbstractAjaxBehavior)4 AccessDeniedPage (org.apache.wicket.markup.html.pages.AccessDeniedPage)4 Url (org.apache.wicket.request.Url)4 MockInnerClassPage (org.apache.wicket.util.tester.MockPageParameterPage.MockInnerClassPage)4 SuccessPage (org.apache.wicket.util.tester.apps_1.SuccessPage)4