Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-878

Exception if binding a form with errorMessage

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 6.0.1
    • 6.0.0
    • Databind 2
    • None

      org.zkoss.zel.ELException: Error reading 'value' on type org.zkoss.zul.Textbox
      	at org.zkoss.zel.BeanELResolver.getValue(BeanELResolver.java:93)
      	at org.zkoss.zel.CompositeELResolver.getValue(CompositeELResolver.java:67)
      	at org.zkoss.zel.CompositeELResolver.getValue(CompositeELResolver.java:67)
      	at org.zkoss.xel.zel.XelELResolver.getValue(XelELResolver.java:71)
      	at org.zkoss.bind.xel.zel.BindELResolver.getValue(BindELResolver.java:64)
      	at org.zkoss.zel.impl.parser.AstValue.getValue(AstValue.java:179)
      	at org.zkoss.zel.impl.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
      	at org.zkoss.xel.zel.ELXelExpression.evaluate(ELXelExpression.java:40)
      	at org.zkoss.bind.impl.BindEvaluatorXImpl.getValue(BindEvaluatorXImpl.java:44)
      	at org.zkoss.bind.impl.SavePropertyBindingImpl.getComponentValue(SavePropertyBindingImpl.java:97)
      	at org.zkoss.bind.impl.SavePropertyBindingImpl.getValidate(SavePropertyBindingImpl.java:139)
      	at org.zkoss.bind.impl.ValidationHelper.collectSavePropertyBinding(ValidationHelper.java:184)
      	at org.zkoss.bind.impl.ValidationHelper.collectSaveFormBinding(ValidationHelper.java:195)
      	at org.zkoss.bind.impl.ValidationHelper.collectSaveFormAfter(ValidationHelper.java:110)
      	at org.zkoss.bind.impl.ValidationHelper.collectSaveAfter(ValidationHelper.java:91)
      	at org.zkoss.bind.impl.BinderImpl.doValidate(BinderImpl.java:1440)
      	at org.zkoss.bind.impl.BinderImpl.doCommand(BinderImpl.java:1257)
      	at org.zkoss.bind.impl.BinderImpl.access$7(BinderImpl.java:1245)
      	at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent(BinderImpl.java:1148)
      	at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2741)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2712)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2653)
      	at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1699)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1484)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1201)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:558)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:456)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:464)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
      	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
      	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
      	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.Server.handle(Server.java:326)
      	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
      	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
      	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
      	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
      Caused by: org.zkoss.zk.ui.WrongValueException: the name have to equals to Lin, but is A
      	at org.zkoss.zul.impl.InputElement.checkUserError(InputElement.java:655)
      	at org.zkoss.zul.impl.InputElement.getText(InputElement.java:248)
      	at org.zkoss.zul.Textbox.getValue(Textbox.java:47)
      	at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.zkoss.zel.BeanELResolver.getValue(BeanELResolver.java:87)
      	... 45 more
      

      1.type A in textbox click save, you will see wrong message 'the name have to equals to Lin, but is A'
      2.type B in textbox click save, you will see exception showing in console if you wrap BinderImpl.this.doCommand and print the cached exception.

      <window apply="org.zkoss.bind.BindComposer"
      	viewModel="@id('vm') @init('org.zkoss.zktest.bind.issue.Bx')"
      	validationMessages="@id('vmsgs')">
      	<vlayout>
      		<hlayout>
      			<label value="@bind(vm.name)" />
      		</hlayout>
      		<hlayout form="@id('fx') @load(vm) @save(vm, after='save2') @validator(vm.validator1)" >
      			Name :
      			<textbox id="tb2" value="@bind(fx.name)" errorMessage="@load(vmsgs[self.parent])" />
      		</hlayout>
      		 
      		<button label="save2" onClick="@command('save2')"/>
      	</vlayout>
      </window>
      
      public class Bx {
      
      	String name;
      
      	public Bx() {
      	}
      
      	public String getName() {
      		return name;
      	}
      	
      	public void setName(String name) {
      		this.name = name;
      	}
      
      	@Command
      	public void save1(){
      		
      	}
      	@Command
      	public void save2(){
      		
      	}
      
      	public Validator getValidator1(){
      		return new AbstractValidator() {
      			
      			@Override
      			public void validate(ValidationContext ctx) {
      				String name = (String)ctx.getProperties("name")[0].getValue();
      				if(!"Lin".equals(name)){
      					addInvalidMessage(ctx, "the name have to equals to Lin, but is "+name);
      				}
      			}
      		};
      	}
      }
      

            Unassigned Unassigned
            dennis dennis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: