@SuppressWarnings("unchecked") private TemplateResolver newTemplateResolverImpl(BinderImpl binderImpl, Component comp, String attr, String templateExpr, Map<String, Object> templateArgs) { String clznm = Library.getProperty("org.zkoss.bind.TemplateResolver.class", TemplateResolverImpl.class.getName()); try { Class<TemplateResolver> clz = (Class<TemplateResolver>) Classes.forNameByThread(clznm); Constructor<TemplateResolver> c = clz.getDeclaredConstructor(Binder.class, Component.class, String.class, String.class, Map.class); TemplateResolver resolver = c.newInstance(binderImpl, comp, attr, templateExpr, templateArgs); return resolver; } catch (Exception e) { throw UiException.Aide.wrap(e, "Can't initialize template resolver "); } }
public Object coerceToUi(Object beanProp, org.zkoss.zul.Image imgComp, BindContext ctx) { if (beanProp == null) { return null; } else if (beanProp instanceof org.zkoss.image.Image) { return beanProp; } else if (beanProp instanceof RenderedImage) { RenderedImage awtImg = (RenderedImage) beanProp; try { return Images.encode("a.png", awtImg); } catch (java.io.IOException ex) { throw UiException.Aide.wrap(ex); } } return beanProp; }
protected Object get(Scope scope, String name) { if (scope != null) { final NameSpace bshns = prepareNS(scope); //note: we have to create NameSpace (with prepareNS) //to have the correct chain if (bshns != _bshns) { try { return unwrap(bshns.getVariable(name)); } catch (UtilEvalError ex) { throw UiException.Aide.wrap(ex); } } } return get(name); }
protected boolean contains(Scope scope, String name) { if (scope != null) { final NameSpace bshns = prepareNS(scope); //note: we have to create NameSpace (with prepareNS) //to have the correct chain if (bshns != _bshns) { try { return bshns.getVariable(name) != Primitive.VOID; } catch (UtilEvalError ex) { throw UiException.Aide.wrap(ex); } } } return contains(name); }
private ChartModel createDefaultModel() { if (WAFERMAP.equals(getType())) { return new WaferMapModel(100, 100); } final String klass = DEFAULT_MODEL.get(getType()); if (klass != null) { try { return (ChartModel) Classes.newInstanceByThread(klass); } catch (Exception e) { throw UiException.Aide.wrap(e); } } else { throw new UiException("unknown chart type: " + getType()); } }
public static Validator get(String name) { init(); Validator v = _validators.get(name); if (v == null && name.indexOf('.') > 0) { //might be a class path try { v = (Validator) Classes.newInstanceByThread(name); set(name, v); //assume state-less } catch (Exception e) { throw UiException.Aide.wrap(e); } } return v; } }
/** Returns the result in the JavaScript. * The caller shall send it back and evaluate it at the client (<code>eval(jscode);</code>). * <p>After calling this method, the caller shall not modify the component's state any more. */ public String getResult() { final Desktop desktop = _exec.getDesktop(); try { JSONArray result = ((WebAppCtrl) desktop.getWebApp()).getUiEngine().finishUpdate(_updctx); return new StringBuffer(512).append("zAu.doCmds('").append(desktop.getId()).append("',") .append(result.toString()).append(");").toString(); } catch (Exception ex) { //not possible throw UiException.Aide.wrap(ex); } }
protected Object getRenderer(String name) { Object renderer = RENDERERS.get(name); if (renderer == null && name.indexOf('.') > 0) { //might be a class path try { renderer = Classes.newInstanceByThread(name); RENDERERS.put(name, renderer); //assume renderer is state-less } catch (IllegalAccessException e) { throw UiException.Aide.wrap(e, e.getMessage()); } catch (Exception e) { //ignore } } return renderer; }
/*package*/ DataLoader getDataLoader() { if (_dataLoader == null) { _rod = evalRod(); final String loadercls = Library.getProperty("org.zkoss.zul.grid.DataLoader.class"); try { _dataLoader = _rod && loadercls != null ? (DataLoader) Classes.forNameByThread(loadercls).newInstance() : new GridDataLoader(); } catch (Exception e) { throw UiException.Aide.wrap(e); } _dataLoader.init(this, 0, initRodSize()); } return _dataLoader; }
/* package */DataLoader getDataLoader() { if (_dataLoader == null) { _rod = evalRod(); final String loadercls = Library.getProperty("org.zkoss.zul.listbox.DataLoader.class"); try { _dataLoader = _rod && loadercls != null ? (DataLoader) Classes.forNameByThread(loadercls).newInstance() : new ListboxDataLoader(); } catch (Exception e) { throw UiException.Aide.wrap(e); } _dataLoader.init(this, 0, initRodSize()); } return _dataLoader; }
/** Assigns the value of this member to the specified component. * * <p>Note: this method does nothing if {@link #isEffective} returns false. */ public void assign(Component comp) { if (isEffective(comp)) { try { assign0(comp); } catch (Exception ex) { log.error("Failed to assign " + this + " to " + comp + "\n" + Exceptions.getMessage(ex)); throw UiException.Aide.wrap(ex); } } }
@SuppressWarnings("unchecked") public static BindEvaluatorX createEvaluator(FunctionMapper fnampper) { String clznm = Library.getProperty("org.zkoss.bind.BindEvaluatorX.class"); if (clznm != null) { Class<BindEvaluatorX> clz; try { clz = (Class<BindEvaluatorX>) Classes.forNameByThread(clznm); return clz.getConstructor(FunctionMapper.class).newInstance(fnampper); } catch (Exception e) { UiException.Aide.wrap(e, "Can't initialize BindEvaluatorX"); } } return new BindEvaluatorXImpl(fnampper, org.zkoss.bind.xel.BindXelFactory.class); }
private Object parse(RequestContext reqctx) throws ServletException, IOException { if (_cnt instanceof SourceInfo) try { _cnt = ((SourceInfo) _cnt).parse(reqctx); } catch (IOException ex) { throw ex; } catch (ServletException ex) { throw ex; } catch (Exception ex) { throw UiException.Aide.wrap(ex); } return _cnt; } }
/** Instantiates a server push of the given class. * <p>Default: creates an instance of klass by use of its no-arg constructor. * @since 6.0.0 */ public ServerPush newServerPush(Desktop desktop, Class klass) { if (!ServerPush.class.isAssignableFrom(klass)) throw new UiException(klass + " must implement " + ServerPush.class); try { return (ServerPush) klass.newInstance(); } catch (Throwable ex) { throw UiException.Aide.wrap(ex, "Unable to instantiate " + klass); } }
public void onClose() { if (_listener != null) { final ClickEvent evt = new ClickEvent(Events.ON_CLOSE, this, null); try { _listener.onEvent(evt); if (!evt.isPropagatable()) return; //no more processing } catch (Exception ex) { throw UiException.Aide.wrap(ex); } } super.onClose(); }
private AnnotateBinder newAnnotateBinder(String name, String scope) { String clznm = Library.getProperty("org.zkoss.bind.AnnotateBinder.class"); if (clznm != null) { try { return (AnnotateBinder) Classes.newInstanceByThread(clznm, new Class[] { String.class, String.class }, new String[] { name, scope }); } catch (Exception e) { throw UiException.Aide.wrap(e, "Can't initialize binder"); } } else { return new AnnotateBinder(name, scope); } }
/** Instantiates a composer of the given class. * <p>Default: creates an instance of klass by use of its no-arg constructor. * @since 6.0.0 */ public Composer newComposer(Page page, Class klass) { if (!Composer.class.isAssignableFrom(klass)) throw new UiException(klass + " must implement " + Composer.class); try { return (Composer) klass.newInstance(); } catch (Throwable ex) { throw UiException.Aide.wrap(ex, "Unable to instantiate " + klass); } }
public int compare(Object o1, Object o2) { try { for (FieldInfo fi : _fieldnames) { final int res = compare0(o1, o2, fi.fieldname, fi.asc, fi.func); if (res != 0) { return res; } } return 0; } catch (NoSuchMethodException ex) { throw UiException.Aide.wrap(ex); } }
public WebApp newWebApp(Object ctx, Configuration config) { // the implementation is the same as org.zkoss.zk.ui.http.WebManager Class<?> cls = config.getWebAppClass(); if (cls != null) { try { return (WebApp) cls.newInstance(); } catch (Exception ex) { throw UiException.Aide.wrap(ex, "Unable to construct " + cls); } } else { return new SimpleWebApp(); } }
public void validate(ValidationContext ctx) { try { getValidator().validate(ctx); } catch (Exception e) { throw UiException.Aide.wrap(e, e.getMessage()); } }