Example usage for org.apache.wicket WicketRuntimeException WicketRuntimeException

List of usage examples for org.apache.wicket WicketRuntimeException WicketRuntimeException

Introduction

In this page you can find the example usage for org.apache.wicket WicketRuntimeException WicketRuntimeException.

Prototype

public WicketRuntimeException(final Throwable cause) 

Source Link

Usage

From source file:at.ac.tuwien.ifs.tita.reporting.JasperResource.java

License:Apache License

/**
 * Returns the generated resource./*from   ww  w  .ja v a2 s  .  c  om*/
 * 
 * @see org.apache.wicket.markup.html.DynamicWebResource#getResourceState()
 * @return resource as ResourceState
 */
@Override
protected ResourceState getResourceState() {
    ByteArrayOutputStream os = null;
    try {
        JasperPrint printer = createJasperPrint();
        JRAbstractExporter exporter = createExporter();

        os = new ByteArrayOutputStream();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, printer);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);

        exporter.exportReport();
    } catch (JRException e) {
        throw new WicketRuntimeException(e);
    }

    final byte[] data = os.toByteArray();
    return new ResourceState() {
        @Override
        public String getContentType() {
            return getFileExtension();
        }

        @Override
        public byte[] getData() {
            return data;
        }

        @Override
        public int getLength() {
            return data.length;
        }
    };
}

From source file:at.ac.tuwien.ifs.tita.ui.BasePage.java

License:Apache License

/**
 * Allows subclasses to specify which context should be used when logging
 * off.//from   w  w w .j av  a  2s.c o  m
 * 
 * @return the context
 */
protected final LoginContext getLogoffContext() {
    Application app = Application.get();
    if (app instanceof TiTAApplication) {
        return ((TiTAApplication) app).getLogoffContext();
    }
    throw new WicketRuntimeException("Application is not a subclass of " + TiTAApplication.class);
}

From source file:at.ac.tuwien.ifs.tita.ui.TiTAApplication.java

License:Apache License

/**
 * {@inheritDoc}/*from www  . j a  v  a  2  s. c om*/
 */
@Override
protected void setUpHive() {
    PolicyFileHiveFactory factory = new SwarmPolicyFileHiveFactory(getActionFactory());

    try {
        factory.addPolicyFile(getServletContext().getResource("/WEB-INF/tita.hive"));
        factory.setAlias("hp", "at.ac.tuwien.ifs.tita.ui.BasePage");

        // Aliases for Admin
        factory.setAlias("userAdministration",
                "at.ac.tuwien.ifs.tita.ui.administration.user.UserAdministrationPage");
        factory.setAlias("projectAdministration",
                "at.ac.tuwien.ifs.tita.ui.administration.project.ProjectAdministrationPage");

        // Aliases for timeconsumer
        factory.setAlias("effortsPage", "at.ac.tuwien.ifs.tita.ui.startpages.EffortsPage");
        factory.setAlias("dailyView", "at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.DailyViewPage");
        factory.setAlias("monthlyView", "at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.MonthlyViewPage");
        factory.setAlias("effortImportCSV",
                "at.ac.tuwien.ifs.tita.ui.importing.effort.csv.EffortImportCSVPage");

        // Aliases for timecontroller
        factory.setAlias("projectsPage", "at.ac.tuwien.ifs.tita.ui.startpages" + ".ProjectsPage");
        factory.setAlias("multipleProjectsView",
                "at.ac.tuwien.ifs.tita.ui.evaluation" + ".timecontroller.MultipleProjectsView");
        factory.setAlias("targetActualView",
                "at.ac.tuwien.ifs.tita.ui.evaluation" + ".timecontroller.TargetActualView");

        factory.setAlias("performanceOfPersonView",
                "at.ac.tuwien.ifs.tita.ui.evaluation" + ".timecontroller.PerformanceOfPersonView");

        // Aliases for admin
        factory.setAlias("adminPage", "at.ac.tuwien.ifs.tita.ui.startpages" + ".AdminPage");

    } catch (MalformedURLException e) {
        throw new WicketRuntimeException(e);
    }

    // register factory
    HiveMind.registerHive(getHiveKey(), factory);

}

From source file:at.molindo.esi4j.example.web.WicketApplication.java

License:Apache License

public static WicketApplication get() {
    Application application = Application.get();

    if (application instanceof WicketApplication == false) {
        throw new WicketRuntimeException("The application attached to the current thread is not a "
                + WicketApplication.class.getSimpleName());
    }//  www  . j a va  2  s . co  m

    return (WicketApplication) application;
}

From source file:at.molindo.wicketutils.migration.ex.AbortException.java

License:Apache License

public AbortException() {
    super(null, true);
    throw new WicketRuntimeException("not implemented");
}

From source file:at.molindo.wicketutils.migration.ex.MigrationExceptionHandler.java

License:Apache License

@Override
public IRequestHandler onException(RequestCycle cycle, Exception ex) {
    if (ex instanceof AbortException) {
        throw new WicketRuntimeException("not implemented");
    }/*from   ww  w  . ja v  a 2s  . c om*/
    return null;

}

From source file:at.molindo.wicketutils.utils.MockRenderCallback.java

License:Apache License

@Override
public final String call() {
    // add component to mock page
    MockRenderPage page = new MockRenderPage();
    Component component = newComponent("mock");
    page.add(component);//from   w  w  w.ja  v a 2 s. c o  m

    // render page
    page.renderPage();

    if (isFailOnStatefulPages() && !page.isPageStateless()) {
        throw new WicketRuntimeException("no stateful components allowed");
    }

    // close response and get output
    WicketUtils.getWebResponse().close();
    return ((MockHttpServletResponse) WicketUtils.getServletWebResponse().getContainerResponse()).getDocument();
}

From source file:at.molindo.wicketutils.utils.PageSpec.java

License:Apache License

public void setAsResponsePage(boolean redirect) {

    RequestCycle rc = RequestCycle.get();
    if (rc == null) {
        throw new WicketRuntimeException("no request cycle available");
    }//from  www.ja  v a  2s  .  c  om
    setAsResponsePage(rc, redirect);
}

From source file:au.org.theark.core.web.component.tabbedPanel.DynamicTabbedPanel.java

License:Open Source License

/**
 * sets the selected tab//  w  w  w.j  a va 2s.c  om
 * 
 * @param index
 *           index of the tab to select
 * @return this for chaining
 */
public DynamicTabbedPanel setSelectedTab(final int index) {
    if ((index < 0) || ((index >= tabModel.getObject().size()) && (index > 0))) {
        throw new IndexOutOfBoundsException();
    }

    setDefaultModelObject(index);

    final Component component;

    if ((tabModel.getObject().size() == 0) || !isTabVisible(index)) {
        // no tabs or the currently selected tab is not visible
        component = new EmptyPanel(TAB_PANEL_ID);
    } else {
        // show panel from selected tab
        ITab tab = tabModel.getObject().get(index);
        component = tab.getPanel(TAB_PANEL_ID);
        if (component == null) {
            throw new WicketRuntimeException("ITab.getPanel() returned null. TabbedPanel [" + getPath()
                    + "] ITab index [" + index + "]");
        }
    }

    if (!component.getId().equals(TAB_PANEL_ID)) {
        throw new WicketRuntimeException("ITab.getPanel() returned a panel with invalid id ["
                + component.getId()
                + "]. You must always return a panel with id equal to the provided panelId parameter. TabbedPanel ["
                + getPath() + "] ITab index [" + index + "]");
    }

    addOrReplace(component);

    return this;
}

From source file:br.com.digilabs.wicket.component.meiomask.MeioMaskField.java

License:Apache License

private void initMaskField(MaskType mask, String options) {
    try {/*from  w ww  .j  a  va  2 s  . c  o  m*/
        maskFormatter.setMask(mask.getMask());
        maskFormatter.setValueClass(String.class);
        maskFormatter.setAllowsInvalid(true);
        maskFormatter.setValueContainsLiteralCharacters(false);
    } catch (ParseException parseException) {
        throw new WicketRuntimeException(parseException);
    }

    add(new MeioMaskBehavior(mask, options));
    setOutputMarkupId(true);
}