use of org.apache.wicket.WicketRuntimeException in project wiquery by WiQuery.
the class AutocompleteComponent method onBeforeRenderAutocomplete.
@Override
protected void onBeforeRenderAutocomplete(Autocomplete<?> autocomplete) {
StringWriter sw = new StringWriter();
try {
JsonGenerator gen = new JsonFactory().createGenerator(sw);
List<Object> json = new ArrayList<Object>();
T defaultValue = AutocompleteComponent.this.getModelObject();
AutocompleteJson value = null;
Integer index = 0;
for (T obj : AutocompleteComponent.this.list.getObject()) {
index++;
value = newAutocompleteJson(index, obj);
json.add(value);
if (obj.equals(defaultValue)) {
autocomplete.setDefaultModelObject(value.getLabel());
getAutocompleteHidden().setModelObject(value.getValueId());
}
}
new ObjectMapper().writeValue(gen, json);
} catch (IOException e) {
throw new WicketRuntimeException(e);
}
autocomplete.getOptions().put("source", sw.toString());
}
use of org.apache.wicket.WicketRuntimeException in project gitblit by gitblit.
the class PluginClassResolver method getResources.
protected Iterator<URL> getResources(String name, PluginWrapper plugin) {
HashSet<URL> loadedFiles = new HashSet<URL>();
try {
// Try the classloader for the wicket jar/bundle
Enumeration<URL> resources = plugin.getPluginClassLoader().getResources(name);
loadResources(resources, loadedFiles);
} catch (IOException e) {
throw new WicketRuntimeException(e);
}
return loadedFiles.iterator();
}
use of org.apache.wicket.WicketRuntimeException in project gitblit by gitblit.
the class FreemarkerPanel method getMarkupResourceStream.
/**
* @see org.apache.wicket.markup.IMarkupResourceStreamProvider#getMarkupResourceStream(org.apache
* .wicket.MarkupContainer, java.lang.Class)
*/
@Override
public final IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) {
Template template = getTemplate();
if (template == null) {
throw new WicketRuntimeException("could not find Freemarker template for panel: " + this);
}
// evaluate the template and return a new StringResourceStream
StringBuffer sb = new StringBuffer();
sb.append("<wicket:panel>");
sb.append(evaluateFreemarkerTemplate(template));
sb.append("</wicket:panel>");
return new StringResourceStream(sb.toString());
}
use of org.apache.wicket.WicketRuntimeException in project midpoint by Evolveum.
the class TabbedPanel method setCurrentTab.
private void setCurrentTab(int index) {
if (this.currentTab == index) {
// already current
return;
}
this.currentTab = index;
final Component component;
if (currentTab == -1 || (tabs.getObject().size() == 0) || !getVisiblityCache().isVisible(currentTab)) {
// no tabs or the current tab is not visible
component = newPanel();
} else {
// show panel from selected tab
T tab = tabs.getObject().get(currentTab);
component = tab.getPanel(TAB_PANEL_ID);
if (component == null) {
throw new WicketRuntimeException("ITab.getPanel() returned null. TabbedPanel [" + getPath() + "] ITab index [" + currentTab + "]");
}
}
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 [" + currentTab + "]");
}
addOrReplace(component);
}
Aggregations