diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/AbstractBindingHandler.java b/zkbind/src/main/java/org/zkoss/bind/impl/AbstractBindingHandler.java index c00aadfe808..8e80633603d 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/AbstractBindingHandler.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/AbstractBindingHandler.java @@ -12,6 +12,7 @@ package org.zkoss.bind.impl; import java.io.Serializable; +import java.text.MessageFormat; import java.util.List; import java.util.Map; import java.util.Set; @@ -66,4 +67,14 @@ protected void addBinding(Map> bindingsMap, K bkey, V binding) bindingsMap.put(bkey, bindings0); } } + + protected String getSaveBindingDebugInfo(String operation, Object... args) { + return MessageFormat.format(operation + ":binding.save() " + + "comp=[{0}],binding=[{1}],command=[{2}],evt=[{3}],notifys=[{4}]", args); + } + + protected String getLoadBindingDebugInfo(String operation, Object... args) { + return MessageFormat.format(operation + ":binding.load() " + + "comp=[{0}],binding=[{1}],context=[{2}],command=[{3}]", args); + } } diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/BinderImpl.java b/zkbind/src/main/java/org/zkoss/bind/impl/BinderImpl.java index a44f7c6e29b..0f97e4a410a 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/BinderImpl.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/BinderImpl.java @@ -18,6 +18,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URLDecoder; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -91,6 +92,8 @@ import org.zkoss.bind.sys.debugger.BindingAnnotationInfoChecker; import org.zkoss.bind.sys.debugger.BindingExecutionInfoCollector; import org.zkoss.bind.sys.debugger.DebuggerFactory; +import org.zkoss.bind.sys.debugger.impl.DefaultAnnotationInfoChecker; +import org.zkoss.bind.sys.debugger.impl.DefaultExecutionInfoCollector; import org.zkoss.bind.sys.debugger.impl.info.AddBindingInfo; import org.zkoss.bind.sys.debugger.impl.info.AddCommandBindingInfo; import org.zkoss.bind.sys.debugger.impl.info.CommandInfo; @@ -447,8 +450,9 @@ public Map> getBindings(Component comp) { //called when onPropertyChange is fired to the subscribed event queue private void doPropertyChange(Object base, String prop) { + String debugInfo = MessageFormat.format("doPropertyChange: base=[{0}],prop=[{1}]", base, prop); if (_log.isDebugEnabled()) { - _log.debug("doPropertyChange:base=[{}],prop=[{}]", base, prop); + _log.debug(debugInfo); } //zk-1468, @@ -474,6 +478,8 @@ private void doPropertyChange(Object base, String prop) { collector.addInfo(new NotifyChangeInfo(_rootComp, base, prop, "Size=" + bindings.size())); } doPropertyChange0(base, prop, bindings); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { if (collector != null) { collector.popStack(); @@ -505,12 +511,16 @@ private void doPropertyChange0(Object base, String prop, Set bindin BindContextUtil.setConverterArgs(this, comp, ctx, (PropertyBinding) binding); } + String debugInfo = MessageFormat.format("doPropertyChange:binding.load() " + + "binding=[{0}],context=[{1}]", binding, ctx); try { if (_log.isDebugEnabled()) { - _log.debug("doPropertyChange:binding.load(),binding=[{}],context=[{}]", binding, ctx); + _log.debug(debugInfo); } doPrePhase(Phase.LOAD_BINDING, ctx); binding.load(ctx); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.LOAD_BINDING, ctx); } @@ -1795,8 +1805,10 @@ public void postCommand(String command, Map args) { private int doCommand(Component comp, CommandBinding commandBinding, String command, Event evt, Map commandArgs, Set notifys) { final String evtnm = evt == null ? null : evt.getName(); + String debugInfo = MessageFormat.format("doCommand " + + "comp=[{0}],command=[{1}],evtnm=[{2}]", comp, command, evtnm); if (_log.isDebugEnabled()) { - _log.debug("Start doCommand comp=[{}],command=[{}],evtnm=[{}]", comp, command, evtnm); + _log.debug("Start " + debugInfo); } BindContext ctx = BindContextUtil.newBindContext(this, commandBinding, false, command, comp, evt); BindContextUtil.setCommandArgs(this, comp, ctx, commandArgs); @@ -1837,6 +1849,8 @@ private int doCommand(Component comp, CommandBinding commandBinding, String comm _log.debug("End doCommand"); } return COMMAND_SUCCESS; + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.COMMAND, ctx); //end of Command } @@ -1845,8 +1859,9 @@ private int doCommand(Component comp, CommandBinding commandBinding, String comm private void doGlobalCommand(Component comp, String command, Event evt, Map commandArgs, Set notifys) { + String debugInfo = MessageFormat.format("doGlobalCommand comp=[{0}],command=[{1}]", comp, command); if (_log.isDebugEnabled()) { - _log.debug("Start doGlobalCommand comp=[{}],command=[{}]", comp, command); + _log.debug("Start " + debugInfo); } BindContext ctx = BindContextUtil.newBindContext(this, null, false, command, comp, evt); @@ -1862,6 +1877,8 @@ private void doGlobalCommand(Component comp, String command, Event evt, Map commandArgs, BindContext ctx, Set notifys) { + String debugInfo = MessageFormat.format("doGlobalCommandExecute comp=[{0}],command=[{1}]", comp, command); try { if (_log.isDebugEnabled()) { - _log.debug("before doGlobalCommandExecute comp=[{}],command=[{}]", comp, command); + _log.debug("before " + debugInfo); } doPrePhase(Phase.EXECUTE, ctx); @@ -1898,10 +1916,13 @@ private void doGlobalCommandExecute(Component comp, String command, Map doValidate protected boolean doValidate(Component comp, String command, Event evt, BindContext ctx, Set notifys) { final Set validates = new HashSet(); + String debugInfo = MessageFormat.format("doValidate " + + "comp=[{0}],command=[{1}],evt=[{2}],context=[{3}]", comp, command, evt, ctx); try { if (_log.isDebugEnabled()) { - _log.debug("doValidate comp=[{}],command=[{}],evt=[{}],context=[{}]", comp, command, evt, ctx); + _log.debug(debugInfo); } doPrePhase(Phase.VALIDATE, ctx); @@ -2022,6 +2045,7 @@ public BindingKey getBindingKey(Component comp, String attr) { if (_log.isDebugEnabled()) { _log.debug("doValidate validates=[{}]", validates); } + debugInfo += MessageFormat.format(",validates=[{0}]", validates); boolean valid = true; //ZK-878 Exception if binding a form with errorMessage @@ -2052,6 +2076,7 @@ public BindingKey getBindingKey(Component comp, String attr) { return valid; } } catch (Exception e) { + _log.error(debugInfo, e); throw UiException.Aide.wrap(e, e.getMessage()); } finally { doPostPhase(Phase.VALIDATE, ctx); @@ -2076,6 +2101,8 @@ protected ParamCall createParamCall(BindContext ctx) { protected void doExecute(Component comp, String command, Map commandArgs, BindContext ctx, Set notifys) { + String debugInfo = MessageFormat.format("doExecute " + + "comp=[{0}],command=[{1}],notifys=[{2}]", comp, command, notifys); try { Matcher matcher = CALL_OTHER_VM_COMMAND_PATTERN.matcher(command); if (matcher.find()) { @@ -2088,7 +2115,7 @@ protected void doExecute(Component comp, String command, Map com } } if (_log.isDebugEnabled()) { - _log.debug("before doExecute comp=[{}],command=[{}],notifys=[{}]", comp, command, notifys); + _log.debug("before " + debugInfo); } doPrePhase(Phase.EXECUTE, ctx); @@ -2122,6 +2149,8 @@ protected void doExecute(Component comp, String command, Map com if (_log.isDebugEnabled()) { _log.debug("after doExecute notifys=[{}]", notifys); } + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.EXECUTE, ctx); } @@ -2217,26 +2246,34 @@ private Method getCommandMethod(Class clz, String command, CommandMethodInfoP //doCommand -> doSaveBefore protected void doSaveBefore(Component comp, String command, Event evt, BindContext ctx, Set notifys) { + String debugInfo = MessageFormat.format("doSaveBefore " + + "comp=[{0}],command=[{1}],evt=[{2}],notifys=[{3}]", comp, command, evt, notifys); if (_log.isDebugEnabled()) { - _log.debug("doSaveBefore, comp=[{}],command=[{}],evt=[{}],notifys=[{}]", comp, command, evt, notifys); + _log.debug(debugInfo); } try { doPrePhase(Phase.SAVE_BEFORE, ctx); _propertyBindingHandler.doSaveBefore(comp, command, evt, notifys); _formBindingHandler.doSaveBefore(comp, command, evt, notifys); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.SAVE_BEFORE, ctx); } } protected void doSaveAfter(Component comp, String command, Event evt, BindContext ctx, Set notifys) { + String debugInfo = MessageFormat.format("doSaveAfter " + + "comp=[{0}],command=[{1}],evt=[{2}],notifys=[{3}]", comp, command, evt, notifys); if (_log.isDebugEnabled()) { - _log.debug("doSaveAfter, comp=[{}],command=[{}],evt=[{}],notifys=[{}]", comp, command, evt, notifys); + _log.debug(debugInfo); } try { doPrePhase(Phase.SAVE_AFTER, ctx); _propertyBindingHandler.doSaveAfter(comp, command, evt, notifys); _formBindingHandler.doSaveAfter(comp, command, evt, notifys); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.SAVE_AFTER, ctx); } @@ -2244,28 +2281,34 @@ protected void doSaveAfter(Component comp, String command, Event evt, BindContex } protected void doLoadBefore(Component comp, String command, BindContext ctx) { + String debugInfo = MessageFormat.format("doLoadBefore comp=[{0}],command=[{1}]", comp, command); if (_log.isDebugEnabled()) { - _log.debug("doLoadBefore, comp=[{}],command=[{}]", comp, command); + _log.debug(debugInfo); } try { doPrePhase(Phase.LOAD_BEFORE, ctx); _propertyBindingHandler.doLoadBefore(comp, command); _formBindingHandler.doLoadBefore(comp, command); _childrenBindingHandler.doLoadBefore(comp, command); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.LOAD_BEFORE, ctx); } } protected void doLoadAfter(Component comp, String command, BindContext ctx) { + String debugInfo = MessageFormat.format("doLoadAfter comp=[{0}],command=[{1}]", comp, command); if (_log.isDebugEnabled()) { - _log.debug("doLoadAfter, comp=[{}],command=[{}]", comp, command); + _log.debug(debugInfo); } try { doPrePhase(Phase.LOAD_AFTER, ctx); _propertyBindingHandler.doLoadAfter(comp, command); _formBindingHandler.doLoadAfter(comp, command); _childrenBindingHandler.doLoadAfter(comp, command); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.LOAD_AFTER, ctx); } @@ -2590,8 +2633,9 @@ public void notifyChange(Object base, String attr) { private void postGlobalCommand(Component comp, CommandBinding commandBinding, String command, Event evt, Map args) { + String debugInfo = MessageFormat.format("postGlobalCommand command=[{0}],args=[{1}]", command, args); if (_log.isDebugEnabled()) { - _log.debug("postGlobalCommand command=[{}], args=[{}]", command, args); + _log.debug(debugInfo); } final BindingExecutionInfoCollector collector = getBindingExecutionInfoCollector(); @@ -2604,6 +2648,8 @@ private void postGlobalCommand(Component comp, CommandBinding commandBinding, St } getEventQueue().publish(new GlobalCommandEvent(_rootComp, command, args, evt)); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { if (collector != null) { collector.popStack(); @@ -2829,12 +2875,26 @@ public void init(Execution exec, Execution parent) throws Exception { public BindingExecutionInfoCollector getBindingExecutionInfoCollector() { DebuggerFactory factory = DebuggerFactory.getInstance(); - return factory == null ? null : factory.getExecutionInfoCollector(); + if (factory == null) return null; + // ZK-5048: setViewModelClass for MVVM DebuggerFactory to log via SLF4J + BindingExecutionInfoCollector collector = factory.getExecutionInfoCollector(); + if (collector instanceof DefaultExecutionInfoCollector) { + Class vmClass = BindUtils.getViewModelClass(getViewModelInView()); + ((DefaultExecutionInfoCollector) collector).setViewModelClass(vmClass); + } + return collector; } public BindingAnnotationInfoChecker getBindingAnnotationInfoChecker() { DebuggerFactory factory = DebuggerFactory.getInstance(); - return factory == null ? null : factory.getAnnotationInfoChecker(); + if (factory == null) return null; + // ZK-5048: setViewModelClass for MVVM DebuggerFactory to log via SLF4J + BindingAnnotationInfoChecker checker = factory.getAnnotationInfoChecker(); + if (checker instanceof DefaultAnnotationInfoChecker) { + Class vmClass = BindUtils.getViewModelClass(getViewModelInView()); + ((DefaultAnnotationInfoChecker) checker).setViewModelClass(vmClass); + } + return checker; } public String getQueueName() { diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/ChildrenBindingHandler.java b/zkbind/src/main/java/org/zkoss/bind/impl/ChildrenBindingHandler.java index dd59e13eb5d..19de4dfc6ba 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/ChildrenBindingHandler.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/ChildrenBindingHandler.java @@ -88,13 +88,15 @@ private void doLoadBinding(Component comp, LoadChildrenBinding binding, String c if (binding instanceof InitChildrenBindingImpl) { ctx.setAttribute(BinderImpl.IGNORE_TRACKER, Boolean.TRUE); //ignore tracker when doing el , we don't need to track the init } + String debugInfo = getLoadBindingDebugInfo("doLoadChildrenBinding", comp, binding, ctx, command); try { if (_log.isDebugEnabled()) { - _log.debug("doLoadChildrenBinding:binding.load(),component=[{}],binding=[{}],context=[{}],command=[{}]", - comp, binding, ctx, command); + _log.debug(debugInfo); } doPrePhase(Phase.LOAD_BINDING, ctx); binding.load(ctx); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.LOAD_BINDING, ctx); } diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/FormBindingHandler.java b/zkbind/src/main/java/org/zkoss/bind/impl/FormBindingHandler.java index d90f7762125..7f17f7492f7 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/FormBindingHandler.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/FormBindingHandler.java @@ -105,13 +105,15 @@ private void doSaveBinding(Component comp, SaveFormBinding binding, String comma evt); BindContextUtil.setValidatorArgs(_binder, binding.getComponent(), ctx, binding); //TODO converter args when we support converter in form + String debugInfo = getSaveBindingDebugInfo("doSaveFormBinding", comp, binding, command, evt, notifys); try { if (_log.isDebugEnabled()) { - _log.debug("doSaveFormBinding:binding.save() comp=[{}],binding=[{}],command=[{}],evt=[{}],notifys=[{}]", - comp, binding, command, evt, notifys); + _log.debug(debugInfo); } doPrePhase(Phase.SAVE_BINDING, ctx); binding.save(ctx); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.SAVE_BINDING, ctx); } @@ -130,10 +132,10 @@ private void doLoadBinding(Component comp, LoadFormBinding binding, String comma ctx.setAttribute(BinderImpl.IGNORE_TRACKER, Boolean.TRUE); //ignore tracker when doing el , we don't need to track the init } //TODO converter args when we support converter in form + String debugInfo = getLoadBindingDebugInfo("doLoadFormBinding", comp, binding, ctx, command); try { if (_log.isDebugEnabled()) { - _log.debug("doLoadFormBinding:binding.load(),component=[{}],binding=[{}],context=[{}],command=[{}]", - comp, binding, ctx, command); + _log.debug(debugInfo); } doPrePhase(Phase.LOAD_BINDING, ctx); binding.load(ctx); @@ -142,6 +144,8 @@ private void doLoadBinding(Component comp, LoadFormBinding binding, String comma if (((BinderImpl) binding.getBinder()).hasValidator(binding.getComponent(), binding.getFormId())) { clearValidationMessages(binding.getBinder(), binding.getComponent(), binding.getFormId()); } + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.LOAD_BINDING, ctx); } diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/PropertyBindingHandler.java b/zkbind/src/main/java/org/zkoss/bind/impl/PropertyBindingHandler.java index 1900f04ab80..51ea296dd14 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/PropertyBindingHandler.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/PropertyBindingHandler.java @@ -11,6 +11,7 @@ */ package org.zkoss.bind.impl; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -105,14 +106,15 @@ private void doSaveBinding(Component comp, SavePropertyBinding binding, String c evt); BindContextUtil.setConverterArgs(_binder, binding.getComponent(), ctx, binding); BindContextUtil.setValidatorArgs(_binder, binding.getComponent(), ctx, binding); + String debugInfo = getSaveBindingDebugInfo("doSavePropertyBinding", comp, binding, command, evt, notifys); try { if (_log.isDebugEnabled()) { - _log.debug( - "doSavePropertyBinding:binding.save() comp=[{}],binding=[{}],command=[{}],evt=[{}],notifys=[{}]", - comp, binding, command, evt, notifys); + _log.debug(debugInfo); } doPrePhase(Phase.SAVE_BINDING, ctx); binding.save(ctx); + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.SAVE_BINDING, ctx); } @@ -131,10 +133,10 @@ private void doLoadBinding(Component comp, LoadPropertyBinding binding, String c if (binding instanceof InitPropertyBindingImpl) { ctx.setAttribute(BinderImpl.IGNORE_TRACKER, Boolean.TRUE); //ignore tracker when doing el , we don't need to track the init } + String debugInfo = getLoadBindingDebugInfo("doLoadPropertyBinding", comp, binding, ctx, command); try { if (_log.isDebugEnabled()) { - _log.debug("doLoadPropertyBinding:binding.load(),component=[{}],binding=[{}],context=[{}],command=[{}]", - comp, binding, ctx, command); + _log.debug(debugInfo); } doPrePhase(Phase.LOAD_BINDING, ctx); binding.load(ctx); @@ -143,6 +145,8 @@ private void doLoadBinding(Component comp, LoadPropertyBinding binding, String c if (((BinderImpl) binding.getBinder()).hasValidator(binding.getComponent(), binding.getFieldName())) { clearValidationMessages(binding.getBinder(), binding.getComponent(), binding.getFieldName()); } + } catch (Exception ex) { + throw new RuntimeException(debugInfo, ex); } finally { doPostPhase(Phase.LOAD_BINDING, ctx); } @@ -184,12 +188,14 @@ private boolean doValidateSaveEvent(Component comp, SavePropertyBinding binding, BindContextUtil.setConverterArgs(_binder, binding.getComponent(), ctx, binding); BindContextUtil.setValidatorArgs(_binder, binding.getComponent(), ctx, binding); + String debugInfo = MessageFormat.format("doValidateSaveEvent " + + "comp=[{0}],binding=[{1}],evt=[{2}]", comp, binding, evt); try { doPrePhase(Phase.VALIDATE, ctx); final Property p = binding.getValidate(ctx); + debugInfo += MessageFormat.format(",validate=[{0}]", p); if (_log.isDebugEnabled()) { - _log.debug("doValidateSaveEvent comp=[{}],binding=[{}],evt=[{}],validate=[{}]", comp, binding, evt, - p); + _log.debug(debugInfo); } if (p == null) { throw new UiException("no main property for save-binding " + binding); @@ -206,6 +212,7 @@ private boolean doValidateSaveEvent(Component comp, SavePropertyBinding binding, if (_log.isDebugEnabled()) { _log.debug("doValidateSaveEvent result=[{}]", valid); } + debugInfo += MessageFormat.format(",result=[{0}]", valid); final Set xnotifys = getNotifys(ctx); if (xnotifys != null) { @@ -214,6 +221,7 @@ private boolean doValidateSaveEvent(Component comp, SavePropertyBinding binding, return valid; } catch (Exception e) { + _log.error(debugInfo); throw UiException.Aide.wrap(e); } finally { doPostPhase(Phase.VALIDATE, ctx); diff --git a/zkbind/src/main/java/org/zkoss/bind/sys/debugger/impl/DefaultAnnotationInfoChecker.java b/zkbind/src/main/java/org/zkoss/bind/sys/debugger/impl/DefaultAnnotationInfoChecker.java index fb78b93db3f..31e04bf76f4 100644 --- a/zkbind/src/main/java/org/zkoss/bind/sys/debugger/impl/DefaultAnnotationInfoChecker.java +++ b/zkbind/src/main/java/org/zkoss/bind/sys/debugger/impl/DefaultAnnotationInfoChecker.java @@ -53,9 +53,20 @@ public class DefaultAnnotationInfoChecker implements BindingAnnotationInfoChecke // private static final String QUEUE_SCOPE_ANNO_ATTR = "queueScope"; BindingExecutionInfoCollector _collector; + private Class _viewModelClass; DefaultAnnotationInfoChecker(BindingExecutionInfoCollector collector) { _collector = collector; + if (_collector instanceof DefaultExecutionInfoCollector) + ((DefaultExecutionInfoCollector) _collector).setViewModelClass(getViewModelClass()); + } + + protected Class getViewModelClass() { + return _viewModelClass; + } + + public void setViewModelClass(Class viewModelClass) { + _viewModelClass = viewModelClass; } public void checkBinding(Binder binder, Component comp) { diff --git a/zkbind/src/main/java/org/zkoss/bind/sys/debugger/impl/DefaultExecutionInfoCollector.java b/zkbind/src/main/java/org/zkoss/bind/sys/debugger/impl/DefaultExecutionInfoCollector.java index 385867b515f..540aee2a98b 100644 --- a/zkbind/src/main/java/org/zkoss/bind/sys/debugger/impl/DefaultExecutionInfoCollector.java +++ b/zkbind/src/main/java/org/zkoss/bind/sys/debugger/impl/DefaultExecutionInfoCollector.java @@ -11,6 +11,8 @@ */ package org.zkoss.bind.sys.debugger.impl; +import org.slf4j.LoggerFactory; + import org.zkoss.bind.sys.debugger.impl.info.AddBindingInfo; import org.zkoss.bind.sys.debugger.impl.info.AddCommandBindingInfo; import org.zkoss.bind.sys.debugger.impl.info.AnnoWarnInfo; @@ -32,6 +34,16 @@ public class DefaultExecutionInfoCollector extends AbstractExecutionInfoCollecto private boolean _startLine = false; + private Class _viewModelClass; + + protected Class getViewModelClass() { + return _viewModelClass; + } + + public void setViewModelClass(Class viewModelClass) { + _viewModelClass = viewModelClass; + } + public void addInfo(JSONObject info) { Object type = info.get("type"); @@ -125,7 +137,7 @@ public void addInfo(JSONObject info) { } protected void out(String string) { - System.out.println(string); + LoggerFactory.getLogger(getViewModelClass()).info(string); } } diff --git a/zkdoc/release-note b/zkdoc/release-note index da44da6124c..c9594307cd6 100644 --- a/zkdoc/release-note +++ b/zkdoc/release-note @@ -4,6 +4,7 @@ ZK 10.0.0 ZK-5018: Enhance simplified MVVM syntax ZK-5516: change the current month with a keyboard ZK-5517: change the current year with a keyboard + ZK-5048: MVVM DebuggerFactory should log via SLF4J ZK-5595: Upgrade Servlet version from 2.4 to 3.1 aligned with Java EE 7 * Bugs diff --git a/zktest/build.gradle b/zktest/build.gradle index 9a67bf8eb16..05f7badbcce 100644 --- a/zktest/build.gradle +++ b/zktest/build.gradle @@ -268,6 +268,7 @@ description = 'ZK Test' gretty { httpPort = 8080 + systemProperty 'java.util.logging.config.file', './src/main/webapp/WEB-INF/logging.properties' } // Start browsersync in the background. diff --git a/zktest/src/main/java/org/zkoss/zktest/test2/F100_ZK_5048VM.java b/zktest/src/main/java/org/zkoss/zktest/test2/F100_ZK_5048VM.java new file mode 100644 index 00000000000..ac67bbf1ef1 --- /dev/null +++ b/zktest/src/main/java/org/zkoss/zktest/test2/F100_ZK_5048VM.java @@ -0,0 +1,17 @@ +/* F100_ZK_5048VM.java + + Purpose: + + Description: + + History: + Mon Dec 11 11:53:50 CST 2023, Created by rebeccalai + +Copyright (C) 2023 Potix Corporation. All Rights Reserved. +*/ +package org.zkoss.zktest.test2; + +public class F100_ZK_5048VM { + public void myCommand() { + } +} diff --git a/zktest/src/main/webapp/WEB-INF/logging.properties b/zktest/src/main/webapp/WEB-INF/logging.properties index 3520324ec78..652d3247b21 100644 --- a/zktest/src/main/webapp/WEB-INF/logging.properties +++ b/zktest/src/main/webapp/WEB-INF/logging.properties @@ -1,5 +1,4 @@ # java.logging setting -# use -Djava.util.logging.config.file=src/archive/WEB-INF/logging.properties to apply it # Default system setting handlers=java.util.logging.ConsoleHandler diff --git a/zktest/src/main/webapp/test2/F100-ZK-5048.zul b/zktest/src/main/webapp/test2/F100-ZK-5048.zul new file mode 100644 index 00000000000..72d6b6774cc --- /dev/null +++ b/zktest/src/main/webapp/test2/F100-ZK-5048.zul @@ -0,0 +1,25 @@ + + + + +
+
+
\ No newline at end of file diff --git a/zktest/src/main/webapp/test2/config.properties b/zktest/src/main/webapp/test2/config.properties index 8eb9dd55437..0135b74e34c 100644 --- a/zktest/src/main/webapp/test2/config.properties +++ b/zktest/src/main/webapp/test2/config.properties @@ -3733,6 +3733,7 @@ F86-ZK-4235.zul=A,E,datefmt,library-property ##zats##F100-ZK-5018-syntax-exception.zul=A,E,MVVM,Syntax,simplified ##zats##F100-ZK-5516.zul=A,E,calendar,month,keyboard ##zats##F100-ZK-5517.zul=A,E,calendar,year,keyboard +##manually##F100-ZK-5048.zul=A,E,MVVM,DebuggerFactory,Log # Complex Test Case # diff --git a/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01016NestedFormTest.java b/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01016NestedFormTest.java index 9e0583e8d3e..c5426a66a61 100644 --- a/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01016NestedFormTest.java +++ b/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01016NestedFormTest.java @@ -12,7 +12,7 @@ public void test() { try { connect(); } catch (Exception e) { - assertTrue(e.getCause().toString().contains("UiException: doesn't support to load a nested form")); + assertTrue(e.getCause().getCause().toString().contains("UiException: doesn't support to load a nested form")); } } } diff --git a/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01059DifferentTypeTest.java b/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01059DifferentTypeTest.java index 43d1cbedb54..cd834ee6d72 100644 --- a/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01059DifferentTypeTest.java +++ b/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01059DifferentTypeTest.java @@ -22,7 +22,7 @@ public void test() { try { ib1.type("1"); } catch(Exception e) { - exceptionMsg = e.getCause().toString(); + exceptionMsg = e.getCause().getCause().getCause().toString(); } assertTrue(exceptionMsg.contains("Property 'value1' not writable")); exceptionMsg = ""; @@ -32,7 +32,7 @@ public void test() { try { ib3.type("3"); } catch(Exception e) { - exceptionMsg = e.getCause().toString(); + exceptionMsg = e.getCause().getCause().getCause().toString(); } assertTrue(exceptionMsg.contains("Property 'value3' not writable")); } diff --git a/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01063BindExceptionTest.java b/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01063BindExceptionTest.java index eb481959e22..0d7dbd99e5c 100644 --- a/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01063BindExceptionTest.java +++ b/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01063BindExceptionTest.java @@ -27,7 +27,7 @@ public void test() { try { tb3.type("3"); } catch(Exception e) { - exceptionMsg = e.getCause().toString(); + exceptionMsg = e.getCause().getCause().getCause().toString(); } assertTrue(exceptionMsg.contains("Property 'valuex' not found")); } diff --git a/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01167ConverterIdxOutOfBoundTest.java b/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01167ConverterIdxOutOfBoundTest.java index b65ef193466..09902053ce1 100644 --- a/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01167ConverterIdxOutOfBoundTest.java +++ b/zktest/src/test/java/org/zkoss/zktest/zats/bind/issue/B01167ConverterIdxOutOfBoundTest.java @@ -13,7 +13,7 @@ public void test() { try { connect(); } catch(ZatsException e) { - assertTrue(e.getCause().toString().contains("UiException: Cannot find converter:something")); + assertTrue(e.getCause().getCause().toString().contains("UiException: Cannot find converter:something")); } } } diff --git a/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/command/GlobalCommandTest.java b/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/command/GlobalCommandTest.java index 07a38958e61..c036f48fd2d 100644 --- a/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/command/GlobalCommandTest.java +++ b/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/command/GlobalCommandTest.java @@ -62,6 +62,6 @@ public void testDefaultDuplicated() { final DesktopAgent desktop = connect("/bind/viewmodel/command/global-command-duplicated-default.zul"); Throwable t = Assertions.assertThrows(ZatsException.class, () -> desktop.query("button").click()); - MatcherAssert.assertThat(t.getMessage(), startsWith("there are more than one DefaultGlobalCommand method in class")); + MatcherAssert.assertThat(t.getCause().getCause().getCause().getMessage(), startsWith("there are more than one DefaultGlobalCommand method in class")); } } diff --git a/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/command/LocalCommandTest.java b/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/command/LocalCommandTest.java index 5d8443bcb63..0ff3fff0690 100644 --- a/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/command/LocalCommandTest.java +++ b/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/command/LocalCommandTest.java @@ -48,7 +48,7 @@ public void testDuplicated() { final DesktopAgent desktop = connect("/bind/viewmodel/command/local-command-duplicated.zul"); Throwable t = Assertions.assertThrows(ZatsException.class, () -> desktop.query("button").click()); - MatcherAssert.assertThat(t.getMessage(), startsWith("there are more than one Command method command1 in class")); + MatcherAssert.assertThat(t.getCause().getCause().getCause().getMessage(), startsWith("there are more than one Command method command1 in class")); } @Test @@ -56,6 +56,6 @@ public void testDefaultDuplicated() { final DesktopAgent desktop = connect("/bind/viewmodel/command/local-command-duplicated-default.zul"); Throwable t = Assertions.assertThrows(ZatsException.class, () -> desktop.query("button").click()); - MatcherAssert.assertThat(t.getMessage(), startsWith("there are more than one DefaultCommand method in class")); + MatcherAssert.assertThat(t.getCause().getCause().getCause().getMessage(), startsWith("there are more than one DefaultCommand method in class")); } } diff --git a/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/notification/NotifyChangeDisabledTest.java b/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/notification/NotifyChangeDisabledTest.java index 2edb529d329..ab15b0a4b1d 100644 --- a/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/notification/NotifyChangeDisabledTest.java +++ b/zktest/src/test/java/org/zkoss/zktest/zats/bind/viewmodel/notification/NotifyChangeDisabledTest.java @@ -47,7 +47,7 @@ public void testIllegalUsage1() { Throwable t = Assertions.assertThrows(AgentException.class, () -> { desktop.query("#inp2").type("ZK"); }); - MatcherAssert.assertThat(t.getCause().getMessage(), is("don't use interface" + + MatcherAssert.assertThat(t.getCause().getCause().getCause().getMessage(), is("don't use interface" + " org.zkoss.bind.annotation.NotifyChange with interface" + " org.zkoss.bind.annotation.NotifyChangeDisabled, choose only one")); } @@ -57,7 +57,7 @@ public void testIllegalUsage2() { Throwable t = Assertions.assertThrows(AgentException.class, () -> { desktop.query("#inp3").type("ZK"); }); - MatcherAssert.assertThat(t.getCause().getMessage(), is("don't use interface" + + MatcherAssert.assertThat(t.getCause().getCause().getCause().getMessage(), is("don't use interface" + " org.zkoss.bind.annotation.SmartNotifyChange with interface" + " org.zkoss.bind.annotation.NotifyChangeDisabled, choose only one")); }