/** * @deprecated since 6.5.4 */ @SuppressWarnings("rawtypes") public static Annotation getOverrideAnnotation(ComponentCtrl compCtrl, String propName, String annoName) { Collection<Annotation> annos = compCtrl.getAnnotations(propName, annoName); if (annos.size() <= 0) return null; //TODO the real implementation, currently I use the last one if (annos instanceof List) { return (Annotation) ((List) annos).get(((List) annos).size() - 1); } Iterator<Annotation> it = annos.iterator(); Annotation anno = it.next(); while (it.hasNext()) { anno = it.next(); } return anno; }
/** * @since 6.5.4 */ @SuppressWarnings("rawtypes") public static Annotation getSystemAnnotation(ComponentCtrl compCtrl, String propName) { //compatible to old spec, gets no ZKBIND prefix in annotation property first Collection<Annotation> annos = compCtrl.getAnnotations(propName, Binder.ZKBIND); if (annos.size() <= 0) { if (propName == null) return null; annos = compCtrl.getAnnotations(ZKBIND_PREFIX + propName, Binder.ZKBIND); if (annos.size() <= 0) return null; } //Use custom ZKBIND annotation instead of default ZKBIND annotation if any if (annos instanceof List) { return (Annotation) ((List) annos).get(0); } Iterator<Annotation> it = annos.iterator(); Annotation anno = it.next(); while (it.hasNext()) { anno = it.next(); } return anno; }
/** * Returns whether the property name contains with a dynamic value. */ protected boolean isDynamicValue(String propName) { final ComponentCtrl compCtrl = this; Collection<Annotation> annos = compCtrl.getAnnotations(propName); if (!annos.isEmpty()) { for (Annotation anno : annos) { final String annoName = anno.getName(); if (annoName.equals(BIND_ANNO) || annoName.equals(LOAD_ANNO) || annoName.equals(SAVE_ANNO) || annoName.equals(REFERENCE_ANNO) || annoName.equals(INIT_ANNO)) { return true; } } } return false; }
private Map<String, Object> getViewModelInitArgs(BindEvaluatorX evalx, Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; final Collection<Annotation> anncol = compCtrl.getAnnotations(VIEW_MODEL_ATTR, INIT_ANNO); if (anncol.size() == 0) return null; final Annotation ann = anncol.iterator().next(); final Map<String, String[]> attrs = ann.getAttributes(); //(tag, tagExpr) Map<String, String[]> args = null; for (final Iterator<Entry<String, String[]>> it = attrs.entrySet().iterator(); it.hasNext();) { final Entry<String, String[]> entry = it.next(); final String tag = entry.getKey(); final String[] tagExpr = entry.getValue(); if ("value".equals(tag)) { //ignore } else { //other unknown tag, keep as arguments if (args == null) { args = new HashMap<String, String[]>(); } args.put(tag, tagExpr); } } return args == null ? null : BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); }
continue; for (Annotation anno : compCtrl.getAnnotations(p)) { String nm = anno.getName(); try {
private ExpressionAnnoInfo parseValidator(Component comp, String propName) { final Collection<Annotation> annos = ((ComponentCtrl) comp).getAnnotations(propName, VALIDATOR_ANNO); if (annos.size() == 0) return null;
private void processChildrenBindings(Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; ExpressionAnnoInfo converterInfo = parseConverter(comp, CHILDREN_ATTR); //scan init first Collection<Annotation> initannos = compCtrl.getAnnotations(CHILDREN_ATTR, INIT_ANNO); if (initannos.size() > 1) { throw new IllegalSyntaxException(MiscUtil.formatLocationMessage( "Allow only one @init for " + CHILDREN_ATTR + " of " + comp, initannos.iterator().next())); } else if (initannos.size() == 1) { processChildrenInit(comp, initannos.iterator().next(), converterInfo); } Collection<Annotation> annos = compCtrl.getAnnotations(CHILDREN_ATTR); //get all annotation in the children with the order. for (Annotation anno : annos) { if (anno.getName().equals(BIND_ANNO)) { processChildrenPromptBindings(comp, anno, converterInfo); } else if (anno.getName().equals(LOAD_ANNO)) { processChildrenLoadBindings(comp, anno, converterInfo); } } ExpressionAnnoInfo templateInfo = parseTemplate(comp, CHILDREN_ATTR); if (templateInfo != null) { //use special CHILDREN_KEY to avoid conflict _binder.setTemplate(comp, CHILDREN_KEY, templateInfo.expr, templateInfo.args); } }
private ExpressionAnnoInfo parseTemplate(Component comp, String propName) { final Collection<Annotation> annos = ((ComponentCtrl) comp).getAnnotations(propName, TEMPLATE_ANNO); if (annos.size() == 0) return null;
private ExpressionAnnoInfo parseConverter(Component comp, String propName) { final Collection<Annotation> annos = ((ComponentCtrl) comp).getAnnotations(propName, CONVERTER_ANNO); if (annos.size() == 0) return null;
private void processGlobalCommandBinding(Component comp, String propName) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; final Collection<Annotation> anncol = compCtrl.getAnnotations(propName, GLOBAL_COMMAND_ANNO); if (anncol.size() == 0) return;
private void processCommandBinding(Component comp, String propName) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; final Collection<Annotation> anncol = compCtrl.getAnnotations(propName, COMMAND_ANNO); if (anncol.size() == 0) return;
Collection<Annotation> idannos = compCtrl.getAnnotations(FORM_ATTR, ID_ANNO); if (idannos.size() == 0) { throw new IllegalSyntaxException( Collection<Annotation> initannos = compCtrl.getAnnotations(FORM_ATTR, INIT_ANNO); if (initannos.size() > 1) { throw new IllegalSyntaxException(MiscUtil.formatLocationMessage( Collection<Annotation> annos = compCtrl.getAnnotations(FORM_ATTR); //get all annotation in the form with the order.
public void checkValidationMessages(Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; for (Annotation anno : compCtrl.getAnnotations(VALIDATION_MESSAGES_ATTR)) { String nm = anno.getName(); if (ID_ANNO.equals(nm) || INIT_ANNO.equals(nm)) { continue; } try { BinderUtil.pushContext().setCurrentLocation(anno.getLocation()); _collector.addInfo( new AnnoWarnInfo(comp, VALIDATION_MESSAGES_ATTR, nm, "Unknow validation messages annotation")); } finally { BinderUtil.popContext(); } } }
public void checkViewModel(Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; for (Annotation anno : compCtrl.getAnnotations(VIEW_MODEL_ATTR)) { String nm = anno.getName(); if (ID_ANNO.equals(nm) || INIT_ANNO.equals(nm)) { continue; } try { BinderUtil.pushContext().setCurrentLocation(anno.getLocation()); _collector.addInfo(new AnnoWarnInfo(comp, VIEW_MODEL_ATTR, nm, "Unknow viewmodel annotation")); } finally { BinderUtil.popContext(); } } }
public void checkBinder(Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; for (Annotation anno : compCtrl.getAnnotations(BINDER_ATTR)) { String nm = anno.getName(); if (ID_ANNO.equals(nm) || INIT_ANNO.equals(nm)) { continue; } try { BinderUtil.pushContext().setCurrentLocation(anno.getLocation()); _collector.addInfo(new AnnoWarnInfo(comp, BINDER_ATTR, nm, "Unknow binder annotation")); } finally { BinderUtil.popContext(); } } }
Collection<Annotation> initannos = compCtrl.getAnnotations(propName, INIT_ANNO); if (initannos.size() > 1) { throw new IllegalSyntaxException(MiscUtil.formatLocationMessage( Collection<Annotation> annos = compCtrl.getAnnotations(propName); //init in the annotation with the sequence