Example usage for org.apache.wicket.request.mapper.parameter PageParameters getPosition

List of usage examples for org.apache.wicket.request.mapper.parameter PageParameters getPosition

Introduction

In this page you can find the example usage for org.apache.wicket.request.mapper.parameter PageParameters getPosition.

Prototype

@Override
    public int getPosition(final String name) 

Source Link

Usage

From source file:com.comcast.cdn.traffic_control.traffic_monitor.publish.CrConfig.java

License:Apache License

/**
 * Send out the xml!!!!//from   w w  w. ja  va 2  s .  com
 */
@Override
public final void renderPage() {
    final PageParameters pageParameters = this.getPageParameters();
    if (pageParameters != null && pageParameters.getPosition("json") != -1) {
        getResponse().write(crConfigJsonStr);
        return;
    }
    getResponse().write(crConfigStr);
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.publish.CrStates.java

License:Apache License

/**
 * Send out the json!!!!// ww w. j  a v a 2s.co m
 */
@Override
public JSONObject getJson(final PageParameters pp) throws JSONException {
    if (myPeerWatcher == null) {
        return null;
    }
    boolean raw = true;
    final MonitorConfig config = ConfigHandler.getConfig();
    final RouterConfig crConfig = RouterConfig.getCrConfig();
    if (crConfig == null || myCacheWatcher.getCycleCount() < config.getStartupMinCycles()) {
        return null;
    }
    if (pp == null || pp.getPosition("raw") == -1) {
        final WebRequest req = (WebRequest) RequestCycle.get().getRequest();
        final HttpServletRequest httpReq = (HttpServletRequest) req.getContainerRequest();
        clientIps.put(httpReq.getRemoteHost(), new Long(System.currentTimeMillis()));
        raw = false;
    }
    final JSONObject o = new JSONObject();
    o.put("caches", getCrStates(crConfig, raw));
    if (ConfigHandler.getConfig().getPublishDsStates()) {
        o.put("deliveryServices", getDsStates(crConfig));
    }
    return o;
}

From source file:com.evolveum.midpoint.gui.impl.page.admin.configuration.component.ObjectPolicyConfigurationTabPanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();

    PageParameters params = getPage().getPageParameters();
    StringValue val = params.get(PageSystemConfiguration.SELECTED_TAB_INDEX);
    if (val != null && !val.isNull()) {
        params.remove(params.getPosition(PageSystemConfiguration.SELECTED_TAB_INDEX));
    }//www.j a  v a 2 s.co m
    params.set(PageSystemConfiguration.SELECTED_TAB_INDEX,
            PageSystemConfiguration.CONFIGURATION_TAB_OBJECT_POLICY);

    initLayout();
}

From source file:com.evolveum.midpoint.web.util.NewWindowNotifyingBehavior.java

License:Apache License

@Override
protected void onNewWindow(AjaxRequestTarget target) {
    LOG.debug("Page version already used in different tab, refreshing page");
    WebPage page = (WebPage) getComponent();
    //fix for MID-4649; windowName parameter causes recursive reloading of the page
    PageParameters pageParameters = page.getPageParameters();
    if (pageParameters != null && pageParameters.getPosition("windowName") > -1) {
        pageParameters = pageParameters.remove("windowName");
    }//  w  w w . java  2 s .c o m
    page.setResponsePage(page.getPageClass(), pageParameters);
}

From source file:org.wuqispank.web.BookmarkableTabbedPanel2.java

License:Apache License

/**
 * Using this constructor the following defaults take effect:
 * <ul>/*from   w w  w  .j  av  a  2 s .com*/
 * <li>tabParameterName = component id</li>
 * <li>defaultTabIndex = 0</li>
 * </ul>
 * 
 * @param id
 *            component id
 * @param tabs
 *            list of ITab objects used to represent tabs
 * @param pageParameters
 *            Container for parameters to a requested page. A parameter for the selected tab
 *            will be inserted.
 */
public BookmarkableTabbedPanel2(String id, List<ITab> tabs, PageParameters pageParameters) {
    super(id, tabs);
    this.pageParameters = pageParameters;
    tabParameterName = "tab";
    if (pageParameters.getPosition(tabParameterName) >= 0) {
        String tab = pageParameters.get(tabParameterName).toString();
        try {
            int tabIndex = Integer.parseInt(tab);
            if (tabIndex >= 0 && tabIndex < tabs.size()) {
                setSelectedTab(tabIndex);
            } else {
                setSelectedTab(defaultTabIndex);
            }

        } catch (NumberFormatException e) {
            setSelectedTab(defaultTabIndex);
        }
    } else
        setSelectedTab(defaultTabIndex);
}

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

License:Apache License

public WidgetWebPage(PageParameters pageParameters) {

    IFrameSettings iframeSettings = storageService.getSettings().getIframe();
    if ((iframeSettings == null)
            || (iframeSettings.isUseAuthentication() && (SecurityUtil.getLoggedUser() == null))) {
        add(new WidgetErrorView("widget", null,
                new Exception("You are not allowed to see iframe if you are not logged!")));
        return;//  w  ww  . j ava  2 s.c o m
    }

    // TODO test for id parameter
    String widgetId = pageParameters.get("id").toString();
    //System.out.println("################### widgetId = " + widgetId);

    if (iframeSettings.isUseAuthentication()) {
        try {
            String dashboardId = storageService.getDashboardId(widgetId);
            String user = SecurityUtil.getLoggedUsername();
            String owner = dashboardService.getDashboardOwner(dashboardId);
            if (!owner.equals(user)) {
                boolean hasRead = securityService.hasPermissionsById(user, PermissionUtil.getRead(),
                        dashboardId);
                if (!hasRead) {
                    add(new WidgetErrorView("widget", null,
                            new Exception("You do not have rights to see this iframe!")));
                    return;
                }
            }
        } catch (NotFoundException e) {
            add(new WidgetErrorView("widget", null, new Exception("Could not load iframe: " + e.getMessage())));
            return;
        }
    }

    String width = pageParameters.get("width").toString();
    //System.out.println("width = " + width);

    String height = pageParameters.get("height").toString();
    //System.out.println("height = " + height);

    // parameters are added to embedded code url like 
    //     $P{Project}=[1,2,3] (for plain text) or
    //     P=<encrypted text> where <encrypted text> is an encryption of a string like $P{Project}=[1,2,3]&$P{Client}=John
    //     
    // multiple values are between brackets
    Map<String, Object> urlQueryParamaters = ChartUtil.getUrlQueryParameters(pageParameters,
            iframeSettings.getEncryptionKey());

    // special iframe parameters 
    // tableFontSize : to allow bigger fonts on iframe tables when using a wall-monitor
    // tableCellPadding : if font size is increased, cell padding must be increased
    // adjustableTextFontSize : to allow fonts in iframe charts to be scaled and not to have a fixed size like in server dashboards
    if (pageParameters.getPosition("tableFontSize") != -1) {
        String tableFontSize = pageParameters.get("tableFontSize").toString();
        urlQueryParamaters.put("tableFontSize", tableFontSize);
    }
    if (pageParameters.getPosition("tableCellPadding") != -1) {
        String tableCellPadding = pageParameters.get("tableCellPadding").toString();
        urlQueryParamaters.put("tableCellPadding", tableCellPadding);
    }
    if (pageParameters.getPosition("adjustableTextFontSize") != -1) {
        String adjustTextFontSize = pageParameters.get("adjustableTextFontSize").toString();
        urlQueryParamaters.put("adjustableTextFontSize", Boolean.parseBoolean(adjustTextFontSize));
    }

    WidgetModel widgetModel = new WidgetModel(widgetId);
    if (widgetModel.getObject() == null) {
        // widget was deleted
        add(new WidgetErrorView("widget", widgetModel, new Exception("Widget was deleted from server!")));
    } else {
        if ((width == null) || (height == null)) {
            add(widgetModel.getObject().createView("widget", false, urlQueryParamaters));
        } else {
            add(widgetModel.getObject().createView("widget", width, height, urlQueryParamaters));
        }
    }
}